From d7e5be08b503eab211d7abb152edac535603cd8a Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Tue, 2 Jun 2026 15:24:47 +0200 Subject: [PATCH] test(e2e): harden flaky auto-start-focus-on-play via hash nav (#7953) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../focus-mode/auto-start-focus-on-play.spec.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/e2e/tests/focus-mode/auto-start-focus-on-play.spec.ts b/e2e/tests/focus-mode/auto-start-focus-on-play.spec.ts index 049798512f..2debb930e3 100644 --- a/e2e/tests/focus-mode/auto-start-focus-on-play.spec.ts +++ b/e2e/tests/focus-mode/auto-start-focus-on-play.spec.ts @@ -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');