From 8cb1dab5cedb43a4020b7df56a01a82b3e0a51a3 Mon Sep 17 00:00:00 2001 From: nagelm <10207686+nagelm@users.noreply.github.com> Date: Tue, 14 Jul 2026 22:25:38 +1200 Subject: [PATCH] test(frontend): make date assertions machine-independent Three tests encoded the machine's timezone or locale into their expectations and fail on any box east of UTC (observed on UTC+12/13; CI's UTC and US-locale dev machines never see it): - dateTimeUtils isSame: compared 10:00Z/11:00Z on the 15th as 'same day', but isSame works on local calendar days and no UTC instant falls on the same date in every timezone (at UTC+13 those are 23:00 on the 15th and 00:00 on the 16th). Use timezone-less datetimes, which mean the same calendar day everywhere. - RecordingUtils toDateString: formatted a UTC-noon instant and expected the UTC date, but toDateString renders local time (UTC+12 renders the next day). Construct the Date with local components. - SeriesModalUtils getEpisodeAirdate: the code renders the viewer's locale via toLocaleDateString() by design, but the test hardcoded the en-US shape (it tolerated the timezone day-shift with /1[4|5]/ yet not the day/month order). Compute the expectation with the same API so the test asserts the wiring, not a specific locale. No production code changes. --- frontend/src/utils/__tests__/dateTimeUtils.test.js | 8 ++++---- .../utils/components/__tests__/SeriesModalUtils.test.js | 2 +- frontend/src/utils/forms/__tests__/RecordingUtils.test.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/utils/__tests__/dateTimeUtils.test.js b/frontend/src/utils/__tests__/dateTimeUtils.test.js index 3bc642af..0e841074 100644 --- a/frontend/src/utils/__tests__/dateTimeUtils.test.js +++ b/frontend/src/utils/__tests__/dateTimeUtils.test.js @@ -132,14 +132,14 @@ describe('dateTimeUtils', () => { describe('isSame', () => { it('should return true when dates are same day', () => { - const date1 = '2024-01-15T10:00:00Z'; - const date2 = '2024-01-15T11:00:00Z'; + const date1 = '2024-01-15 10:00:00'; + const date2 = '2024-01-15 11:00:00'; expect(dateTimeUtils.isSame(date1, date2)).toBe(true); }); it('should return false when dates are different days', () => { - const date1 = '2024-01-15T10:00:00Z'; - const date2 = '2024-01-16T10:00:00Z'; + const date1 = '2024-01-15 10:00:00'; + const date2 = '2024-01-16 10:00:00'; expect(dateTimeUtils.isSame(date1, date2)).toBe(false); }); diff --git a/frontend/src/utils/components/__tests__/SeriesModalUtils.test.js b/frontend/src/utils/components/__tests__/SeriesModalUtils.test.js index d986cfcc..5f4f4490 100644 --- a/frontend/src/utils/components/__tests__/SeriesModalUtils.test.js +++ b/frontend/src/utils/components/__tests__/SeriesModalUtils.test.js @@ -353,7 +353,7 @@ describe('SeriesModalUtils', () => { it('should format valid air date', () => { const episode = { air_date: '2024-01-15' }; const formatted = getEpisodeAirdate(episode); - expect(formatted).toMatch(/1\/1[4|5]\/2024/); + expect(formatted).toBe(new Date('2024-01-15').toLocaleDateString()); }); it('should return N/A for missing air date', () => { diff --git a/frontend/src/utils/forms/__tests__/RecordingUtils.test.js b/frontend/src/utils/forms/__tests__/RecordingUtils.test.js index 6e3ae901..db74a1f9 100644 --- a/frontend/src/utils/forms/__tests__/RecordingUtils.test.js +++ b/frontend/src/utils/forms/__tests__/RecordingUtils.test.js @@ -111,7 +111,7 @@ describe('RecordingUtils', () => { describe('toDateString', () => { it('formats a Date to YYYY-MM-DD', () => { - const d = new Date('2024-06-15T12:00:00Z'); + const d = new Date(2024, 5, 15, 12, 0, 0); const result = toDateString(d); expect(result).toBe('2024-06-15'); });