fix(e2e): add /api/setup route to workflowui and fail fast on seed error

The E2E global setup calls POST /api/setup on localhost:3000, but port
3000 is the workflowui dev server which had no such route — it only
existed in the nextjs workspace. This caused a 404, leaving the DB
empty and making all data-dependent tests (workflowui-auth,
workflowui-templates) time out waiting for content that was never seeded.

- Add /api/setup/route.ts to workflowui that seeds InstalledPackage and
  PageConfig records via the DBAL REST API
- Make global setup throw on seed failure instead of logging and
  continuing, so the suite fails fast rather than running 250 tests
  against an empty database

https://claude.ai/code/session_01ChKf8wbKQLBcNbBCtqCwT6
This commit is contained in:
Claude
2026-03-11 20:55:17 +00:00
parent 84f8122ef3
commit 8b0924ed65
2 changed files with 108 additions and 4 deletions

View File

@@ -42,12 +42,13 @@ async function globalSetup() {
try {
const response = await fetch(setupUrl, { method: 'POST' })
if (!response.ok) {
console.error('[setup] Failed to seed database:', response.status, response.statusText)
} else {
console.log('[setup] Database seeded successfully')
throw new Error(`Seed endpoint returned ${response.status} ${response.statusText}`)
}
console.log('[setup] Database seeded successfully')
} catch (error) {
console.warn('[setup] Setup endpoint not available (non-fatal):', (error as Error).message)
const message = error instanceof Error ? error.message : String(error)
console.error('[setup] Failed to seed database:', message)
throw new Error(`[setup] Seeding failed — aborting test suite. ${message}`)
}
}