From 1cf7cffa8ec36bed6fb6113dc3aef347f6cee0b3 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Sun, 22 Mar 2026 21:20:09 +0100 Subject: [PATCH] test(e2e): fix failing tests by suppressing onboarding and example tasks Set localStorage flags (onboarding preset, hints, tour, example tasks) via addInitScript before app boots, preventing onboarding overlays and example tasks from interfering with e2e tests. Also switch archive import/subtask specs to use the shared test fixture for proper isolation. --- e2e/fixtures/test.fixture.ts | 9 +++++++++ .../import-export/archive-import-persistence.spec.ts | 3 ++- e2e/tests/import-export/archive-subtasks.spec.ts | 3 ++- e2e/utils/waits.ts | 9 ++++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/e2e/fixtures/test.fixture.ts b/e2e/fixtures/test.fixture.ts index c441f7b4c9..e18c421f69 100644 --- a/e2e/fixtures/test.fixture.ts +++ b/e2e/fixtures/test.fixture.ts @@ -50,6 +50,15 @@ export const test = base.extend({ page: async ({ isolatedContext }, use) => { const page = await isolatedContext.newPage(); + // Skip onboarding, hints, and example tasks before the app boots. + // This runs before any page JavaScript, so Angular sees the flags immediately. + await page.addInitScript(() => { + localStorage.setItem('SUP_ONBOARDING_PRESET_DONE', 'true'); + localStorage.setItem('SUP_ONBOARDING_HINTS_DONE', 'true'); + localStorage.setItem('SUP_IS_SHOW_TOUR', 'true'); + localStorage.setItem('SUP_EXAMPLE_TASKS_CREATED', 'true'); + }); + try { // Always log uncaught page errors — they are almost always test-relevant page.on('pageerror', (error) => { diff --git a/e2e/tests/import-export/archive-import-persistence.spec.ts b/e2e/tests/import-export/archive-import-persistence.spec.ts index b295d36159..9c6c4c9c0a 100644 --- a/e2e/tests/import-export/archive-import-persistence.spec.ts +++ b/e2e/tests/import-export/archive-import-persistence.spec.ts @@ -1,4 +1,5 @@ -import { test, expect, type Page, type Download } from '@playwright/test'; +import { test, expect } from '../../fixtures/test.fixture'; +import { type Page, type Download } from '@playwright/test'; import { ImportPage } from '../../pages/import.page'; import * as fs from 'fs'; diff --git a/e2e/tests/import-export/archive-subtasks.spec.ts b/e2e/tests/import-export/archive-subtasks.spec.ts index 65bb0b4c78..f30c603ef2 100644 --- a/e2e/tests/import-export/archive-subtasks.spec.ts +++ b/e2e/tests/import-export/archive-subtasks.spec.ts @@ -1,4 +1,5 @@ -import { test, expect, type Page, type Download } from '@playwright/test'; +import { test, expect } from '../../fixtures/test.fixture'; +import { type Page, type Download } from '@playwright/test'; import { ImportPage } from '../../pages/import.page'; import * as fs from 'fs'; diff --git a/e2e/utils/waits.ts b/e2e/utils/waits.ts index 226a0b3273..ef85123fd7 100644 --- a/e2e/utils/waits.ts +++ b/e2e/utils/waits.ts @@ -66,9 +66,12 @@ const dismissOnboardingPresets = async (page: Page): Promise => { .then(() => true) .catch(() => false); if (isVisible) { - await page.evaluate(() => - localStorage.setItem('SUP_ONBOARDING_PRESET_DONE', 'true'), - ); + await page.evaluate(() => { + localStorage.setItem('SUP_ONBOARDING_PRESET_DONE', 'true'); + localStorage.setItem('SUP_ONBOARDING_HINTS_DONE', 'true'); + localStorage.setItem('SUP_IS_SHOW_TOUR', 'true'); + localStorage.setItem('SUP_EXAMPLE_TASKS_CREATED', 'true'); + }); await page.reload({ waitUntil: 'domcontentloaded' }); await page.waitForTimeout(500); }