Context
Running bun test with the OpenCode backend on port 4096 causes 4 failures in api-contract.test.ts. The saved-prompts extended API endpoints (/api/ext/saved-prompts) are served by our dev/production server (dev.ts / serve-ui.ts), not by the OpenCode backend directly. The API contract tests hit http://127.0.0.1:4096 (the backend), so the backend returns HTML (its built-in SPA fallback) instead of JSON.
Failing tests
GET /api/ext/saved-prompts returns prompt arrays — gets text/html instead of application/json
GET /api/ext/saved-prompts supports directory param — JSON parse error (HTML response)
PUT /api/ext/saved-prompts rejects project prompts without directory — gets 200 instead of 400
PUT /api/ext/saved-prompts rejects outside directory — gets 200 instead of 400/403
Root cause
The api-contract.test.ts file tests against OPENCODE_URL (default http://127.0.0.1:4096), but extended endpoints are only available through our proxy server. These tests need to either:
- Skip when targeting the backend directly — detect that extended endpoints aren't available and skip gracefully, OR
- Run against the dev server — add a separate test target for extended API tests against
http://localhost:3000
Files to modify
app-prefixable/tests/api-contract.test.ts:247-348 — Extended API test section
Acceptance criteria
bun test passes with only the OpenCode backend running (no dev server)
- Extended API tests still run and pass when the dev server is available
- No false positives from HTML fallback responses
Context
Running
bun testwith the OpenCode backend on port 4096 causes 4 failures inapi-contract.test.ts. The saved-prompts extended API endpoints (/api/ext/saved-prompts) are served by our dev/production server (dev.ts/serve-ui.ts), not by the OpenCode backend directly. The API contract tests hithttp://127.0.0.1:4096(the backend), so the backend returns HTML (its built-in SPA fallback) instead of JSON.Failing tests
GET /api/ext/saved-prompts returns prompt arrays— getstext/htmlinstead ofapplication/jsonGET /api/ext/saved-prompts supports directory param— JSON parse error (HTML response)PUT /api/ext/saved-prompts rejects project prompts without directory— gets 200 instead of 400PUT /api/ext/saved-prompts rejects outside directory— gets 200 instead of 400/403Root cause
The
api-contract.test.tsfile tests againstOPENCODE_URL(defaulthttp://127.0.0.1:4096), but extended endpoints are only available through our proxy server. These tests need to either:http://localhost:3000Files to modify
app-prefixable/tests/api-contract.test.ts:247-348— Extended API test sectionAcceptance criteria
bun testpasses with only the OpenCode backend running (no dev server)