Skip to content

Commit a9b94a0

Browse files
committed
chore(e2e): pin anthropic for api e2e, servers, and ci
1 parent 0687c1c commit a9b94a0

File tree

7 files changed

+15
-2
lines changed

7 files changed

+15
-2
lines changed

.github/workflows/api-e2e.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ env:
2323
PGLITE: true
2424
DATABASE_URL: postgresql://localhost/test
2525
JWT_SECRET: e2e-jwt-secret-min-32-chars-for-tests
26+
AI_PROVIDER: anthropic
2627
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
2728

2829
jobs:

.github/workflows/web-e2e.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ env:
2727
DATABASE_URL: postgresql://localhost/test
2828
JWT_SECRET: e2e-jwt-secret-min-32-chars-for-tests
2929
NEXT_PUBLIC_API_URL: http://localhost:3001
30+
AI_PROVIDER: anthropic
3031
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
3132

3233
jobs:

apps/api/.env.test.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ DATABASE_URL=postgresql://localhost/test
2828
# AI
2929
# -----------------------------------------------------------------------------
3030
ANTHROPIC_API_KEY=sk-ant-xxx
31+
AI_PROVIDER=anthropic
3132
# OPEN_ROUTER_API_KEY=
3233
# OLLAMA_BASE_URL=http://localhost:11434
3334
# AI_DEFAULT_MODEL=claude-sonnet-4-20250514

apps/api/scripts/run-e2e-local.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/**
33
* E2E local: spawn Fastify API, poll until healthy, run Playwright, cleanup on exit.
44
* No wait-on. Uses ALLOW_TEST, PGLITE, NODE_ENV=test.
5+
* Forces AI_PROVIDER=anthropic and strips Open Router/Ollama/AI_DEFAULT_MODEL (parity with Vitest + web E2E).
56
*/
67
import { spawn, spawnSync } from 'node:child_process'
78
import { existsSync, readFileSync } from 'node:fs'
@@ -74,7 +75,11 @@ async function main() {
7475
PGLITE: 'true',
7576
NODE_ENV: 'test',
7677
JWT_SECRET: jwtSecret,
78+
AI_PROVIDER: 'anthropic',
7779
}
80+
delete env.OPEN_ROUTER_API_KEY
81+
delete env.OLLAMA_BASE_URL
82+
delete env.AI_DEFAULT_MODEL
7883

7984
const fastify = spawn(process.execPath, ['--import', 'tsx', 'server.ts'], {
8085
cwd: fastifyDir,

apps/docu/content/docs/testing/frontend-testing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ test.describe('Magic Link Auth E2E', () => {
5858

5959
- **workers: 1** — Required for PGlite (Fastify test DB) to avoid concurrent writer issues
6060
- **Test order** — Auth project first (magic-link-auth: error tests, login/logout; ends with logout). Chromium: unauth badge tests first, then first authed test triggers fixture and confirms session, then remaining authed tests run consecutively
61-
- **Chat E2E** — Requires `OPEN_ROUTER_API_KEY`; see [E2E Testing](/docs/testing/e2e-testing) for env vars. If UNAUTHORIZED, session/Bearer propagation to Fastify `/ai/chat` needs debugging.
61+
- **Chat E2E** — Requires `ANTHROPIC_API_KEY` (Anthropic Sonnet); see [E2E Testing](/docs/testing/e2e-testing) for env vars. If UNAUTHORIZED, session/Bearer propagation to Fastify `/ai/chat` needs debugging.
6262
- **Session model** — One login per worker via `authenticatedStorageState` fixture; cookies/storage saved to `test-results/.auth/user.json` (gitignored); each authed test gets a new context created with that storageState. No per-test login
6363
- **Login/logout tests** — Import from `@playwright/test`, use `page`; need fresh contexts to verify the flow
6464
- **Authed feature tests** — Import from `e2e/fixtures`, use `authenticatedPage`; no `loginAsTestUser` in test body. Each test gets a fresh context with saved storageState; navigate to target route (e.g. `goto('/')`) before asserting

apps/web/e2e/chat-assistant.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test.describe('Chat Assistant', () => {
3232
if (
3333
/insufficient_quota|insufficient_credits|quota_exceeded|credits_exceeded/i.test(errorText)
3434
) {
35-
test.skip(true, 'OpenRouter 402 insufficient credits')
35+
test.skip(true, 'AI provider quota/credits (402)')
3636
return
3737
}
3838
if (/invalid x-api-key|authentication_error|invalid.*api.*key|401/i.test(errorText)) {

apps/web/scripts/start-e2e-servers.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Run in one terminal, then in another: pnpm test:e2e
55
*
66
* Use when Playwright's webServer spawns processes that get OOM killed (exit 137) on constrained VMs.
7+
* Pins AI to Anthropic for API (same as test:e2e:local).
78
*/
89
import { spawn } from 'node:child_process'
910
import { dirname } from 'node:path'
@@ -18,7 +19,11 @@ const env = {
1819
PGLITE: 'true',
1920
NODE_ENV: 'test',
2021
NEXT_PUBLIC_API_URL: 'http://localhost:3001',
22+
AI_PROVIDER: 'anthropic',
2123
}
24+
delete env.OPEN_ROUTER_API_KEY
25+
delete env.OLLAMA_BASE_URL
26+
delete env.AI_DEFAULT_MODEL
2227

2328
const api = spawn('pnpm', ['--filter', '@repo/api', 'start:ci'], {
2429
cwd: repoRoot,

0 commit comments

Comments
 (0)