diff --git a/desktop/frontend-next/src/ui/useWorkbenchFiles.poll.test.tsx b/desktop/frontend-next/src/ui/useWorkbenchFiles.poll.test.tsx index 11373cc864..25eba35000 100644 --- a/desktop/frontend-next/src/ui/useWorkbenchFiles.poll.test.tsx +++ b/desktop/frontend-next/src/ui/useWorkbenchFiles.poll.test.tsx @@ -16,13 +16,13 @@ const tick = () => act(async () => { await vi.advanceTimersByTimeAsync(3000); }) /** Waits until the panel has stopped committing on its own: what opening a file * leaves behind (an entering tab's 220ms timer, a lazily loaded chunk, a * persisted list) lands at a time that depends on the machine, and none of it - * is what a poll does. Two quiet 50ms windows in a row end the wait; a panel + * is what a poll does. Four quiet 100ms windows in a row end the wait; a panel * that never goes quiet leaves the real assertion to fail. */ async function quiet(commits: ReturnType) { let still = 0; - for (let i = 0; i < 60 && still < 2; i++) { + for (let i = 0; i < 60 && still < 4; i++) { commits.mockClear(); - await act(async () => { await new Promise((resolve) => setTimeout(resolve, 50)); }); + await act(async () => { await new Promise((resolve) => setTimeout(resolve, 100)); }); still = commits.mock.calls.length === 0 ? still + 1 : 0; } } @@ -114,10 +114,11 @@ it("leaves the rendered Workbench untouched when Markdown polls are unchanged", await act(async () => {}); await quiet(commits); commits.mockClear(); + const base = performance.now(); const seen: string[] = []; for (const n of [1, 2]) { await tick(); - seen.push(`after poll ${n}: ${commits.mock.calls.length} commits [${commits.mock.calls.map((c) => c[1]).join(",")}], file reads ${read.mock.calls.length}, listings ${listed.mock.calls.length}`); + seen.push(`after poll ${n} (${(performance.now() - base).toFixed(0)}ms): ${commits.mock.calls.length} commits [${commits.mock.calls.map((c) => `${c[1]}@${(c[5] - base).toFixed(0)}ms`).join(",")}], file reads ${read.mock.calls.length}, listings ${listed.mock.calls.length}`); } expect(read).toHaveBeenCalledTimes(3); expect(commits.mock.calls.length, seen.join("; ")).toBe(0);