Repository navigation
fix(test): stop a fixed-date fixture colliding with a pinned relative age - #14390
bolichen97 wants to merge 1 commit into
Conversation
… age `CrewWebviewContainment.test.tsx`'s retained-document test compared a FIXED fixture instant (2026-09-04) against the LIVE clock, so the fixture's rendered age grows without bound while the republish offset stayed pinned at three days. On the day the fixture reached `23d ago` that string came to CONTAIN `3d ago`, and the test's `expect(text).not.toContain(newWhen)` failed against correct production code. It recurs every ten days (3d, 13d, 23d, 33d …). The guard above the assertions only asserted the two ages were UNEQUAL, which a suffix relation satisfies, so it passed the colliding pair straight through to an assertion that reads one whole sentence with `toContain`. - Republish at hour scale (5h), so the rendered UNIT differs from the fixture's day/month age and neither string can be a substring of the other. Hours do not tick within a test run, which is what the original day-scale offset was for. - Assert the relation the test actually needs: mutual non-containment, not inequality. Restoring the 3-day offset now fails on that guard (`expected '23d ago' not to contain '3d ago'`), beside the offsets a reader edits, instead of in the assertion twenty lines below. No production code changes.
|
Intent: Clear |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify no sibling test pairs the shared fixed fixture with a clock-relative offset the same way; this guard covers only this pair. [DESIGN-REVIEWED] 173d6d8 |
UX Review (Fable 5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] 173d6d8 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
This PR and #14381 each hold the only fix for the other's remaining red, so neither can reach a green
Both reds are inherited from Nothing here needs another rebase: the two PRs are already on the same base and rebasing either one re-lands on the other's red. The cycle breaks in one of three ways, and all three are a maintainer's call:
@bolichen97 option 1 is the smallest and the one I would take, but it widens this PR's stated goal, so I am not doing it unprompted. |
Opus 5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
Closing: superseded on main by #14398 ( Same root cause, same class of fix, so there is nothing left for this PR to carry. For the record, the diagnosis this PR carried: the case compared a fixed fixture date against a republish offset pinned to the live clock, so the fixture's age grew without bound and reached a value whose rendering ( |
Problem / Motivation
Goal:
Frontend Tests (1)stops failing onmainand on every PR under it, on a test that was red about nothing.Frontend Tests (1)is red onmainright now, and has been failing every open PR that rebases onto it. The failing case issrc/test/CrewWebviewContainment.test.tsx > crew webview containment > dates the retained document by the version on screen, not by the record that replaced it:Production code is correct. The test compares a FIXED fixture instant
(
2026-09-04T05:16:00) against the LIVE clock, so the fixture's rendered age growswithout bound, while the republish offset it is checked against stayed pinned at
three days. On the day the fixture reached
23d ago, that string came to CONTAIN3d ago, andexpect(text).not.toContain(newWhen)failed.Why it matters
It is a date bomb, not a one-off: the collision recurs every ten days —
3d,13d,23d,33d— for as long as the fixture stays fixed. Each time, it reds a requiredcheck on
mainand on every PR underneath it, and it reds it with a message thatpoints at the banner's copy rather than at the offsets that actually collided, so the
cost is a fresh investigation every time.
Not a goal
CrewWebview.tsxor any other production code. The component renders theright two ages; only the test's comparison was wrong.
{ now }approachIssueRadarCrewPage.test.tsxuses). The component callsfmtRelativewithoutnow, so pinning it here would need fake timers across an asyncwaitFor/QueryClientflow — much wider than the defect.What changed (motivation → approach → change)
3d ago5h ago, a different UNIT from the fixture's ageThe assertions read one whole rendered sentence with
toContain, so the relation theyneed is non-containment; the guard asserted inequality, which a suffix relation
satisfies, and so handed the colliding pair straight to the assertion below it.
Moving the republish to hour scale makes the rendered unit letter differ (
5hvs23d, and1mo/1yas the fixture ages further), so neither string can ever be asubstring of the other. Hours were chosen over seconds or minutes for the reason the
original offset was day-scale: the test computes its own rendering a moment after the
component's, and a finer scale can roll over between the two.
Asserting mutual non-containment is what turns a recurrence into an immediate, local
failure. Restoring the 3-day offset now fails on the guard —
expected '23d ago' not to contain '3d ago'— next to the two offsets a readerwould edit, instead of twenty lines lower in an assertion about banner copy.
Backwards compatibility
Compatible: test-only change, one file, no production code and no exported behavior.
Tests
The changed test is itself the test. Verified both directions:
CrewWebviewContainment.test.tsx44 passed; together withCrewWebviewContainmentCopy.test.ts, 60 passed.guard with
AssertionError: expected '23d ago' not to contain '3d ago'at theguard's own line, not in the assertion below.
tsc -p tsconfig.app.json,eslinton the changed file, andnpm run i18n:checkare all green.Manual verification
N/A — the defect and the fix are both in an automated test, and the failure was
reproduced and cleared by running it.
Screenshots / video
Why no screenshot: test-only change; no component, layout, copy or rendered
output is touched.
Related Issues
no linked issue: found while driving PR #14369, whose
Frontend Tests (1)inheritedthis red from
main.Pattern harvest
Rule candidate: review-prompt
Pattern: a relative-time string compared with
toContain, guarded only byinequality —
"23d ago"is unequal to"3d ago"and still contains it, so any testthat pairs a fixed fixture date with a clock-relative offset can collide as the
fixture ages. The general rule: when an assertion uses substring containment, the
non-vacuity guard must assert non-containment, not inequality.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)