From aa07a789124eedd83da6e43c1d5c3204d6e21daa Mon Sep 17 00:00:00 2001 From: Mark Rapson Date: Fri, 28 Aug 2026 02:56:48 +0100 Subject: [PATCH] Fix timetable timezone tests --- test/timetable-region-timezone.test.js | 36 ++++++++++++++------------ 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/test/timetable-region-timezone.test.js b/test/timetable-region-timezone.test.js index f38540e..f88a7c1 100644 --- a/test/timetable-region-timezone.test.js +++ b/test/timetable-region-timezone.test.js @@ -6,6 +6,7 @@ const vm = require('node:vm'); function loadScheduleModule(overrides) { const timeDatePlaceholdersScript = fs.readFileSync(require.resolve('../src/web/public/js/shared/time-date-placeholders.js'), 'utf8'); const placeholderScript = fs.readFileSync(require.resolve('../src/web/public/js/shared/placeholder-utils.js'), 'utf8'); + const placeholderInfoScript = fs.readFileSync(require.resolve('../src/web/public/js/shared/placeholder-info.js'), 'utf8'); const scriptPath = require.resolve('../src/web/public/js/regions/type/timetable.js'); const script = fs.readFileSync(scriptPath, 'utf8'); const registry = new Map(); @@ -74,6 +75,7 @@ function loadScheduleModule(overrides) { vm.runInNewContext(timeDatePlaceholdersScript, sandbox, { filename: 'time-date-placeholders.js' }); vm.runInNewContext(placeholderScript, sandbox, { filename: 'placeholder-utils.js' }); + vm.runInNewContext(placeholderInfoScript, sandbox, { filename: 'placeholder-info.js' }); if (customWindow.placeholderUtils) { sandbox.window.placeholderUtils = customWindow.placeholderUtils; } @@ -101,9 +103,9 @@ test('timetable region editor lists timezone transforms in helper text', () => { ] }); - assert.match(html, /Placeholder values support transforms/); - assert.match(html, /\{\{start\.tz\(\)\}\}<\/code>/); - assert.match(html, /\{\{start\.tz_long\(\)\}\}<\/code>/); + assert.match(html, /Timetable placeholder transforms/); + assert.match(html, /
tz\(\)<\/code>/); + assert.match(html, /
tz_long\(\)<\/code>/); assert.doesNotMatch(html, /class="chip">\{\{start\.tz\(\)\}\}<\/span>/); }); @@ -127,17 +129,17 @@ test('timetable region editor shows supported date format tokens', () => { ] }); - assert.match(html, /Supported date format tokens/); - assert.match(html, /Format<\/th>/); - assert.ok(html.indexOf('D1-31The day of the month') < html.indexOf('dddMonThe abbreviated weekday name')); - assert.ok(html.indexOf('dddMonThe abbreviated weekday name') < html.indexOf('M1-12The month, beginning at 1')); - assert.ok(html.indexOf('YY18The two-digit year') < html.indexOf('YYYY2018The four-digit year')); - assert.doesNotMatch(html, /y<\/code><\/td>/); - assert.doesNotMatch(html, /yyyy<\/code><\/td>/); - assert.doesNotMatch(html, /yy<\/code><\/td>/); + assert.match(html, /Date format tokens/); + assert.match(html, /Token<\/th>Meaning<\/th>Example<\/th>/); + assert.match(html, /D<\/code><\/td>Day number<\/td>16<\/code><\/td><\/tr>/); + assert.match(html, /YYYY<\/code><\/td>Four-digit year<\/td>2026<\/code><\/td><\/tr>/); + assert.match(html, /Date format tokens/); + assert.match(html, /Token<\/th>Meaning<\/th>Example<\/th>/); + assert.match(html, /D<\/code><\/td>Day number<\/td>16<\/code><\/td><\/tr>/); + assert.match(html, /YYYY<\/code><\/td>Four-digit year<\/td>2026<\/code><\/td><\/tr>/); assert.doesNotMatch(html, /tz<\/code><\/td>/); - assert.match(html, /start\.tz_long\(\)/); - assert.match(html, /Use these tokens inside \.format\(\.\.\.\)<\/code>/); + assert.match(html, /Use tz\(\)<\/code> for a short timezone name and tz_long\(\)<\/code> for the full timezone name/); + assert.match(html, /Use tz\(\)<\/code> for a short timezone name and tz_long\(\)<\/code> for the full timezone name/); }); test('timetable region preview resolves timezone placeholders from explicit timezone transforms', () => { @@ -161,8 +163,8 @@ test('timetable region preview resolves timezone placeholders from explicit time id: 101, title: 'Launch', short_description: 'Doors open', - start_datetime: '2026-08-20T10:00:00.000Z', - end_datetime: '2026-08-20T11:00:00.000Z' + start_datetime: '2099-08-20T10:00:00.000Z', + end_datetime: '2099-08-20T11:00:00.000Z' } ] } @@ -281,8 +283,8 @@ test('timetable preview does not force the group timezone into placeholder trans id: 101, title: 'Launch', short_description: 'Doors open', - start_datetime: '2026-08-20T10:00:00.000Z', - end_datetime: '2026-08-20T11:00:00.000Z' + start_datetime: '2099-08-20T10:00:00.000Z', + end_datetime: '2099-08-20T11:00:00.000Z' } ] }