- Migrate postinstall script to `postinstall-sync-playwright-root-links.mjs` for streamlined path resolution. - Replace `axios` v1.15.0 with v1.13.5 and downgrade `vite` from v8.0.5 to v7.1.11. - Update testing code for consistent formatting and enhanced readability (e.g., `poll` and `catch` calls). - Remove unused or redundant dependency flags and align `package-lock.json` with new configuration.
135 lines
4.0 KiB
TypeScript
135 lines
4.0 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
import { mockApi, primeMockSession } from "./support/network.js";
|
|
|
|
test("[PAGES][User][/user/orders] handles sparse order fields without invalid collected invoice lookups", async ({
|
|
page,
|
|
}) => {
|
|
const consoleMessages: string[] = [];
|
|
const pageErrors: string[] = [];
|
|
const collectedInvoiceRequests: string[] = [];
|
|
|
|
page.on("console", (message) => {
|
|
if (message.type() === "warning" || message.type() === "error") {
|
|
consoleMessages.push(message.text());
|
|
}
|
|
});
|
|
|
|
page.on("pageerror", (error) => {
|
|
pageErrors.push(String(error));
|
|
});
|
|
|
|
page.on("request", (request) => {
|
|
if (request.url().includes("/collected-invoices")) {
|
|
collectedInvoiceRequests.push(request.url());
|
|
}
|
|
});
|
|
|
|
await mockApi(page, {
|
|
authenticated: true,
|
|
sessionData: {
|
|
display_name: "Demo",
|
|
permissions: ["user"],
|
|
},
|
|
pos: {
|
|
ordersById: {
|
|
54518: {
|
|
id: 54518,
|
|
customer_id: 12345,
|
|
department_id: 12,
|
|
reference: undefined,
|
|
notes: null,
|
|
po: undefined,
|
|
reg_1: "AB12345",
|
|
reg_2: "",
|
|
reg_3: "",
|
|
invoice_collection_id: undefined,
|
|
booking_id: null,
|
|
completed_at: null,
|
|
closed_at: null,
|
|
created_at: "2026-04-13 10:00:00",
|
|
include_in_invoice: null,
|
|
total_net_amount: 649,
|
|
},
|
|
54519: {
|
|
id: 54519,
|
|
customer_id: 12345,
|
|
department_id: 12,
|
|
reference: "",
|
|
notes: undefined,
|
|
po: null,
|
|
reg_1: "CD67890",
|
|
reg_2: "",
|
|
reg_3: "",
|
|
invoice_collection_id: 14,
|
|
booking_id: null,
|
|
completed_at: null,
|
|
closed_at: null,
|
|
created_at: "2026-04-13 09:00:00",
|
|
include_in_invoice: null,
|
|
total_net_amount: 399,
|
|
},
|
|
54520: {
|
|
id: 54520,
|
|
customer_id: 12345,
|
|
department_id: 12,
|
|
reference: "Normal ref",
|
|
notes: "",
|
|
po: "PO-123",
|
|
reg_1: "EF11111",
|
|
reg_2: "",
|
|
reg_3: "",
|
|
invoice_collection_id: 18,
|
|
booking_id: null,
|
|
completed_at: null,
|
|
closed_at: null,
|
|
created_at: "2026-04-13 08:00:00",
|
|
include_in_invoice: null,
|
|
total_net_amount: 249,
|
|
},
|
|
},
|
|
orderItemsByOrderId: {
|
|
54518: [],
|
|
54519: [],
|
|
54520: [],
|
|
},
|
|
economicModuleOrdersByOrderId: {
|
|
54518: { invoice_id: null, invoice_draft_id: null },
|
|
54519: { invoice_id: null, invoice_draft_id: null },
|
|
54520: { invoice_id: null, invoice_draft_id: null },
|
|
},
|
|
stripeModuleOrdersByOrderId: {
|
|
54518: {},
|
|
54519: {},
|
|
54520: {},
|
|
},
|
|
},
|
|
});
|
|
|
|
await primeMockSession(page);
|
|
await page.goto("/user/orders");
|
|
await expect(page).toHaveURL(/\/user\/orders/);
|
|
await expect(page.getByText("Historiske vaske").first()).toBeVisible();
|
|
await expect(page.locator("table.table").first().or(page.getByTestId("pos-order-list-card-54518"))).toBeVisible();
|
|
await expect(
|
|
page
|
|
.locator("table.table tbody tr")
|
|
.filter({ hasText: "AB12345" })
|
|
.first()
|
|
.or(page.getByTestId("pos-order-list-card-54518"))
|
|
).toBeVisible();
|
|
await expect(
|
|
page
|
|
.locator("table.table tbody tr")
|
|
.filter({ hasText: "EF11111" })
|
|
.first()
|
|
.or(page.getByTestId("pos-order-list-card-54520"))
|
|
).toBeVisible();
|
|
|
|
const combinedMessages = [...consoleMessages, ...pageErrors].join("\n");
|
|
|
|
expect(combinedMessages).not.toContain("Cannot read properties of undefined (reading 'length')");
|
|
expect(combinedMessages).not.toContain("Cannot read properties of undefined (reading 'orders')");
|
|
expect(combinedMessages).not.toContain("Unhandled error during execution of component update");
|
|
expect(collectedInvoiceRequests.some((url) => url.includes("/collected-invoices?id=undefined"))).toBe(false);
|
|
});
|