.
This commit is contained in:
parent
b07eb454eb
commit
3182771455
@ -1,7 +1,8 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mock, test } from "node:test";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
test("conecta la alta rápida directa y la alta rápida desde selector con callbacks distintos", async () => {
|
||||
const openSelectDialog = () => undefined;
|
||||
@ -161,10 +162,7 @@ test("conecta la alta rápida directa y la alta rápida desde selector con callb
|
||||
|
||||
assert.equal(capturedEditorProps?.onChangeCustomerClick, openSelectDialog);
|
||||
assert.equal(capturedEditorProps?.onCreateCustomerClick, openQuickCreateDialog);
|
||||
assert.equal(
|
||||
capturedSelectDialogProps?.onCreateNewCustomerClick,
|
||||
openQuickCreateFromSelection
|
||||
);
|
||||
assert.equal(capturedSelectDialogProps?.onCreateNewCustomerClick, openQuickCreateFromSelection);
|
||||
assert.equal(capturedQuickCreateDialogProps?.ctrl, quickCreateCtrl);
|
||||
|
||||
mock.restoreAll();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mock, test } from "node:test";
|
||||
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
|
||||
test("expone apertura directa y apertura desde selector con comportamientos distintos", async () => {
|
||||
@ -16,9 +17,7 @@ test("expone apertura directa y apertura desde selector con comportamientos dist
|
||||
mock.module("../../quick-create-customer", {
|
||||
namedExports: {
|
||||
QuickCreateCustomerDialog: () => null,
|
||||
useQuickCreateCustomerFlow: (
|
||||
options: NonNullable<typeof quickCreateOptions>
|
||||
) => {
|
||||
useQuickCreateCustomerFlow: (options: NonNullable<typeof quickCreateOptions>) => {
|
||||
quickCreateOptions = options;
|
||||
|
||||
return {
|
||||
@ -54,9 +53,7 @@ test("expone apertura directa y apertura desde selector con comportamientos dist
|
||||
const { useCustomerSelectionFlow } = await import("./use-customer-selection-flow.ts");
|
||||
|
||||
const selectedCustomers: Array<{ id: string }> = [];
|
||||
let flow:
|
||||
| ReturnType<typeof useCustomerSelectionFlow>
|
||||
| undefined;
|
||||
let flow: ReturnType<typeof useCustomerSelectionFlow> | undefined;
|
||||
|
||||
const Harness = () => {
|
||||
flow = useCustomerSelectionFlow({
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { CustomerSelectionOption } from "../entities";
|
||||
import { QuickCreateCustomerDialog, useQuickCreateCustomerFlow } from "../../quick-create-customer";
|
||||
import type { CustomerSelectionOption } from "../entities";
|
||||
import { SelectCustomerDialog } from "../ui";
|
||||
|
||||
import { useSelectCustomerDialogController } from "./use-select-customer-dialog-controller";
|
||||
|
||||
@ -14,10 +14,10 @@ import {
|
||||
import { useId, useState } from "react";
|
||||
import type { FieldErrors } from "react-hook-form";
|
||||
|
||||
import type { CustomerSelectionOption } from "../../customer-selection";
|
||||
import { buildCustomerSelectionOption } from "../../customer-selection";
|
||||
import { useTranslation } from "../../../../web/i18n";
|
||||
import { useCustomerCreateMutation } from "../../../../web/shared/hooks";
|
||||
import type { CustomerSelectionOption } from "../../customer-selection";
|
||||
import { buildCustomerSelectionOption } from "../../customer-selection";
|
||||
import { type QuickCustomerCreateForm, QuickCustomerCreateFormSchema } from "../entities";
|
||||
import {
|
||||
buildCreateCustomerParamsFromQuickForm,
|
||||
@ -120,7 +120,7 @@ export const useQuickCreateCustomerDialogController = (
|
||||
|
||||
if (isValidationErrorCollection(normalizedError)) {
|
||||
applyValidationErrorCollection(form, normalizedError);
|
||||
focusFirstInputFormError(form);
|
||||
focusFirstInputFormError(form.formState.errors, form);
|
||||
|
||||
showWarningToast(
|
||||
t("create.feedback.validation.title"),
|
||||
@ -140,7 +140,7 @@ export const useQuickCreateCustomerDialogController = (
|
||||
(errors: FieldErrors<QuickCustomerCreateForm>) => {
|
||||
console.error(errors);
|
||||
setSubmitError(null);
|
||||
focusFirstInputFormError(form);
|
||||
focusFirstInputFormError(errors, form);
|
||||
|
||||
showWarningToast(
|
||||
t("common.feedback.validation.title"),
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { z } from "zod/v4";
|
||||
import type { z } from "zod/v4";
|
||||
|
||||
import { CustomerCreateFormSchema } from "../../../../web/create/entities";
|
||||
|
||||
|
||||
@ -110,7 +110,7 @@ export const useCreateCustomerController = (options?: UseCustomerCreateControlle
|
||||
|
||||
console.log("Errores de validación aplicados al form:", form.formState.errors);
|
||||
|
||||
focusFirstInputFormError(form);
|
||||
focusFirstInputFormError(form.formState.errors, form);
|
||||
|
||||
if (options?.errorToasts !== false) {
|
||||
showWarningToast(
|
||||
@ -135,7 +135,7 @@ export const useCreateCustomerController = (options?: UseCustomerCreateControlle
|
||||
},
|
||||
(errors: FieldErrors<CustomerCreateForm>) => {
|
||||
console.error(errors);
|
||||
focusFirstInputFormError(form);
|
||||
focusFirstInputFormError(errors, form);
|
||||
|
||||
showWarningToast(
|
||||
t("common.feedback.validation.title"),
|
||||
|
||||
@ -173,7 +173,7 @@ export const useCustomerUpdateController = (
|
||||
|
||||
console.log("Errores de validación aplicados al form:", form.formState.errors);
|
||||
|
||||
focusFirstInputFormError(form);
|
||||
focusFirstInputFormError(form.formState.errors, form);
|
||||
|
||||
if (options?.errorToasts !== false) {
|
||||
showWarningToast(
|
||||
@ -198,7 +198,7 @@ export const useCustomerUpdateController = (
|
||||
},
|
||||
(errors: FieldErrors<CustomerUpdateForm>) => {
|
||||
console.error(errors);
|
||||
focusFirstInputFormError(form);
|
||||
focusFirstInputFormError(errors, form);
|
||||
|
||||
showWarningToast(
|
||||
t("common.feedback.validation.title"),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user