fix(wiki): render the public pages on the server

The documentation was assembled in the browser, so a client that runs no
script saw an empty shell — including whoever fetches the terms and privacy
links before approving an application, which is exactly what those pages are
for.

The wiki is now delivered as finished HTML, carries no script at all, and
declares itself indexable, unlike the panel. Search works through a plain
query string, an unknown page answers 404 rather than a blank page, and both
legal pages are linked from the footer of every page.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
nocodeandClaude Opus 5 committed 2026-09-23 23:31:27 +02:00
1 parent 3d0e21d7cb
commit 8869c74b7b
7 files changed
+348 -222

No files matched your search

+44 -6
View File
@@ -207,10 +207,48 @@ describe('wiki over HTTP', () => {
for (const path of ['/terms-of-service', '/privacy-policy']) {
const response = await get(path);
assert.equal(response.status, 200, `${path} ne répond pas`);
assert.match(await response.text(), /wiki\.js/, `${path} ne sert pas le site public`);
assert.match(response.headers.get('content-type'), /text\/html/);
}
});
/**
* The point of the whole exercise: whoever checks these links before
* approving an application does not run scripts.
*/
it('delivers the legal text without any script', async () => {
const terms = await get('/terms-of-service').then((response) => response.text());
const privacy = await get('/privacy-policy').then((response) => response.text());
assert.match(terms, /droit suisse/, 'les conditions ne sont pas dans le HTML');
assert.match(privacy, /LPD/, 'la politique n’est pas dans le HTML');
assert.match(privacy, /PFPDT/);
assert.doesNotMatch(terms, /<script/i, 'la page embarque un script');
assert.doesNotMatch(privacy, /<script/i, 'la page embarque un script');
});
it('lets itself be indexed, unlike the dashboard', async () => {
const terms = await get('/terms-of-service').then((response) => response.text());
assert.match(terms, /name="robots" content="index, follow"/);
});
it('links both legal pages from every page of the wiki', async () => {
const index = await get('/wiki').then((response) => response.text());
assert.match(index, /href="\/terms-of-service"/);
assert.match(index, /href="\/privacy-policy"/);
});
it('searches without scripts, through a plain query string', async () => {
const results = await get('/wiki?q=confidentialit').then((response) => response.text());
assert.match(results, /résultat\(s\)/);
assert.match(results, /privacy-policy/);
});
it('answers 404 on an unknown page rather than a blank shell', async () => {
const response = await get('/wiki/inexistante');
assert.equal(response.status, 404);
assert.match(await response.text(), /introuvable/);
});
it('tells each page where it lives', async () => {
const body = await get('/api/wiki').then((response) => response.json());
const pages = body.categories.flatMap((category) => category.pages);
@@ -222,19 +260,19 @@ describe('wiki over HTTP', () => {
it('keeps an ordinary page under /wiki', async () => {
createPage({ slug: 'guide', title: 'Guide', content: 'x', published: true });
const response = await get('/guide');
// Not a wiki root page: it falls back to the dashboard shell.
assert.doesNotMatch(await response.text(), /wiki\.js/);
// Not a legal page: `/guide` belongs to the dashboard, not to the wiki.
assert.doesNotMatch(await get('/guide').then((r) => r.text()), /wiki-shell/);
assert.match(await get('/wiki/guide').then((r) => r.text()), /wiki-shell/);
});
it('keeps the administration behind the login', async () => {
assert.equal((await get('/api/wiki/admin')).status, 401);
});
it('serves its own page rather than the dashboard shell', async () => {
it('serves the documentation rather than the dashboard shell', async () => {
const body = await get('/wiki/terms-of-service').then((response) => response.text());
assert.match(body, /wiki\.js/);
assert.match(body, /wiki-shell/);
assert.doesNotMatch(body, /id="app"/);
});
});