diff --git a/tests/e2e/invoicing-period.smoke.spec.js b/tests/e2e/invoicing-period.smoke.spec.js index eacc3760..09b07ac5 100644 --- a/tests/e2e/invoicing-period.smoke.spec.js +++ b/tests/e2e/invoicing-period.smoke.spec.js @@ -16,6 +16,11 @@ function matchesApiPath(urlString, expectedPath) { return url.pathname === expectedPath || url.pathname === `/api${expectedPath}`; } +function periodFixtureDate(dateFrom, fallback = "2026-07-14") { + const value = String(dateFrom || fallback).slice(0, 10); + return /^\d{4}-\d{2}-\d{2}$/.test(value) ? value : fallback; +} + async function suppressVueDevtoolsOverlay(page) { await page.addInitScript(() => { const STYLE_ID = "__e2e-hide-vue-devtools"; @@ -153,8 +158,9 @@ function createPeriodPayload() { }; } -function createObjectTreePeriodPayload() { +function createObjectTreePeriodPayload({ dateFrom = "2026-07-14" } = {}) { const payload = createPeriodPayload(); + const fixtureDate = periodFixtureDate(dateFrom); const order = { id: 9001, customer_id: 4101, @@ -172,8 +178,8 @@ function createObjectTreePeriodPayload() { external_id: "", closed_at: "", }, - date: "2026-07-14T10:00:00.000Z", - created_at: "2026-07-14 10:00:00", + date: `${fixtureDate}T10:00:00.000Z`, + created_at: `${fixtureDate} 10:00:00`, amount: 360, total_net_amount: 360, reference: "FORVOGN-REF-9001", @@ -215,8 +221,10 @@ function createFlaggedPeriodPayload({ flaggedCustomerRequiresAction = true, includeHiddenFilteredFlag = false, invoiceCollectionId = null, + dateFrom = "2026-07-14", } = {}) { const payload = createPeriodPayload(); + const fixtureDate = periodFixtureDate(dateFrom); payload.types.all[0].requires_action = flaggedCustomerRequiresAction; payload.types.all[0].transactions = payload.types.all[0].transactions.map((transaction) => ({ ...transaction, @@ -237,7 +245,7 @@ function createFlaggedPeriodPayload({ invoice_collection: invoiceCollectionId ? { id: invoiceCollectionId, - closed_at: "2026-07-14 10:30:00", + closed_at: `${fixtureDate} 10:30:00`, booked_invoice_id: 28368, } : null, @@ -248,8 +256,8 @@ function createFlaggedPeriodPayload({ pending_handheld: false, user_id: 11, booked: flaggedTransactionBooked, - date: "2026-07-14T10:00:00.000Z", - created_at: "2026-07-14 10:00:00", + date: `${fixtureDate}T10:00:00.000Z`, + created_at: `${fixtureDate} 10:00:00`, })); const flags = [ { @@ -539,7 +547,8 @@ function createQueuedPeriodPayload() { }; } -function createDraftBlockedPeriodPayload() { +function createDraftBlockedPeriodPayload({ dateFrom = "2026-07-14" } = {}) { + const fixtureDate = periodFixtureDate(dateFrom); return { types: { all: [ @@ -551,7 +560,7 @@ function createDraftBlockedPeriodPayload() { transactions: [ { id: 9301, - date: "2026-07-14T10:00:00.000Z", + date: `${fixtureDate}T10:00:00.000Z`, amount: 210, booked: false, excluded: false, @@ -584,7 +593,8 @@ function createDraftBlockedPeriodPayload() { }; } -function createStaleDraftPeriodPayload() { +function createStaleDraftPeriodPayload({ dateFrom = "2026-04-14" } = {}) { + const fixtureDate = periodFixtureDate(dateFrom, "2026-04-14"); return { types: { all: [ @@ -596,7 +606,7 @@ function createStaleDraftPeriodPayload() { transactions: [ { id: 9302, - date: "2026-04-14T10:00:00.000Z", + date: `${fixtureDate}T10:00:00.000Z`, amount: 210, booked: false, excluded: false, @@ -1458,8 +1468,9 @@ test.describe("Invoicing period tab", () => { const resolvedAutomaticFingerprints = new Set(); await openPeriodView(page, { - payloadFactory: () => + payloadFactory: ({ dateFrom }) => createFlaggedPeriodPayload({ + dateFrom, resolvedManualFlagIds: Array.from(resolvedManualFlagIds), resolvedAutomaticFingerprints: Array.from(resolvedAutomaticFingerprints), flaggedTransactionBooked: true, @@ -1604,8 +1615,9 @@ test.describe("Invoicing period tab", () => { test("@smoke period expanded booked collection shows hidden flag reasons", async ({ page }) => { await openPeriodView(page, { - payloadFactory: () => + payloadFactory: ({ dateFrom }) => createFlaggedPeriodPayload({ + dateFrom, resolvedManualFlagIds: [501], resolvedAutomaticFingerprints: ["order-reference-fingerprint-1", "price-fingerprint-1"], flaggedTransactionBooked: true,