diff --git a/modules/customer-invoices/src/web/proformas/detail/ui/components/proforma-detail-header-meta.tsx b/modules/customer-invoices/src/web/proformas/detail/ui/components/proforma-detail-header-meta.tsx index 1d738c38..9d526ce9 100644 --- a/modules/customer-invoices/src/web/proformas/detail/ui/components/proforma-detail-header-meta.tsx +++ b/modules/customer-invoices/src/web/proformas/detail/ui/components/proforma-detail-header-meta.tsx @@ -12,7 +12,10 @@ export const ProformaDetailHeaderMeta = ({ const items = useMemo(() => [customerName, documentReference], [customerName, documentReference]); return ( -
+
{items.map((item, index) => (
{index > 0 ? | : null} diff --git a/modules/customer-invoices/src/web/proformas/list/ui/blocks/proformas-grid/proforma-row-actions.tsx b/modules/customer-invoices/src/web/proformas/list/ui/blocks/proformas-grid/proforma-row-actions.tsx index 345d3111..ce383570 100644 --- a/modules/customer-invoices/src/web/proformas/list/ui/blocks/proformas-grid/proforma-row-actions.tsx +++ b/modules/customer-invoices/src/web/proformas/list/ui/blocks/proformas-grid/proforma-row-actions.tsx @@ -246,6 +246,7 @@ export function ProformaRowActions({ return (
-

{recipient.name}

+

+ {recipient.name} +

{recipient.status ? ( Cancelar -
diff --git a/modules/customers/src/common/features/customer-selection/ui/dialogs/select-customer-selection-list.tsx b/modules/customers/src/common/features/customer-selection/ui/dialogs/select-customer-selection-list.tsx index b066ee89..495d269a 100644 --- a/modules/customers/src/common/features/customer-selection/ui/dialogs/select-customer-selection-list.tsx +++ b/modules/customers/src/common/features/customer-selection/ui/dialogs/select-customer-selection-list.tsx @@ -50,6 +50,7 @@ export const SelectCustomerSelectionList = ({ "cursor-pointer", customer.id === selectedCustomer?.id && "border-primary bg-accent" )} + data-testid={`customer-selection-${customer.id}`} key={customer.id} onClick={() => onSelect(customer)} role="listitem" diff --git a/tests/e2e/customer-invoices/proformas/create-proforma.spec.ts b/tests/e2e/customer-invoices/proformas/create-proforma.spec.ts new file mode 100644 index 00000000..707f82ca --- /dev/null +++ b/tests/e2e/customer-invoices/proformas/create-proforma.spec.ts @@ -0,0 +1,16 @@ +import { expect, test } from "@playwright/test"; + +import { loginViaUi } from "../../support/login-via-ui"; + +import { createProformaViaUi } from "./support/create-proforma-via-ui"; + +test("CUSTOMER-INVOICES-PROFORMA-CREATE-001: crea un borrador mínimo sin líneas y comprueba persistencia", async ({ + page, +}, testInfo) => { + await loginViaUi(page); + const proforma = await createProformaViaUi(page, testInfo); + await page.reload(); + await expect(page).toHaveURL((url) => url.pathname === `/proformas/${proforma.id}/edit`); + await expect(page.locator('input[name="proformaReference"]')).toHaveValue(proforma.reference); + await expect(page.locator("#proforma-recipient-name")).toHaveText(proforma.customer.name); +}); diff --git a/tests/e2e/customer-invoices/proformas/proforma-list.spec.ts b/tests/e2e/customer-invoices/proformas/proforma-list.spec.ts new file mode 100644 index 00000000..41c113c9 --- /dev/null +++ b/tests/e2e/customer-invoices/proformas/proforma-list.spec.ts @@ -0,0 +1,21 @@ +import { expect, test } from "@playwright/test"; + +import { loginViaUi } from "../../support/login-via-ui"; + +import { createProformaViaUi } from "./support/create-proforma-via-ui"; + +test("CUSTOMER-INVOICES-PROFORMA-LIST-001: muestra la proforma persistida propia del escenario", async ({ + page, +}, testInfo) => { + await loginViaUi(page); + const proforma = await createProformaViaUi(page, testInfo); + await page.goto("/proformas"); + // La referencia asignada por el servidor permite aislar el registro sin depender de su página. + await page.locator('input[inputmode="search"]').fill(proforma.reference); + const row = page + .getByRole("row") + .filter({ has: page.getByTestId(`proforma-row-${proforma.id}`) }); + await expect(row).toBeVisible(); + await expect(row).toContainText(proforma.reference); + await expect(row).toContainText(proforma.customer.name); +}); diff --git a/tests/e2e/customer-invoices/proformas/proforma-view.spec.ts b/tests/e2e/customer-invoices/proformas/proforma-view.spec.ts new file mode 100644 index 00000000..e3a56d62 --- /dev/null +++ b/tests/e2e/customer-invoices/proformas/proforma-view.spec.ts @@ -0,0 +1,19 @@ +import { expect, test } from "@playwright/test"; + +import { loginViaUi } from "../../support/login-via-ui"; + +import { createProformaViaUi } from "./support/create-proforma-via-ui"; + +test("CUSTOMER-INVOICES-PROFORMA-VIEW-001: muestra referencia y cliente persistidos al abrir y recargar detalle", async ({ + page, +}, testInfo) => { + await loginViaUi(page); + const proforma = await createProformaViaUi(page, testInfo); + await page.goto(`/proformas/${proforma.id}`); + const identity = page.locator("#proforma-detail-identity"); + await expect(identity).toContainText(proforma.reference); + await expect(identity).toContainText(proforma.customer.name); + await page.reload(); + await expect(identity).toContainText(proforma.reference); + await expect(identity).toContainText(proforma.customer.name); +}); diff --git a/tests/e2e/customer-invoices/proformas/support/create-proforma-via-ui.ts b/tests/e2e/customer-invoices/proformas/support/create-proforma-via-ui.ts new file mode 100644 index 00000000..757ccc4f --- /dev/null +++ b/tests/e2e/customer-invoices/proformas/support/create-proforma-via-ui.ts @@ -0,0 +1,29 @@ +import { randomUUID } from "node:crypto"; + +import type { Page, TestInfo } from "@playwright/test"; +import { expect } from "@playwright/test"; + +import { createCustomerViaUi } from "../../../customers/support/create-customer-via-ui"; + +export async function createProformaViaUi(page: Page, testInfo: TestInfo) { + const token = `e2eproforma${randomUUID().replaceAll("-", "")}`; + const customer = await createCustomerViaUi(page, testInfo, `E2E Proforma ${token}`); + await page.goto("/proformas/create"); + await page.locator("#proforma-create-customer").click(); + await page.getByRole("dialog").locator('input[inputmode="search"]').fill(token); + await page.getByTestId(`customer-selection-${customer.id}`).click(); + await page.locator("#customer-selection-confirm").click(); + await expect(page.locator("#proforma-create-customer")).toContainText(customer.name); + await page.getByTestId("submit-button").click(); + + await expect(page).toHaveURL(/\/proformas\/[^/]+\/edit\?returnTo=/); + const referenceInput = page.locator('input[name="proformaReference"]'); + await expect(referenceInput).toHaveValue(/\S+/); + await expect(page.locator("#proforma-recipient-name")).toHaveText(customer.name); + const reference = await referenceInput.inputValue(); + const id = new URL(page.url()).pathname.split("/")[2]; + if (!id) { + throw new Error("Missing proforma ID in edit URL"); + } + return { id, reference, customer, token }; +} diff --git a/tests/e2e/customer-invoices/proformas/update-proforma.spec.ts b/tests/e2e/customer-invoices/proformas/update-proforma.spec.ts new file mode 100644 index 00000000..94d14e7a --- /dev/null +++ b/tests/e2e/customer-invoices/proformas/update-proforma.spec.ts @@ -0,0 +1,29 @@ +import { expect, test } from "@playwright/test"; + +import { loginViaUi } from "../../support/login-via-ui"; + +import { createProformaViaUi } from "./support/create-proforma-via-ui"; + +test("CUSTOMER-INVOICES-PROFORMA-UPDATE-001: modifica referencia y descripción del borrador y comprueba persistencia", async ({ + page, +}, testInfo) => { + await loginViaUi(page); + const proforma = await createProformaViaUi(page, testInfo); + const reference = `E2E ${proforma.token}`; + const description = `E2E updated draft ${proforma.token}`; + await page.locator('input[name="reference"]').fill(reference); + await page.locator('textarea[name="description"]').fill(description); + const responsePromise = page.waitForResponse( + (response) => + response.request().method() === "PUT" && + new URL(response.url()).pathname.endsWith(`/proformas/${proforma.id}`) + ); + await page.getByTestId("submit-button").click(); + expect((await responsePromise).status()).toBe(200); + await expect(page).toHaveURL((url) => url.pathname === `/proformas/${proforma.id}/edit`); + await expect(page.locator('input[name="reference"]')).toHaveValue(reference); + await expect(page.locator('textarea[name="description"]')).toHaveValue(description); + await page.reload(); + await expect(page.locator('input[name="reference"]')).toHaveValue(reference); + await expect(page.locator('textarea[name="description"]')).toHaveValue(description); +});