From 043c76348470a106a80fbe30e72c70c1f4e05d17 Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Sun, 13 Sep 2026 20:48:26 +0200 Subject: [PATCH] test(news): respect sandboxed preview focus and browser isolation --- docs/testing/news-e2e.md | 2 ++ e2e/news-real/news.spec.ts | 7 +++++-- e2e/news-real/playwright.config.ts | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/testing/news-e2e.md b/docs/testing/news-e2e.md index d9840910..afba8fb8 100644 --- a/docs/testing/news-e2e.md +++ b/docs/testing/news-e2e.md @@ -21,6 +21,8 @@ One Chromium journey exercises the candidate's normal Docker entrypoint and stan No authentication, application HTTP responses, mutations, database calls or cache calls are mocked. The browser blocks resources outside the local fixture origin, such as external avatars. This does not replace any application response. A local HTTPS edge passes requests to Next and sets trusted forwarding headers, allowing the production Secure-cookie behavior to run normally. +The fresh browser contexts retain normal application service-worker registration. The application worker does not cache article or authentication responses. Playwright's worker-blocking injection is avoided because it throws inside the sandboxed preview; browser errors are still checked without filtering. The preview is closed through its Close button, since keyboard events inside its sandbox do not reach the parent dialog. + ## Isolation and cleanup - Each run creates a random Docker network and fresh MariaDB, Redis and candidate containers. All mapped ports are allocated dynamically. The HTTPS listener binds only to `127.0.0.1`. diff --git a/e2e/news-real/news.spec.ts b/e2e/news-real/news.spec.ts index 2563f047..43e25d1e 100644 --- a/e2e/news-real/news.spec.ts +++ b/e2e/news-real/news.spec.ts @@ -51,7 +51,6 @@ test("staff signs in, saves a draft, previews it and publishes to anonymous read baseURL, locale: "en-US", ignoreHTTPSErrors: true, - serviceWorkers: "block", }); const reader = await anonymous.newPage(); const errors: string[] = []; @@ -199,7 +198,11 @@ test("staff signs in, saves a draft, previews it and publishes to anonymous read expect( await rows("SELECT id FROM website_article_revisions"), ).toHaveLength(0); - await page.keyboard.press("Escape"); + // Preview autofocus enters its sandboxed iframe, whose Escape event cannot reach the dialog. + await page + .getByRole("dialog") + .getByRole("button", { name: "Close", exact: true }) + .click(); await expect(page.getByRole("dialog")).toHaveCount(0); }); await test.step("publish once and persist revision, audit and delivery intent", async () => { diff --git a/e2e/news-real/playwright.config.ts b/e2e/news-real/playwright.config.ts index 2ffc24ba..742a4a78 100644 --- a/e2e/news-real/playwright.config.ts +++ b/e2e/news-real/playwright.config.ts @@ -25,7 +25,6 @@ export default defineConfig({ baseURL: process.env.NEWS_E2E_BASE_URL, locale: "en-US", ignoreHTTPSErrors: true, - serviceWorkers: "block", trace: "retain-on-failure", screenshot: "only-on-failure", video: "off",