Skip to content

Commit efb2676

Browse files
committed
test(social): build the face-title fixtures from local parts, not UTC
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.
1 parent fc32c5f commit efb2676

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎plugins/social/test/face-rooms.test.js‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ import {
4949
} from '../src/face-rooms.js'
5050
import { formatFaceRoomTitle } from '../src/face-title.js'
5151

52+
// The title prints the wall clock of the box that draws it, so a fixture instant is built from
53+
// local parts: `localIso(2026, 10, 17, 14, 38)` reads as `Oct 17 14:38` in every time zone. A UTC
54+
// instant only read that way on a UTC box, which is what these fixtures got wrong.
55+
const localIso = (year, month, day, hour, minute, second = 0) =>
56+
new Date(year, month - 1, day, hour, minute, second).toISOString()
57+
5258
test('join code is exactly six digits', () => {
5359
assert.equal(isJoinCode('123456'), true)
5460
assert.equal(isJoinCode(' 123456 '), true)
@@ -247,7 +253,7 @@ test('owner-typed face-room lines encode as a human envelope', () => {
247253
assert.equal(humanFaceWho({ who: 'User' }, 'Alice'), 'Alice')
248254
assert.equal(formatFaceRoomTitle({ owners: ['BoxA', 'BoxB'], code: '482913' }), 'Face-to-face · BoxA, BoxB · 482913')
249255
assert.equal(faceRoomTitle({ members: [{ owner_name: 'BoxA' }, { ownerName: 'BoxB' }] }, { code: '482913' }), 'Face-to-face · BoxA, BoxB · 482913')
250-
const at = '2026-10-17T14:38:00.000Z'
256+
const at = localIso(2026, 10, 17, 14, 38)
251257
const titleA = faceRoomTitle({ members: [{ owner_name: 'UiB1415', handle: '@b.home' }, { owner_name: 'UiA1415', handle: '@a.home' }], startedAt: at })
252258
const titleB = faceRoomTitle({ members: [{ ownerName: 'UiA1415', handle: '@a.home' }, { ownerName: 'UiB1415', handle: '@b.home' }], startedAt: at })
253259
assert.equal(titleA, titleB)
@@ -643,12 +649,14 @@ test('#179: a Bot line can never carry the person-line marker', () => {
643649

644650
test('#194: a face room title shows one time, the creation time, before and after Enter chat', () => {
645651
const members = [{ ownerName: 'Alice', handle: '@a.home' }]
646-
const candidate = faceRoomTitle({ members, expiresAt: '2026-10-17T13:06:00.000Z' })
647-
const open = faceRoomTitle({ members, expiresAt: '2026-10-17T13:06:00.000Z', startedAt: '2026-10-17T13:01:30.000Z' })
652+
const deadline = localIso(2026, 10, 17, 13, 6)
653+
const created = localIso(2026, 10, 17, 12, 40)
654+
const candidate = faceRoomTitle({ members, expiresAt: deadline })
655+
const open = faceRoomTitle({ members, expiresAt: deadline, startedAt: localIso(2026, 10, 17, 13, 1, 30) })
648656
assert.equal(candidate, open)
649657
assert.match(candidate, /12:56$/)
650-
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' }))
651-
assert.notEqual(faceRoomTitle({ members, createdAt: '2026-10-17T12:40:00.000Z', expiresAt: '2026-10-17T13:06:00.000Z' }), candidate)
658+
assert.equal(faceRoomTitle({ members, createdAt: created, expiresAt: deadline }), faceRoomTitle({ members, createdAt: created }))
659+
assert.notEqual(faceRoomTitle({ members, createdAt: created, expiresAt: deadline }), candidate)
652660
})
653661

654662
test('a peer line with paragraphs survives being viewed twice (viewFaceRoom then renderFaceEvent, #302)', () => {

0 commit comments

Comments
 (0)