Repository navigation
[backport core/1.59] test: fix WorkflowTab hover-delay flake from wall-time fake timers - #22257
Conversation
…22038) - `WorkflowTab` hover-delay tests flaked under CI load - Cause: global fake timers use `shouldAdvanceTime: true`, so wall time leaks into the 200ms/100ms delays - Fix: those tests pin `shouldAdvanceTime: false` <details><summary>Full context for agent readers</summary> ## Failure `src/components/topbar/WorkflowTab.test.ts > WorkflowTab - workflow status indicator > delays hover preview without moving focus and dismisses after leaving` failed on #21341 (job https://github.com/Comfy-Org/ComfyUI_frontend/actions/runs/40394181583/job/121824507992): - first attempt: `Unable to find an accessible element with the role "dialog"` at the "still open after 99ms" check (the hide timer had already fired) - both retries: `expect(element).not.toBeInTheDocument()` at the "not open after 199ms" check (the show timer had already fired) ## Root cause `vite.config.mts` sets `fakeTimers: { now: TEST_SYSTEM_TIME, shouldAdvanceTime: true }`, and `vitest.timer.setup.ts` calls `vi.useFakeTimers()` before every test. With `shouldAdvanceTime`, the fake clock also moves forward with real elapsed time. The test steps the popover's `useTimeoutFn` delays (200ms show, 100ms hide) one millisecond at a time with `vi.advanceTimersByTimeAsync(199)` + `(1)` and `(99)` + `(1)`. Once a loaded runner spends more than ~1ms of wall time between those steps, a timer fires a step early. Either assertion can then fail, which matches both CI errors. On an idle machine the drift stays under 1ms, so it passed locally. ## Fix The `workflow status indicator` describe's `beforeEach` calls `vi.useFakeTimers({ shouldAdvanceTime: false })`. Vitest merges that with the project `fakeTimers` config, so `now` is kept. Time moves only when the test advances it. This is the same pattern other suites already use (e.g. `src/stores/assetDownloadStore.test.ts`, `src/components/queue/job/JobAssetsList.test.ts`). Only the two hover/click tests in that describe depend on timers. The other tests in it do not care. Alternatives not taken: - loosening the assertions (e.g. `advanceTimersByTimeAsync(150)`): hides the boundary the test exists to check - flipping `shouldAdvanceTime` globally: much wider blast radius, since other suites rely on it ## Evidence Both hover tests temporarily run with `{ repeats: 50 }`, `-t "hover|click-dismissed"`, on a shared 8-core host at load average 26–36. "Under load" adds 10 extra `node -e 'for(;;){}'` busy loops. Each run is 100 executions. | variant | condition | result | | --- | --- | --- | | before | idle-ish | 1 failed (`:153`, `:165`), same lines as CI | | before | under load, 2 runs | 2/2 failed (`:153`, `:165`) | | after | idle-ish | 2 passed (100/100) | | after | under load, 3 runs | 3/3 passed (300/300) | | after | idle, `{ repeats: 200 }` on the hover test | passed (200/200) | The full file passes (24/24). `oxfmt`, `oxlint` and `pnpm typecheck` are clean. </details>
📦 Bundle Size
🎨 Storybook: ✅ Built — View Storybook🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measureExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight
Findings and check detailsThe matrix runs on same-repository version-bump PRs with relevant changes, main-branch pushes, and manual dispatches. This candidate does not qualify, so every expensive stage was skipped. Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
Full docs: scripts/registry-census/README.md 🌾 Fallow: ✅ PassedFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. Findings and check detailsNo new findings in the changed files. Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since 90ba36745f6d53dbb2a332ffa062413fad0ce083
Full docs: ADR-DEVEX-LINT-0015 🏛️ Architecture: ✅ PassedFindings and check detailsWarnings (219)
Reproduce locallypnpm architecture:checkFull docs: Frontend domain catalog |
dante01yoon
left a comment
There was a problem hiding this comment.
Clean backport: the diff matches the merged original exactly. Approving.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## core/1.59 #22257 +/- ##
==========================================
Coverage 87.45% 87.45%
==========================================
Files 2958 2958
Lines 156128 156128
Branches 42215 42215
==========================================
Hits 136544 136544
Misses 18908 18908
Partials 676 676
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Backport of #22038 to
core/1.59Automatically created by backport workflow.