From 6ec3fb5058d31cd90dab3f274dbdb545ebe34b45 Mon Sep 17 00:00:00 2001 From: Isaac S Date: Mon, 1 Jun 2026 23:52:30 -0400 Subject: [PATCH] Add test:all script and isolate E2E on a dedicated port - New `test:all` script runs lint + typecheck + vitest + playwright in one command. - Playwright now always boots its own mock-backed server on port 3100 (`reuseExistingServer: false`) instead of reusing whatever is on the default port 3000. Previously a local `next dev` running against real Notion on :3000 would be reused by the E2E run, breaking the slug-based assertions; pinning a dedicated port makes E2E deterministic regardless of the local environment. - Update TESTING.md to document both changes. Co-Authored-By: Claude Opus 4.8 (1M context) --- v5/TESTING.md | 19 +++++++++++-------- v5/package.json | 1 + v5/playwright.config.ts | 13 +++++++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/v5/TESTING.md b/v5/TESTING.md index f42b946..b93ebc9 100644 --- a/v5/TESTING.md +++ b/v5/TESTING.md @@ -26,6 +26,7 @@ Shared infra lives in `test/` (MSW server + handlers, fixtures, mocks, the RTL ## How to run ```bash +npm run test:all # everything: lint + typecheck + vitest + playwright (one command) npm test # vitest run — one-shot, runs unit + integration + component npm run test:watch # vitest watch mode npm run test:coverage # vitest run --coverage (v8 reporter: text + html) @@ -146,16 +147,18 @@ directly. Also mock `@ai-sdk/anthropic`. The full verified snippet is in ## E2E notes -- Playwright's `webServer` boots `npm run dev` with all `NOTION_*` vars set to - `""`, so `hasNotionCatalogEnv()` is false and the app serves the built-in mock - catalog (`src/components/mock-catalog.ts`) regardless of your dev shell's - environment. `testDir` is `./e2e`; `baseURL` is `http://localhost:3000`. +- Playwright's `webServer` boots `npx next dev -p 3100` with all `NOTION_*` vars + set to `""`, so `hasNotionCatalogEnv()` is false and the app serves the + built-in mock catalog (`src/components/mock-catalog.ts`) regardless of your + dev shell's environment. `testDir` is `./e2e`; `baseURL` is + `http://localhost:3100`. - `/api/chat` is intercepted **inside each spec** at the network layer via `page.route()` returning a UI-message stream chunk — no real Anthropic call. -- `reuseExistingServer: true` (when not in CI) means an already-running dev - server on port 3000 is reused instead of starting a fresh one; in CI a new - server is always spawned. If you have a stale dev server with the wrong env, - stop it so Playwright boots its own with Notion unset. +- `reuseExistingServer: false` — Playwright **always** boots its own fresh + mock-backed server on the dedicated port 3100. This means E2E never collides + with (or accidentally reuses) a `next dev` you have running on the default + port 3000 against real Notion, so results are deterministic no matter what you + have running locally. Port 3000 is left untouched. ## Coverage diff --git a/v5/package.json b/v5/package.json index 17933e1..a23d659 100644 --- a/v5/package.json +++ b/v5/package.json @@ -13,6 +13,7 @@ "test:coverage": "vitest run --coverage", "test:e2e": "playwright test", "test:e2e:ui": "playwright test --ui", + "test:all": "npm run lint && npm run typecheck && npm run test && npm run test:e2e", "migrate:resources": "node --env-file=.env.local --experimental-strip-types scripts/migrate-tools-to-resources.ts", "drop:deprecated-columns": "node --env-file=.env.local --experimental-strip-types scripts/drop-deprecated-notion-columns.ts", "clear:migration-notes": "node --env-file=.env.local --experimental-strip-types scripts/clear-resource-migration-notes.ts" diff --git a/v5/playwright.config.ts b/v5/playwright.config.ts index b0d8ee4..a2d2d11 100644 --- a/v5/playwright.config.ts +++ b/v5/playwright.config.ts @@ -14,7 +14,10 @@ export default defineConfig({ retries: process.env.CI ? 1 : 0, reporter: process.env.CI ? "github" : "list", use: { - baseURL: "http://localhost:3000", + // Dedicated test port (not 3000) so the suite never collides with — or + // accidentally reuses — a `next dev` you have running locally against real + // Notion. The webServer below always boots its own mock-backed instance. + baseURL: "http://localhost:3100", trace: "on-first-retry", }, projects: [ @@ -24,9 +27,11 @@ export default defineConfig({ }, ], webServer: { - command: "npm run dev", - url: "http://localhost:3000", - reuseExistingServer: !process.env.CI, + command: "npx next dev -p 3100", + url: "http://localhost:3100", + // Always boot a fresh mock-backed server; never reuse whatever is on the + // port. Keeps E2E deterministic regardless of the local dev environment. + reuseExistingServer: false, timeout: 120_000, // Unset Notion env so the app serves the mock catalog. Spreading // process.env first, then overwriting with "" makes hasNotionCatalogEnv()