From d03c0cfd235a08b6bf7671ad4a55f9f731a9b58f Mon Sep 17 00:00:00 2001 From: hanafish <1106510024@qq.com> Date: Tue, 29 Sep 2026 15:04:15 +0800 Subject: [PATCH] test(issue-time): use elapsed durations in relative age fixtures --- .../hooks/__tests__/workstationIssueHelpers.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/WorkStation/CodeEditor/Panels/EditorPrimarySidebar/hooks/__tests__/workstationIssueHelpers.test.ts b/src/modules/WorkStation/CodeEditor/Panels/EditorPrimarySidebar/hooks/__tests__/workstationIssueHelpers.test.ts index 91b19d5152..205c6f9096 100644 --- a/src/modules/WorkStation/CodeEditor/Panels/EditorPrimarySidebar/hooks/__tests__/workstationIssueHelpers.test.ts +++ b/src/modules/WorkStation/CodeEditor/Panels/EditorPrimarySidebar/hooks/__tests__/workstationIssueHelpers.test.ts @@ -230,16 +230,16 @@ describe("getLabelColorStyle", () => { // formatTimeAgo // ============================================================ describe("formatTimeAgo", () => { + const dayMs = 24 * 60 * 60 * 1000; + function daysAgo(n: number): string { - const d = new Date(); - d.setDate(d.getDate() - n); - return d.toISOString(); + return new Date(Date.now() - n * dayMs).toISOString(); } function monthsAgo(n: number): string { - const d = new Date(); - d.setDate(d.getDate() - n * 30); - return d.toISOString(); + // formatRelativeTime defines a month as 30 elapsed days. Subtract elapsed + // time here too, so a DST transition cannot turn 11 months into 10. + return new Date(Date.now() - n * 30 * dayMs).toISOString(); } it('returns "Today" for the current date', () => {