34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
import { loginViaUi } from "../support/login-via-ui";
|
|
|
|
import { createCustomerViaUi } from "./support/create-customer-via-ui";
|
|
|
|
test("CUSTOMERS-NAVIGATION-001: cancelar edición conserva el contexto del listado", async ({
|
|
page,
|
|
}, testInfo) => {
|
|
await loginViaUi(page);
|
|
const customer = await createCustomerViaUi(page, testInfo);
|
|
const listPath = "/customers?page=1&pageSize=25&sortField=name&sortDirection=desc";
|
|
|
|
await page.goto(listPath);
|
|
const editAction = page.getByTestId(`customer-edit-${customer.id}`);
|
|
await expect(editAction).toBeVisible();
|
|
await editAction.click();
|
|
|
|
await expect(page).toHaveURL(
|
|
(url) =>
|
|
url.pathname === `/customers/${customer.id}/edit` &&
|
|
url.searchParams.get("returnTo") === listPath
|
|
);
|
|
await expect(page.locator('input[name="name"]')).toHaveValue(customer.name);
|
|
|
|
// Recargar demuestra que returnTo no depende de estado de navegación en memoria.
|
|
await page.reload();
|
|
await expect(page.locator('input[name="name"]')).toHaveValue(customer.name);
|
|
await page.getByTestId("cancel-button").click();
|
|
|
|
await expect(page).toHaveURL((url) => `${url.pathname}${url.search}` === listPath);
|
|
await expect(editAction).toBeVisible();
|
|
});
|