Skip to content

Commit 79bd7fb

Browse files
IMMINJUclaude
andcommitted
Add CI integration/E2E jobs, Vercel cron DB reset, and test fixes
- CI: add integration test job with PostgreSQL service container - CI: add E2E test job with DB seed and Playwright - Add /api/cron/reset endpoint for hourly demo DB reset (Vercel Cron) - Extract seed logic to shared seed-data.ts (CLI + API) - E2E: auto-reseed in global-setup to prevent stale password state - E2E: fix status/priority change tests (waitForResponse instead of timeout) - Fix dashboard test quote mismatch ('customer' vs "customer") Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9c3a140 commit 79bd7fb

8 files changed

Lines changed: 421 additions & 315 deletions

File tree

.github/workflows/ci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,75 @@ jobs:
3838
- run: pnpm install --frozen-lockfile
3939
- run: pnpm test
4040

41+
integration:
42+
name: Integration Tests
43+
runs-on: ubuntu-latest
44+
services:
45+
postgres:
46+
image: postgres:16
47+
env:
48+
POSTGRES_USER: postgres
49+
POSTGRES_PASSWORD: postgres
50+
POSTGRES_DB: postgres
51+
ports:
52+
- 5432:5432
53+
options: >-
54+
--health-cmd="pg_isready -U postgres"
55+
--health-interval=10s
56+
--health-timeout=5s
57+
--health-retries=5
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: pnpm/action-setup@v4
61+
with:
62+
version: 9
63+
- uses: actions/setup-node@v4
64+
with:
65+
node-version: 20
66+
cache: pnpm
67+
- run: pnpm install --frozen-lockfile
68+
- run: pnpm test:integration
69+
env:
70+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/solvesk_test
71+
72+
e2e:
73+
name: E2E Tests
74+
runs-on: ubuntu-latest
75+
services:
76+
postgres:
77+
image: postgres:16
78+
env:
79+
POSTGRES_USER: postgres
80+
POSTGRES_PASSWORD: postgres
81+
POSTGRES_DB: solvesk
82+
ports:
83+
- 5432:5432
84+
options: >-
85+
--health-cmd="pg_isready -U postgres"
86+
--health-interval=10s
87+
--health-timeout=5s
88+
--health-retries=5
89+
env:
90+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/solvesk
91+
NEXTAUTH_URL: http://localhost:3000
92+
NEXTAUTH_SECRET: ci-test-secret-for-e2e
93+
NEXT_PUBLIC_APP_URL: http://localhost:3000
94+
SKIP_ENV_VALIDATION: true
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: pnpm/action-setup@v4
98+
with:
99+
version: 9
100+
- uses: actions/setup-node@v4
101+
with:
102+
node-version: 20
103+
cache: pnpm
104+
- run: pnpm install --frozen-lockfile
105+
- run: pnpm db:push
106+
- run: pnpm db:seed
107+
- run: npx playwright install --with-deps chromium
108+
- run: pnpm test:e2e
109+
41110
build:
42111
name: Build
43112
runs-on: ubuntu-latest

src/app/api/cron/reset/route.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { NextResponse } from 'next/server'
2+
import { seedDatabase } from '@/scripts/seed-data'
3+
4+
export const maxDuration = 30
5+
6+
export async function GET(request: Request) {
7+
const authHeader = request.headers.get('authorization')
8+
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
9+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
10+
}
11+
12+
try {
13+
await seedDatabase()
14+
return NextResponse.json({ success: true, resetAt: new Date().toISOString() })
15+
} catch (error) {
16+
console.error('Cron reset failed:', error)
17+
return NextResponse.json({ error: 'Reset failed' }, { status: 500 })
18+
}
19+
}

src/features/dashboard/services/__tests__/dashboard.service.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ describe('DashboardService — customer privacy isolation', () => {
339339
// Must use or() to combine own issues + public issues
340340
expect(source).toContain('or(')
341341
// Must scope to customer role
342-
expect(source).toContain('role === "customer"')
342+
expect(source).toContain("role === 'customer'")
343343
})
344344
})
345345

0 commit comments

Comments
 (0)