Skip to content

test: stop depending on another test file's leaked indexedDB global - #1201

Open
njbrake wants to merge 1 commit into
thunderbird:mainfrom
njbrake:pr2-test-indexeddb-isolation
Open

test: stop depending on another test file's leaked indexedDB global#1201
njbrake wants to merge 1 commit into
thunderbird:mainfrom
njbrake:pr2-test-indexeddb-isolation

Conversation

@njbrake

@njbrake njbrake commented Aug 6, 2026

Copy link
Copy Markdown

Note: this PR description was drafted by Claude via back-and-forth with @njbrake. The reasoning and decisions are his; the prose is Claude's.

Removes a cross-file dependency that makes sidebar-footer.test.tsx fail depending on test order.

Its "sync retry flow" block enables sync, which puts the encryption config on the render path. That reads the bare indexedDB global, which happy-dom does not implement, so the tests only passed when some earlier test file had already stubbed it. With --randomize, an ordering that runs this file first fails with ReferenceError: indexedDB is not defined.

use-app-initialization.test.tsx was the accidental supplier, and its restore was itself wrong: it captured globalThis.indexedDB at module load (undefined, since happy-dom has none) and wrote that back in afterAll, leaving the property defined-but-undefined rather than absent.

Adds stubIndexedDb/restoreIndexedDb, which delete the global when it did not exist before, and has both files opt in explicitly. The absence is load-bearing elsewhere, since the boot pipeline's storage pre-flight is supposed to report STORAGE_UNAVAILABLE without it, so this stays opt-in rather than going into the global preload.

I saw this fail on a randomized run of main. I could not pin a seed that reproduces it on main itself, but it reproduces deterministically once any single extra test file changes the shuffle.

_Note: this PR description was drafted by Claude via back-and-forth with @njbrake. The reasoning and decisions are his; the prose is Claude's._

Removes a cross-file dependency that makes `sidebar-footer.test.tsx` fail depending on test order.

Its "sync retry flow" block enables sync, which puts the encryption config on the render path. That reads the bare `indexedDB` global, which happy-dom does not implement, so the tests only passed when some earlier test *file* had already stubbed it. With `--randomize`, an ordering that runs this file first fails with `ReferenceError: indexedDB is not defined`.

`use-app-initialization.test.tsx` was the accidental supplier, and its restore was itself wrong: it captured `globalThis.indexedDB` at module load (undefined, since happy-dom has none) and wrote that back in `afterAll`, leaving the property defined-but-undefined rather than absent.

Adds `stubIndexedDb`/`restoreIndexedDb`, which delete the global when it did not exist before, and has both files opt in explicitly. The absence is load-bearing elsewhere, since the boot pipeline's storage pre-flight is supposed to report STORAGE_UNAVAILABLE without it, so this stays opt-in rather than going into the global preload.

I saw this fail on a randomized run of `main`. I could not pin a seed that reproduces it on `main` itself, but it reproduces deterministically once any single extra test file changes the shuffle.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant