Resolve recommended-profile Critical and High findings, update vulnerable dependencies, restore invoice queue E2E authentication setup, and clear the remaining frontend Qodana findings.
88 lines
2.8 KiB
JavaScript
88 lines
2.8 KiB
JavaScript
import { expect, test } from "@playwright/test";
|
|
import { mockApi, seedAuthenticatedState } from "./support/network.js";
|
|
|
|
function matchesApiPath(urlString, expectedPath) {
|
|
const url = new URL(urlString);
|
|
return url.pathname === expectedPath || url.pathname === `/api${expectedPath}`;
|
|
}
|
|
|
|
test("InvoiceOrdersPagination uses specific date for duplicate groups", async ({ page }) => {
|
|
const mockPeriodData = {
|
|
data: {
|
|
types: {
|
|
all: [],
|
|
possible_duplicates: [
|
|
{
|
|
customer_number: 1001,
|
|
customer_name: "Customer A",
|
|
transactions: [{ id: 1, reg_1: "ABC1234", date: "2026-05-12T10:00:00Z" }],
|
|
},
|
|
{
|
|
customer_number: 1002,
|
|
customer_name: "Customer B",
|
|
transactions: [{ id: 2, reg_1: "ABC1234", date: "2026-05-12T11:00:00Z" }],
|
|
},
|
|
],
|
|
},
|
|
statistics: { total_amount: 0, total_count: 0 },
|
|
},
|
|
meta: {
|
|
pagination: {
|
|
page: 1,
|
|
per_page: 100,
|
|
total: 1,
|
|
},
|
|
},
|
|
};
|
|
|
|
const token = "duplicate-date-e2e-token";
|
|
await seedAuthenticatedState(page, token);
|
|
await mockApi(page, {
|
|
authenticated: true,
|
|
permissions: ["superuser", "user"],
|
|
loginToken: token,
|
|
});
|
|
|
|
await page.route("**/superuser/invoicing/period**", async (route) => {
|
|
await route.fulfill({
|
|
status: 200,
|
|
contentType: "application/json",
|
|
body: JSON.stringify(mockPeriodData),
|
|
});
|
|
});
|
|
|
|
await page.route("**/orders**", async (route) => {
|
|
if (route.request().method() !== "GET" || !matchesApiPath(route.request().url(), "/orders")) {
|
|
await route.fallback();
|
|
return;
|
|
}
|
|
|
|
await route.fulfill({
|
|
status: 200,
|
|
contentType: "application/json",
|
|
body: JSON.stringify({ data: [], meta: { total: 0 } }),
|
|
});
|
|
});
|
|
|
|
await page.goto(
|
|
"/superuser/invoices?activeTab=period&periodView=possible_duplicates&startDate=2026-05-01&endDate=2026-05-31"
|
|
);
|
|
|
|
const duplicateGroup = page.getByTestId("invoicing-period-duplicate-group-ABC1234-2026-05-12");
|
|
await expect(duplicateGroup).toBeVisible();
|
|
const ordersResponse = page.waitForResponse((res) => {
|
|
if (!matchesApiPath(res.url(), "/orders") || res.request().method() !== "GET") {
|
|
return false;
|
|
}
|
|
|
|
const filters = new URL(res.url()).searchParams.get("filters") ?? "";
|
|
return filters.includes("created_at-date_from:2026-05-12") && filters.includes("created_at-date_to:2026-05-12");
|
|
});
|
|
await duplicateGroup.click();
|
|
const capturedOrdersUrl = (await ordersResponse).url();
|
|
|
|
const capturedFilters = new URL(capturedOrdersUrl).searchParams.get("filters") ?? "";
|
|
expect(capturedFilters).toContain("created_at-date_from:2026-05-12");
|
|
expect(capturedFilters).toContain("created_at-date_to:2026-05-12");
|
|
});
|