test: no timer a popup test started fires after cleanupPopup() (closes #578) #582

Merged
clawbot merged 1 commits from issue-578-popup-timers into next 2026-10-19 04:06:24 +02:00
Collaborator

Fixes #578.

tests/support/popupBoot.js already recorded every interval the popup sets instead of starting it, but left setTimeout alone. The two-second timer showFlash() starts could then fire after cleanupPopup() had removed the page, throw "document is not defined", and fail whichever test file the jest worker had moved on to.

What changed:

  • During a popup test, timeouts still run on the real clock, so the page behaves as it does in the browser, but the helper records each one until it fires or is cleared. cleanupPopup() clears the ones still pending and puts setTimeout and clearTimeout back.
  • tests/firstWalletRefresh.test.js no longer switches to fake timers. They were there only to hold the flash timer, which the helper now handles for every popup test.
  • New tests/popupBoot.test.js: one test shows a flash message, cleans up, waits past the flash duration and fails if the timer fires; the other checks that a flash message still clears while the page is up, so the fix cannot pass by stopping timeouts altogether.

No product code changed.

Worth knowing:

  • Popup timeouts use the real clock taken when the helper loads, so jest.useFakeTimers() in a popup test does not reach them. The helper's comment says so.
  • Judgement call: the new test calls showFlash() with a 10 ms duration instead of the default two seconds, to keep the suite fast.
  • Judgement call: no test of the helper itself existed, so the new file sits in tests/ beside the test files that use it.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/AutistMask/issues/578. `tests/support/popupBoot.js` already recorded every interval the popup sets instead of starting it, but left `setTimeout` alone. The two-second timer `showFlash()` starts could then fire after `cleanupPopup()` had removed the page, throw "document is not defined", and fail whichever test file the jest worker had moved on to. What changed: - During a popup test, timeouts still run on the real clock, so the page behaves as it does in the browser, but the helper records each one until it fires or is cleared. `cleanupPopup()` clears the ones still pending and puts `setTimeout` and `clearTimeout` back. - `tests/firstWalletRefresh.test.js` no longer switches to fake timers. They were there only to hold the flash timer, which the helper now handles for every popup test. - New `tests/popupBoot.test.js`: one test shows a flash message, cleans up, waits past the flash duration and fails if the timer fires; the other checks that a flash message still clears while the page is up, so the fix cannot pass by stopping timeouts altogether. No product code changed. Worth knowing: - Popup timeouts use the real clock taken when the helper loads, so `jest.useFakeTimers()` in a popup test does not reach them. The helper's comment says so. - Judgement call: the new test calls `showFlash()` with a 10 ms duration instead of the default two seconds, to keep the suite fast. - Judgement call: no test of the helper itself existed, so the new file sits in `tests/` beside the test files that use it. Model: opus-5-5
clawbot added the needs-review label 2026-10-19 03:52:37 +02:00
clawbot self-assigned this 2026-10-19 03:52:37 +02:00
clawbot added 1 commit 2026-10-19 03:52:38 +02:00
test: no timer a popup test started fires after cleanupPopup() (closes #578)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
6524db53cc
tests/support/popupBoot.js recorded every interval the popup sets but left
timeouts alone, so the two-second timer that clears a flash message could fire
after cleanupPopup() had removed the page, throw "document is not defined",
and fail whichever test file the jest worker had moved on to. Timeouts still
run for real during a popup test; the helper now records each one until it
fires or is cleared, and cleanupPopup() clears the ones still pending. The
fake timers tests/firstWalletRefresh.test.js used to hold that timer are
removed. tests/popupBoot.test.js shows a flash message, cleans up, waits past
the flash duration, and fails if anything throws.

Model: opus-5-5
Author
Collaborator

PASS: cleanupPopup() now clears every timeout the popup left pending, and tests/popupBoot.test.js meets the definition of done of #578.

Model: opus-5-5

PASS: `cleanupPopup()` now clears every timeout the popup left pending, and `tests/popupBoot.test.js` meets the definition of done of https://git.eeqj.de/sneak/AutistMask/issues/578. Model: opus-5-5
clawbot merged commit 85fa864db4 into next 2026-10-19 04:06:24 +02:00
clawbot deleted branch issue-578-popup-timers 2026-10-19 04:06:25 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#582