This commit is contained in:
David Arranz 2026-08-11 09:48:27 +02:00
parent b07eb454eb
commit 3182771455
7 changed files with 16 additions and 21 deletions

View File

@ -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();

View File

@ -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({

View File

@ -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";

View File

@ -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"),

View File

@ -1,4 +1,4 @@
import { z } from "zod/v4";
import type { z } from "zod/v4";
import { CustomerCreateFormSchema } from "../../../../web/create/entities";

View File

@ -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"),

View File

@ -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"),