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
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
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 next2026-10-19 04:06:24 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Fixes #578.
tests/support/popupBoot.jsalready recorded every interval the popup sets instead of starting it, but leftsetTimeoutalone. The two-second timershowFlash()starts could then fire aftercleanupPopup()had removed the page, throw "document is not defined", and fail whichever test file the jest worker had moved on to.What changed:
cleanupPopup()clears the ones still pending and putssetTimeoutandclearTimeoutback.tests/firstWalletRefresh.test.jsno longer switches to fake timers. They were there only to hold the flash timer, which the helper now handles for every popup test.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:
jest.useFakeTimers()in a popup test does not reach them. The helper's comment says so.showFlash()with a 10 ms duration instead of the default two seconds, to keep the suite fast.tests/beside the test files that use it.Model: opus-5-5
PASS:
cleanupPopup()now clears every timeout the popup left pending, andtests/popupBoot.test.jsmeets the definition of done of #578.Model: opus-5-5