import assert from 'node:assert/strict'; import { createServer } from 'node:http'; import { after, before, describe, it } from 'node:test'; /** * `WEB_PUBLIC_STATUS=false` (M19). * * The switch decides what an anonymous visitor may learn about the * infrastructure, so it gets a file of its own: the flag is read when the * configuration module loads, and a suite cannot hold both answers at once. */ process.env.WEB_PUBLIC_STATUS = 'false'; const { closeDatabase, initDatabase } = await import('../src/database/index.js'); const { createHandler } = await import('../src/web/server.js'); describe('status page turned off', () => { let app; before(async () => { initDatabase(':memory:'); app = createServer(createHandler({ client: null, setupOnly: false })); await new Promise((resolve) => app.listen(0, '127.0.0.1', resolve)); }); after(async () => { await new Promise((resolve) => app.close(resolve)); closeDatabase(); }); const call = (path) => fetch(`http://127.0.0.1:${app.address().port}${path}`); it('does not serve the page', async () => { const response = await call('/status'); assert.equal(response.status, 404); assert.doesNotMatch(await response.text(), /État des services/); }); it('does not answer in JSON either', async () => { assert.equal((await call('/api/status')).status, 404); }); it('leaves the health probe alone', async () => { assert.equal((await call('/api/health')).status, 200); }); });