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 ' +