Skip to content

Commit d9978f1

Browse files
test: boot smoke-test for the API that runs without a real database
Gives loadEnv a throwaway DATABASE_URL and boots the server (app.ready + inject), so a route-registration crash is caught in every environment instead of only surfacing as a 502 in production. Asserts /health responds and the WebDAV verbs route outside CORS.
1 parent bae5790 commit d9978f1

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎apps/api/test/webdav.test.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,23 @@ describe('webdav helpers', () => {
2323
});
2424
});
2525

26-
// Building the app needs env (incl. DATABASE_URL); run these only where it's configured (CI).
27-
const routingDescribe = process.env.DATABASE_URL ? describe : describe.skip;
28-
routingDescribe('webdav routing', () => {
26+
// A boot smoke-test needs no real database (these routes reject before any query), so give
27+
// loadEnv a throwaway DATABASE_URL and always run it — this catches route-registration crashes
28+
// (e.g. a duplicated HEAD route) that would otherwise only surface as a 502 in production.
29+
process.env.DATABASE_URL ||= 'postgresql://x:x@localhost:5432/ocl_boot_check';
30+
31+
describe('webdav routing (boot smoke-test)', () => {
2932
let app: FastifyInstance;
3033
beforeAll(async () => {
3134
app = await buildTestApp();
3235
});
3336
afterAll(async () => {
34-
await app.close();
37+
await app?.close();
38+
});
39+
40+
it('boots: browser routes stay inside CORS and respond', async () => {
41+
const res = await app.inject({ method: 'GET', url: '/health' });
42+
expect(res.statusCode).toBe(200);
3543
});
3644

3745
// No auth header → challenge BEFORE any DB access. Proves the custom methods are routed and

0 commit comments

Comments
 (0)