// ── Without DEMO_MODE, none of the demo is mounted (DEMO_MODE.md §2) ─────── // // The other half of demoApp.test.js, in its own process because app.js reads // the flag at require time. A normal shard must answer exactly as it did before // demo mode existed: its own auth check, no noindex header, its own robots.txt. process.env.DB_HOST = '127.0.0.1' process.env.DB_PORT = '59999' delete process.env.DEMO_MODE process.env.MODULES_DIR = require('path').join(require('os').tmpdir(), 'rg-demo-app-no-modules') const { test, after } = require('node:test') const assert = require('node:assert/strict') const app = require('../src/app') const db = require('../src/utils/db') after(() => db.close()) test('a route the demo locks answers its own 401 on a normal deployment', async () => { const server = await new Promise((resolve) => { const s = app.listen(0, '127.0.0.1', () => resolve(s)) }) try { const base = `http://127.0.0.1:${server.address().port}` const res = await fetch(`${base}/api/v1/admin/site-mode`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ mode: 'maintenance' }), }) assert.equal(res.status, 401) const health = await fetch(`${base}/api/health`) assert.equal(health.headers.get('x-robots-tag'), null) } finally { server.closeAllConnections() await new Promise((resolve) => server.close(resolve)) } })