Skip to content

Commit d5335c5

Browse files
committed
test(app): let the self-host banner's rollback render before unregistering
A failed save rolls the cache back after cleanup. Unregistering happy-dom at once removes window under it, and React's read of window.event throws between tests, failing the run with every test passed. Same change as main's #858.
1 parent e9dccc3 commit d5335c5

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎app/tests/self-host-banner.test.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ afterEach(() => {
5050
clients.length = 0;
5151
globalThis.fetch = originalFetch;
5252
});
53-
afterAll(() => GlobalRegistrator.unregister());
53+
// A failed save rolls the cache back after the last test has seen the banner return, and React
54+
// renders that after `cleanup`. Unregistering at once removes `window` under it, and the scheduler's
55+
// read of `window.event` throws between tests, failing the run with every test passed.
56+
afterAll(async () => {
57+
await new Promise((resolve) => setTimeout(resolve, 50));
58+
await GlobalRegistrator.unregister();
59+
});
5460

5561
const banner = { name: "Self-host OpenBot" } as const;
5662

0 commit comments

Comments
 (0)