Repository navigation
test(room-invite-preview): freeze the clock the render reads - #1840
Merged
Merged
Conversation
The card's deadline case rendered with Date.now() inside inviteCountdown and then compared against inviteCountdownAt(..., Date.now()) - two independent reads, so a second boundary between them made the expectation one second ahead of the drawn line. It was seen once as "37958984:53 left to join" against ":52" and never reproduced in 60 single-file runs (ThinkFlowLab#1839). Read the clock once, freeze it for the whole case and drive both the render and the expectation from that instant; restore the real clock in finally. No tolerance and no production change: the assertion still compares exact text, so an off-by-one inside the countdown would still fail. Docs-not-needed: test-only; no subsystem behaviour or owned path changes. Fixes ThinkFlowLab#1839
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1839
Owner: Dev2
Written-by: Dev-2
Reviewer: Reviewer
Claim-Id: a497345b7dd544c0b87a56a96d6217cc
Base: f245520
Tip SHA: 3b8d239
Tree: 25d3f899aec104f2a0f95a83568bde15a1ea6a20
Diff: 2 files, +38/−18
What changed
core/test/room-invite-preview.test.jsdrew the card — the render itself callsDate.now()inside
inviteCountdown— and then compared the deadline line againstinviteCountdownAt(preview.expiresAt, 0, Date.now()). Two independent clock reads: when asecond boundary falls between them the expectation is one second ahead of the drawn line, so
the case flakes. Seen once on
f245520cin a full verify as37958984:53 left to joinagainst:52; 60 single-file runs never reproduced it.The case now reads the clock once and freezes it for the whole assertion — one instant drives
both the render and the expectation:
No tolerance: the comparison is still exact text at one instant, so a genuine off-by-one inside
inviteCountdownstill fails. No production change —core/src/client/room-invite-preview.jsis untouched and no clock parameter is added.
patches/ds-bot/files/test/room-invite-preview.test.jsis the whole-file mirror, byte-identical(
sha1 c172eb851f7b45b07b843fd90b61b04cf5569b35both sides). No.patchregeneration and notopics.jsonchange: this file is a whole-file mirror, not an edited upstream file.Red first
Probe 1 — the current assertion is clock-sensitive. Clock advanced 1000 ms per read, current
case unchanged, restored in
finally:Probe 2 — the fixed assertion is immune and not vacuous:
# tests 5 / # pass 5 / # fail 0.frozen - 1000) must fail, and does:200 consecutive runs of the file at this tip:
runs=200 failures=0 elapsed=36s.Verification at the tip
Ran:at3b8d23941035fd80dc757f8982519480c40d0a30(tree25d3f899),git status --porcelainempty before and after:
test/room-invite-preview.test.js5/5.github/scripts549/549, interop 37/37, live-e2e 24/24build-client.mjs --check: cleanarch-docs: OK (2 changed file(s)),ARCH_DOCS_BASE=f245520cbbcb7de1931a91c07c675e20dbe9fc79One honest note on the run: the first full verify at this tip went red on an unrelated file —
core/test/room-external.test.js:79, "timed out waiting for the child" after 4.1 s — not onanything this change touches; that file alone passed 3/3 afterwards and the rerun above is
green. Recorded rather than hidden.
Not run:the smoke bench (noindex.js/src/host/change), the CIpackagejob (pack check,typecheck, actionlint) and the merge-queue rebuild.
Checkpoint
{ "pr": 1840, "claim": "Dev2", "issue": 1839, "summary": "The room-invite preview case drew the card, whose render reads Date.now() inside inviteCountdown, then compared the line against a second Date.now() read, so a second boundary put the expectation one second ahead. The case now reads the clock once, freezes it for the whole assertion and restores it in finally; the comparison stays exact text with no tolerance and no production file changes. An advancing-clock probe fails on the old assertion and passes on the new one, a one-second mutation still fails, 200 runs stayed clean. The whole-file mirror under patches/ds-bot/files is byte-identical.", "files": [ "core/test/room-invite-preview.test.js", "patches/ds-bot/files/test/room-invite-preview.test.js" ], "checks": { "ran": "TZ=UTC ARCH_DOCS_BASE=f245520c npm run verify; node scripts/ds-bot-patches.mjs check; 200x node --test test/room-invite-preview.test.js", "result": "green", "at": "3b8d23941035fd80dc757f8982519480c40d0a30" }, "next": "none — ready for review" }