Files
AutistMask/tests/popupBoot.test.js
T
clawbot 85fa864db4
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run
test: no timer a popup test started fires after cleanupPopup() (closes #578)
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
2026-10-19 04:06:24 +02:00

43 lines
1.3 KiB
JavaScript

// A timer the popup started and that fires after cleanupPopup() has removed
// the page throws "document is not defined", and the throw fails whatever test
// the jest worker is running by then, in this file or another
// (https://git.eeqj.de/sneak/AutistMask/issues/578). The flash message's
// timer is the one that did it. A throw from a timer during a test fails that
// test, so each test here passes only if nothing throws.
const {
bootPopup,
cleanupPopup,
unversionedValidProfile,
} = require("./support/popupBoot");
const FLASH_MS = 10;
function wait(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
afterEach(() => {
cleanupPopup();
});
test("a flash message clears while the page is up", async () => {
const page = await bootPopup(unversionedValidProfile());
const { showFlash } = require("../src/popup/views/helpers");
showFlash("Copied.", FLASH_MS);
expect(page.text("flash-msg")).toBe("Copied.");
await wait(FLASH_MS * 5);
expect(page.text("flash-msg")).toBe("");
});
test("a flash message's timer does not fire after cleanupPopup()", async () => {
await bootPopup(unversionedValidProfile());
const { showFlash } = require("../src/popup/views/helpers");
showFlash("Copied.", FLASH_MS);
cleanupPopup();
await wait(FLASH_MS * 5);
});