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