test(e2e): harden flaky auto-start-focus-on-play via hash nav (#7953)

Run #3925 (Build All & Release on master) failed solely on
auto-start-focus-on-play.spec.ts:53 — every other test passed and the
merged commit (local-backup) is unrelated to focus mode, so this is a
flake, not a regression.

The test enabled `autoStartFocusOnPlay` in Settings and then did a hard
`page.goto('/')` reload before pressing play. A full reload re-bootstraps
the app and re-reads the config from IndexedDB, which races the debounced
persistence of the toggle we just flipped: if the write hasn't flushed,
the reloaded app boots with the setting OFF, `syncTrackingStartToSession$`
early-returns, and the focus indicator never spawns — a flake no expect
timeout can fix.

Switch to a same-document hash navigation (`/#/tag/TODAY/tasks`, the
pattern already used by `navigateToMiscSettings`). This preserves the
in-memory NgRx config the toggle updated synchronously, so the test
exercises the auto-start behavior without depending on persistence timing.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Johannes Millan 2026-06-02 15:24:47 +02:00 committed by GitHub
parent c9de10a785
commit d7e5be08b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,8 +60,17 @@ test.describe('autoStartFocusOnPlay', () => {
// Step 1: enable the new setting via Settings UI.
await enableAutoStartOnPlay(page);
// Step 2: navigate back to work view and add a task.
await page.goto('/');
// Step 2: navigate back to the work view and add a task.
// Use a same-document hash navigation rather than `page.goto('/')`. A hard
// reload re-bootstraps the app and re-reads the config from IndexedDB,
// which races the debounced persistence of the toggle we just flipped: if
// the write hasn't flushed yet, the reloaded app boots with
// autoStartFocusOnPlay=false and the session never spawns — a flake no
// timeout can fix. Hash nav keeps the in-memory NgRx config that the toggle
// already updated synchronously, so we test the auto-start behavior without
// depending on persistence timing.
await page.goto('/#/tag/TODAY/tasks');
await page.waitForURL(/tag\/TODAY/);
await workViewPage.waitForTaskList();
await workViewPage.addTask('AutoStartTask');