From 25ef7f001cec326e58d7b230737b45d21be4cd11 Mon Sep 17 00:00:00 2001 From: Haksung Jang Date: Wed, 8 Jul 2026 20:53:47 +0900 Subject: [PATCH] fix(test): de-flake the KEV inline-due-date test (date time bomb) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VulnerabilityDetailBody.test.tsx asserted the inline kev-badge-due-date renders "2026-07-15", but VulnerabilityDetailBody does not inject a `now` into KevBadge, so the inline text is computed against the REAL clock. dueDateStatus flips to the relative "Due in n days" format inside a 7-day imminent window, so from 2026-07-08 through 2026-07-15 the element renders "Due in 7 days" and the test fails — on main, blocking every PR for that week (it first bit the pytest-9 PR). Use a far-future due date (2099-12-31) so this surface's real-clock computation always lands in the "ok" (absolute-date) branch regardless of run date. The state-aware relative/absolute formatting is already covered deterministically in KevBadge.test.tsx via its injected `now`, so nothing is lost here. --- .../projects/VulnerabilityDetailBody.test.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/frontend/tests/unit/features/projects/VulnerabilityDetailBody.test.tsx b/apps/frontend/tests/unit/features/projects/VulnerabilityDetailBody.test.tsx index 45a4953a..a23aaa0e 100644 --- a/apps/frontend/tests/unit/features/projects/VulnerabilityDetailBody.test.tsx +++ b/apps/frontend/tests/unit/features/projects/VulnerabilityDetailBody.test.tsx @@ -163,12 +163,19 @@ describe("VulnerabilityDetailBody", () => { }); it("renders the KEV badge with the inline due date for a KEV-listed finding", () => { - renderBody({ kev: true, kev_due_date: "2026-07-15" }); + // Far-future due date on purpose: this surface (VulnerabilityDetailBody) + // does NOT inject a `now` into KevBadge, so the inline text is computed + // against the real clock. A near date would flip to the relative + // "Due in n days" format (dueDateStatus imminent window is 7 days) and make + // this assertion date-dependent — the exact time bomb this replaces. The + // state-aware relative/absolute formatting is covered deterministically in + // KevBadge.test.tsx via its injected `now`. + renderBody({ kev: true, kev_due_date: "2099-12-31" }); const badge = screen.getByTestId("kev-badge"); expect(badge.textContent).toContain("KEV"); // Drawer surface renders the CISA remediation due date inline. expect(screen.getByTestId("kev-badge-due-date").textContent).toContain( - "2026-07-15", + "2099-12-31", ); });