FactuGES_ERP/tests/e2e/customers/customer-list.spec.ts

30 lines
1.2 KiB
TypeScript

import { randomUUID } from "node:crypto";
import { expect, test } from "@playwright/test";
import { loginViaUi } from "../support/login-via-ui";
import { createCustomerViaUi } from "./support/create-customer-via-ui";
import { searchCustomersViaUi } from "./support/search-customers-via-ui";
test("CUSTOMERS-LIST-001: muestra un cliente persistido y permite acceder a su edición", async ({
page,
}, testInfo) => {
await loginViaUi(page);
const token = `e2elist${randomUUID().replaceAll("-", "")}`;
const customer = await createCustomerViaUi(page, testInfo, `E2E LIST ${token}`);
await page.goto("/customers");
// Aísla el cliente propio sin depender de su posición entre datos de otras ejecuciones.
await searchCustomersViaUi(page, token);
const editAction = page.getByTestId(`customer-edit-${customer.id}`);
const row = page.getByRole("row").filter({ has: editAction });
await expect(row).toBeVisible();
await expect(row).toContainText(customer.name);
await expect(row).toContainText(customer.email);
await editAction.click();
await expect(page).toHaveURL((url) => url.pathname === `/customers/${customer.id}/edit`);
await expect(page.locator('input[name="name"]')).toHaveValue(customer.name);
});