From f0bebcce206e91306383ef577ce8a1aba6888c03 Mon Sep 17 00:00:00 2001 From: memosr Date: Mon, 17 Aug 2026 05:26:28 +0300 Subject: [PATCH] test(harness): make formatClockTime tests locale independent The date assertions matched the English month abbreviation, so the suite failed on any machine whose system locale is not English (for example tr-TR renders Jul as Tem). formatClockTime deliberately formats in the user's locale, so the source is correct and the test was over-specified. Assert the shape instead: the dated form is the same-day form with a date and a comma prepended. Verified across de-DE, ja-JP, tr-TR and en-GB in three timezones. --- .changeset/dull-walls-tan.md | 2 ++ .../harness/web/src/lib/session-record-view.test.ts | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .changeset/dull-walls-tan.md diff --git a/.changeset/dull-walls-tan.md b/.changeset/dull-walls-tan.md new file mode 100644 index 000000000..a845151cc --- /dev/null +++ b/.changeset/dull-walls-tan.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/harness/web/src/lib/session-record-view.test.ts b/packages/harness/web/src/lib/session-record-view.test.ts index ff548a7a3..41bb111df 100644 --- a/packages/harness/web/src/lib/session-record-view.test.ts +++ b/packages/harness/web/src/lib/session-record-view.test.ts @@ -65,14 +65,17 @@ describe("formatClockTime", () => { const iso = "2026-07-01T10:00:00.000Z"; const formatted = formatClockTime(iso, new Date(iso).getTime()); expect(formatted).toMatch(/^\d{1,2}:\d{2}/); - expect(formatted).not.toMatch(/Jul/); }); it("adds the date for a turn from another day, so a multi-day session has boundaries", () => { - // Same clock time, three days earlier — indistinguishable without a date. - const formatted = formatClockTime("2026-07-01T10:00:00.000Z", Date.parse("2026-07-04T10:00:00.000Z")); - expect(formatted).toMatch(/Jul/); - expect(formatted).toMatch(/\d{1,2}:\d{2}/); + const iso = "2026-07-01T10:00:00.000Z"; + const sameDay = formatClockTime(iso, Date.parse(iso)); + // Same clock time, three days later — indistinguishable without a date. + const otherDay = formatClockTime(iso, Date.parse("2026-07-04T10:00:00.000Z")); + // How the date itself reads is the locale's business; what matters is that + // it's prepended to the exact clock time today's turn would have shown. + expect(otherDay).toContain(`, ${sameDay}`); + expect(otherDay).toMatch(/\d{1,2}:\d{2}/); }); });