Skip to content

test: pin the repository-page clock fixture to one stored instant (#1300) - #1305

Merged
HugoXK merged 2 commits into
mainfrom
dev1/1300-repo-clock-fixture
Nov 24, 2026
Merged

HugoXK merged 2 commits into
mainfrom
dev1/1300-repo-clock-fixture

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Written-by: Fledge Platform Dev-1

Fixes #1300

The defect

test/repoClockWarning.test.ts compared two whole-page renders, but the fixture built a fresh Store and a new job per renderRepo() call. makeTerminalJob (test/helpers.ts:91-95) took no instant and wrote new Date().toISOString(), and createJob fell back to nowIso() for created_at, so each call stamped its own page. The repository page renders the job's created_at through humanTimeShort (src/views/pages.ts:636), which truncates to whole seconds (src/lib/time.ts:34): a second boundary between the two calls changes the rendered line by one second and the equality assertion fails on unchanged code. The card records the same shape one level up — test (24) job 138383429500 failed at test/repoClockWarning.test.ts:96 and passed on the rerun of the same sha.

The assertion was right about the page. The fixture was the non-deterministic half.

The change

  • test/helpers.ts — makeTerminalJob takes an optional third argument, { finishedAt }, defaulting to new Date().toISOString() so the existing 30 call sites are untouched. The returned snapshot carries the stamp the caller asked for. Its other fields, status included, stay exactly what the created row held, so those call sites see no change beyond finished_at now being set.
  • test/repoClockWarning.test.ts — one store and one job are built once with created_at and finished_at both at 2026-11-23T21:25:43.500Z, and every render reads that one record. A new assertion pins the rendered text to 2026-11-23 21:25:43 UTC, so a fixture that still read the wall clock cannot produce it. Every existing assertion is kept verbatim; none is removed or weakened.
  • test/clockFixtures.test.ts — new, half 1: makeTerminalJob(..., { finishedAt }) stores the instant it is given.

No product code, no src/ file, no change to humanTimeShort or the page.

Red first

Commit e4e8075 is the test-only half. On that tip npx tsx --test test/clockFixtures.test.ts test/repoClockWarning.test.ts gave 4 tests, 3 pass, 1 fail:

  • not ok 1 — a fixture written for a fixed instant keeps that instant: expected '2026-11-23T21:25:43.500Z', actual null — the helper took no instant and returned the created row.

Green at the tip

ac9a4f9a4eb4758492893819643cff08b6f2dc04 (tree a3136c95615e4d61655ccc5e936e712322a3584e), read from the branch API this turn; opened against main 7a451f9242d5ef060cfe0b3693a8b1c45a37555d.

Ran:

  • node scripts/issue-gate.mjs --issue 1300 — issue-gate: ok #1300 593b457a2f88
  • npx tsx --test test/clockFixtures.test.ts test/repoClockWarning.test.ts at the tip — 4 tests, 4 pass, 0 fail
  • the same two files 20 consecutive runs — 20/20 green, so nothing on that path reads the wall clock
  • npm run check at the tip — exit 0: lint baseline matches (11 warning(s) in 8 entries), tsc --noEmit pass, # tests 3436 / # pass 3436 / # fail 0, tsc -p tsconfig.build.json pass
  • node scripts/risk-gate.mjs --base 7a451f9242d5ef060cfe0b3693a8b1c45a37555d — risk-tier: T1; basis: test/clockFixtures.test.ts
  • node scripts/pr-lint.mjs --pr 1305 — pr-lint: ok (#1305, T1, 3 files)

Not run: Docker image, Playwright/visual suite (npm run dev) — test-only diff, no user-visible surface.

Risk

Tier computed from the diff: T1. Test-only, no src/ file, no behaviour change; merges on green ci-ok alone.

  • Rollback: revert the squash; the fixture returns to the wall clock and the equality assertion flakes again.
  • Residual: makeTerminalJob still defaults to the wall clock for the other call sites; only the page fixture pins an instant. That is deliberate — the card's non-goals keep the other fixtures untouched.
  • Base movement: cut from 7a451f9242d5ef060cfe0b3693a8b1c45a37555d and main has not moved since (read this turn), so the branch needs no merge.

Docs decision: Docs-not-needed: test-only fixture determinism; no product behaviour, command or documented contract changes. No changelog fragment: users cannot see a test fixture.

@HugoXK
HugoXK merged commit 8417228 into main Nov 24, 2026
32 checks passed
@HugoXK
HugoXK deleted the dev1/1300-repo-clock-fixture branch November 24, 2026 12:31
`makeTerminalJob` takes no instant and writes `new Date()`, so
`renderRepo` stamped the job at call time and the whole-page equality
compared two independently stamped pages. Build one store and one job with
`createdAt` and the instant the helper should store, render both pages from
that job, and assert the rendered line is the literal, not "now".

Red on this tip: `test/clockFixtures.test.ts` fails because
`makeTerminalJob` ignores the instant, and `tsc` refuses the third
argument until the helper takes it.
The helper wrote `new Date()` and returned the created row, so a caller
could not pin the stamp its page renders. Take `{ finishedAt }`, default it
to the wall clock so the existing call sites do not change, and return the
snapshot with the one stamp the caller asked for. The repository-page fixture
now builds one store and one job and reads both renders from that record.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: make repoClockWarning's whole-page equality independent of the wall clock (flake on PR #1297)

1 participant