From e3eefb1356c0b3f4b8c994bdca2b961de5da50bc Mon Sep 17 00:00:00 2001 From: Jackson Miller Date: Mon, 9 Nov 2026 03:53:09 -0500 Subject: [PATCH] test(web): the shared-timeline test controls the clock it compares The message's first-seen stamp and the moment the thread can be shared are both Date.now(). The hook treats a message as on screen before sharing only when its stamp is strictly earlier, so two renders in the same millisecond held the message back. The test now sets the clock for each render. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/j5/sharing/sharedTimeline.browser.test.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/web/src/j5/sharing/sharedTimeline.browser.test.tsx b/apps/web/src/j5/sharing/sharedTimeline.browser.test.tsx index 807b90b484dd6..53ea2a920c876 100644 --- a/apps/web/src/j5/sharing/sharedTimeline.browser.test.tsx +++ b/apps/web/src/j5/sharing/sharedTimeline.browser.test.tsx @@ -73,10 +73,14 @@ describe("useSharedConversationEntries", () => { seen.push(useSharedConversationEntries(threadRef, entries)); return {props.tick}; } + // The message is first seen a millisecond before the thread is shared; on the wall clock both + // renders can fall in the same millisecond, which reads as seen once it may be shared. + using now = vi.spyOn(Date, "now").mockReturnValue(10); // The hook reads no route. await using screen = await render(, { router: false }); expect(authors.refresh).not.toHaveBeenCalled(); reach.people = twoWriters; + now.mockReturnValue(11); await screen.rerender(); expect(seen.at(-1)?.map((entry) => entry.id)).toEqual(["entry-1"]); expect(authors.refresh).toHaveBeenCalledTimes(1);