diff --git a/test/invoice-dedup.test.ts b/test/invoice-dedup.test.ts index d86f15c..0a61026 100644 --- a/test/invoice-dedup.test.ts +++ b/test/invoice-dedup.test.ts @@ -14,6 +14,8 @@ import type { XftApprovalProvider } from "../src/xft.js"; import { UnifiedApprovalService } from "../src/unified-approval.js"; const secret = "invoice-dedup-test-secret-with-at-least-32-bytes"; +// Retained fixtures must stay inside the production retention window as calendar time advances. +const recentSubmittedAt = new Date(Date.now() - 86_400_000).toISOString(); function config(): AppConfig { return { @@ -51,7 +53,7 @@ test("invoice store persists only HMAC fingerprints and isolates users across re const evidence = extractInvoiceEvidence({ invoiceCode: "044031900111", invoiceNumber: "87654321" }); const first = new InvoiceDedupStore(path, secret); const userOne = first.userHash("private-user-one"); - first.indexDetail(userOne, "xft", "business-1", "pending", "2026-08-01T01:00:00.000Z", evidence); + first.indexDetail(userOne, "xft", "business-1", "pending", recentSubmittedAt, evidence); assert.ok(first.findMatches(userOne, evidence).length >= 1); assert.equal(first.findMatches(first.userHash("private-user-two"), evidence).length, 0); @@ -91,7 +93,7 @@ test("dedup preparation blocks historical duplicates and concurrent confirmation observedRange = range; return { items: [{ source: "official_oa", historyScope: "submitted", processInstanceId: "oa-existing", - status: "COMPLETED", result: "agree", submittedAt: "2026-08-01T01:00:00.000Z", + status: "COMPLETED", result: "agree", submittedAt: recentSubmittedAt, }], diagnostics: {} }; }, async getHistoryDetail() { @@ -161,7 +163,7 @@ test("rejected prior bills warn instead of masquerading as active approvals", as const root = mkdtempSync(join(tmpdir(), "ding-invoice-rejected-")); const store = new InvoiceDedupStore(join(root, "dedup.sqlite"), secret); const evidence = extractInvoiceEvidence({ invoiceCode: "044031900111", invoiceNumber: "87654321" }); - store.indexDetail(store.userHash("user-1"), "xft", "xft-rejected", "rejected", "2026-08-01T00:00:00.000Z", evidence); + store.indexDetail(store.userHash("user-1"), "xft", "xft-rejected", "rejected", recentSubmittedAt, evidence); const ding = { async listMyHistory() { return { items: [], diagnostics: {} }; } } as unknown as ApprovalService; const xft = { async listMyHistory() { return { items: [], totalCount: 0, diagnostics: {} }; } } as unknown as XftApprovalProvider; const service = new InvoiceDeduplicationService(config(), store, ding, xft);