From f07750b0894cb71dbc01b6d83d1b224ce4eba3cf Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Wed, 11 Nov 2026 16:22:48 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B1=20ci:=20Block=20the=20PWA=20Servic?= =?UTF-8?q?e=20Worker=20Across=20the=20Mock=20E2E=20Profiles=20(#18063)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🧱 ci: Block the PWA Service Worker Across the Mock E2E Profiles Every mock test opens a fresh browser context, so the app's service worker installs and claims the page during each test's first load. A `page.route` installed within a few milliseconds of that claim is never consulted: the request it should hold goes to the server, and a test waiting on the route times out. 113 mock spec files install routes and seven blocked the worker themselves. Set `serviceWorkers: 'block'` in the mock profile's shared `use`, which every profile derived from it inherits. No spec asserts worker behavior; one that does can opt back in with `test.use({ serviceWorkers: 'allow' })`. * 🧪 test: Keep the Sandpack Preview Worker in the Plain Text Artifact Spec `serviceWorkers: 'block'` stops every service worker in the browser context, not only the app's. Sandpack's static template serves an artifact's files from a service worker inside its preview iframe, so with the profile blocking workers the preview stays empty and the spec that reads it fails every attempt. Opt that one spec back in and say in the profile's comment that the setting reaches third-party workers too. --- e2e/playwright.config.mock.ts | 7 +++++++ e2e/specs/mock/scenarios/plain-text-artifact-row.spec.ts | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/e2e/playwright.config.mock.ts b/e2e/playwright.config.mock.ts index 16d0f0af04..52985d3320 100644 --- a/e2e/playwright.config.mock.ts +++ b/e2e/playwright.config.mock.ts @@ -549,6 +549,13 @@ export default defineConfig({ headless: true, storageState: path.resolve(process.cwd(), 'e2e/storageState.json'), screenshot: 'only-on-failure', + /** Each test opens a fresh context, so the PWA service worker installs and claims the page + * during that test's first load. A `page.route` installed within a few milliseconds of the + * claim is never consulted, and the request it was meant to hold reaches the server. This + * blocks every worker in the context, including the one Sandpack's static preview serves + * an artifact's files from, so a spec that needs one opts back in with + * `test.use({ serviceWorkers: 'allow' })`. Derived profiles inherit this through `use`. */ + serviceWorkers: 'block', }, expect: { timeout: 10000, diff --git a/e2e/specs/mock/scenarios/plain-text-artifact-row.spec.ts b/e2e/specs/mock/scenarios/plain-text-artifact-row.spec.ts index 4c4104616c..0d5bfd6a21 100644 --- a/e2e/specs/mock/scenarios/plain-text-artifact-row.spec.ts +++ b/e2e/specs/mock/scenarios/plain-text-artifact-row.spec.ts @@ -16,6 +16,10 @@ const PLAIN_TEXT = 'plain notes body\n' + ':::'; +/** The mock profile blocks every service worker in the context, and Sandpack's static preview + * serves the artifact's files from one inside the preview iframe. */ +test.use({ serviceWorkers: 'allow' }); + test.describe('plain text artifact row', () => { test( 'announces a rendered preview for plain text artifacts ' +