Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions v5/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 9 additions & 4 deletions v5/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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()
Expand Down