From efb26767ce0ca483d0dae9cfbb64905fd7b06f9a Mon Sep 17 00:00:00 2001 From: Day Dreamer <87640074+HugoXK@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:41:12 +0800 Subject: [PATCH] test(social): build the face-title fixtures from local parts, not UTC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #3106 Owner: Dev-1 Written-by: Dev-1 Bot: FlyBot Dev-1 Tier: T1 (test-only, `plugins/social/test/**`; no product code) Docs-not-needed: test-only; only how the fixture instant is built changed, and the title behaviour it pins is untouched. `plugins/social/test/face-rooms.test.js` wrote its fixture instants in UTC (`2026-10-17T14:38:00.000Z`) and then asserted the rendered title as `Oct 17 14:38`. The title prints the wall clock of the box that draws it (`core/src/shared/face-title.js` `formatFaceWhen` reads `getHours()` / `getMinutes()` / `getMonth()` / `getDate()`), so that pair only agrees on a UTC box: `TZ=Asia/Shanghai` renders `Oct 17 22:38` and `TZ=America/New_York` renders `Oct 17 10:38`, and the file is red there. Nothing is wrong with the product — the test pinned a local rendering to a UTC expectation. The fixtures are now built from the same local parts the title prints, so the expectation holds everywhere while still asserting the same thing: the title carries the exact minute (`Oct 17 14:38`) and the owners in handle order. A `localIso(year, month, day, hour, minute)` helper does the conversion, used by the human-envelope fixture and by the `#194` case (`12:56` is still the deadline minus the ten-minute window). No assertion was relaxed, skipped or turned into a regex; the two-different-starts `notEqual` and the `isGenericFaceTitle` branch are unchanged, so the case cannot pass vacuously. Verified: `TZ=UTC`, `TZ=Asia/Shanghai`, `TZ=Europe/Berlin` — 38/38 green, twice each. --- plugins/social/test/face-rooms.test.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/social/test/face-rooms.test.js b/plugins/social/test/face-rooms.test.js index 8bae984a0..21900ce7d 100644 --- a/plugins/social/test/face-rooms.test.js +++ b/plugins/social/test/face-rooms.test.js @@ -49,6 +49,12 @@ import { } from '../src/face-rooms.js' import { formatFaceRoomTitle } from '../src/face-title.js' +// The title prints the wall clock of the box that draws it, so a fixture instant is built from +// local parts: `localIso(2026, 10, 17, 14, 38)` reads as `Oct 17 14:38` in every time zone. A UTC +// instant only read that way on a UTC box, which is what these fixtures got wrong. +const localIso = (year, month, day, hour, minute, second = 0) => + new Date(year, month - 1, day, hour, minute, second).toISOString() + test('join code is exactly six digits', () => { assert.equal(isJoinCode('123456'), true) assert.equal(isJoinCode(' 123456 '), true) @@ -247,7 +253,7 @@ test('owner-typed face-room lines encode as a human envelope', () => { assert.equal(humanFaceWho({ who: 'User' }, 'Alice'), 'Alice') assert.equal(formatFaceRoomTitle({ owners: ['BoxA', 'BoxB'], code: '482913' }), 'Face-to-face · BoxA, BoxB · 482913') assert.equal(faceRoomTitle({ members: [{ owner_name: 'BoxA' }, { ownerName: 'BoxB' }] }, { code: '482913' }), 'Face-to-face · BoxA, BoxB · 482913') - const at = '2026-10-17T14:38:00.000Z' + const at = localIso(2026, 10, 17, 14, 38) const titleA = faceRoomTitle({ members: [{ owner_name: 'UiB1415', handle: '@b.home' }, { owner_name: 'UiA1415', handle: '@a.home' }], startedAt: at }) const titleB = faceRoomTitle({ members: [{ ownerName: 'UiA1415', handle: '@a.home' }, { ownerName: 'UiB1415', handle: '@b.home' }], startedAt: at }) assert.equal(titleA, titleB) @@ -643,12 +649,14 @@ test('#179: a Bot line can never carry the person-line marker', () => { test('#194: a face room title shows one time, the creation time, before and after Enter chat', () => { const members = [{ ownerName: 'Alice', handle: '@a.home' }] - const candidate = faceRoomTitle({ members, expiresAt: '2026-10-17T13:06:00.000Z' }) - const open = faceRoomTitle({ members, expiresAt: '2026-10-17T13:06:00.000Z', startedAt: '2026-10-17T13:01:30.000Z' }) + const deadline = localIso(2026, 10, 17, 13, 6) + const created = localIso(2026, 10, 17, 12, 40) + const candidate = faceRoomTitle({ members, expiresAt: deadline }) + const open = faceRoomTitle({ members, expiresAt: deadline, startedAt: localIso(2026, 10, 17, 13, 1, 30) }) assert.equal(candidate, open) assert.match(candidate, /12:56$/) - assert.equal(faceRoomTitle({ members, createdAt: '2026-10-17T12:40:00.000Z', expiresAt: '2026-10-17T13:06:00.000Z' }), faceRoomTitle({ members, createdAt: '2026-10-17T12:40:00.000Z' })) - assert.notEqual(faceRoomTitle({ members, createdAt: '2026-10-17T12:40:00.000Z', expiresAt: '2026-10-17T13:06:00.000Z' }), candidate) + assert.equal(faceRoomTitle({ members, createdAt: created, expiresAt: deadline }), faceRoomTitle({ members, createdAt: created })) + assert.notEqual(faceRoomTitle({ members, createdAt: created, expiresAt: deadline }), candidate) }) test('a peer line with paragraphs survives being viewed twice (viewFaceRoom then renderFaceEvent, #302)', () => {