From 0f0fb134e7c310a116f0d806b4076766de2e8291 Mon Sep 17 00:00:00 2001 From: Brian Love Date: Wed, 2 Sep 2026 17:24:25 -0700 Subject: [PATCH] fix(website): production-smoke spec must not use import.meta.url MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The spec added in #963 never loaded. Playwright transpiles specs to CJS (`var _test = require("@playwright/test")`), so `import.meta.url` compiles to a `require` the loaded module cannot resolve: ReferenceError: require is not defined in ES module scope at platform-production-smoke.spec.ts:1 Error: No tests found. Production smoke has therefore been reporting "no tests" rather than running, so the job has verified nothing since it landed. Resolve the repo-root policy file from __dirname, which is what the emitted CJS module actually has. The spec is testIgnore'd outside PRODUCTION_SMOKE mode, so nothing on a PR ever loaded it — the failure only surfaced post-merge on main. Add a Website e2e step that collects it with --list, which loads every spec without touching production, so this cannot recur. Verified: the spec now collects 104 tests, and running it against production gives 98 passed / 5 failed / 1 skipped. The 5 failures are real production findings (legacy Cockpit redirects still answer 200 instead of 308, and the assembled frame-ancestors policy does not validate) and are reported separately — they are not caused by this change. Co-Authored-By: Claude Opus 5 --- .github/workflows/ci.yml | 11 +++++++++++ apps/website/e2e/platform-production-smoke.spec.ts | 10 ++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba59e244e..2e99e039f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -640,6 +640,17 @@ jobs: playwright-${{ runner.os }}- - run: npx playwright install --with-deps chromium - run: npx nx e2e website --skip-nx-cache + # The production-smoke spec is testIgnore'd outside PRODUCTION_SMOKE mode, + # so a module-load error in it is invisible until the post-merge Production + # smoke job runs against main — too late to gate a PR. Collect it here: + # --list loads every spec without hitting production. + - name: Production-smoke spec must load + env: + PRODUCTION_SMOKE: 'true' + BASE_URL: https://threadplane.ai + run: | + npx playwright test apps/website/e2e/platform-production-smoke.spec.ts \ + --config apps/website/playwright.config.ts --list required-pr-checks: name: CI — required diff --git a/apps/website/e2e/platform-production-smoke.spec.ts b/apps/website/e2e/platform-production-smoke.spec.ts index da9799740..9e6f5d67a 100644 --- a/apps/website/e2e/platform-production-smoke.spec.ts +++ b/apps/website/e2e/platform-production-smoke.spec.ts @@ -1,5 +1,6 @@ import { expect, test } from '@playwright/test'; import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; import { validateRuntimeParentOrigins } from '@threadplane/cockpit-runtime-bridge'; import { cockpitManifest, @@ -30,11 +31,12 @@ const EXAMPLES_URL = process.env['EXAMPLES_URL'] ?? 'https://examples.threadplane.ai'; const DEMO_URL = process.env['DEMO_URL'] ?? 'https://demo.threadplane.ai'; const WEBSITE_URL = process.env['WEBSITE_URL'] ?? 'https://threadplane.ai'; +// Playwright transpiles specs to CJS, so `import.meta.url` here compiles to a +// `require` the ESM-loaded output cannot resolve and the whole file fails to +// load. `__dirname` is what the emitted module actually has. Don't "modernise" +// this back to import.meta.url. const runtimeParentOriginSource = JSON.parse( - readFileSync( - new URL('../../../runtime-parent-origins.json', import.meta.url), - 'utf8' - ) + readFileSync(join(__dirname, '../../../runtime-parent-origins.json'), 'utf8') ) as { readonly baseOrigins?: unknown }; const runtimeParentPreviewOrigins = ( process.env['RUNTIME_PARENT_PREVIEW_ORIGINS'] ?? ''