import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; import test from 'node:test'; const docsRoot = 'src/content/docs/useful-information'; test('Laptop Buying Advice publishes the newer hardware baseline without a dated warning', async () => { const content = await readFile(`${docsRoot}/laptop-buying-advice.md`, 'utf8'); assert.match(content, /16 GB/); assert.match(content, /512 GB/); assert.match(content, /Core i5-class or equivalent/i); assert.match(content, /M-series Mac/i); assert.match(content, /Nvidia[\s\S]*CUDA/i); assert.doesNotMatch(content, /:::caution\[Historical information\]/); }); const recoveredGuides = [ { slug: 'housing-guide', title: 'Housing Guide', source: 'https://wiki.msvincognito.nl/useful-guides/housing-guide', }, { slug: 'linux-tricks', title: 'Linux Tricks', source: 'https://wiki.msvincognito.nl/useful-guides/linux-tricks', }, { slug: 'surviving-dacs', title: 'Surviving DACS', source: 'https://wiki.msvincognito.nl/useful-guides/survivingdacs', }, ]; test('the three recovered guides are publishable native Markdown', async () => { for (const { slug, title } of recoveredGuides) { const content = await readFile(`${docsRoot}/${slug}.md`, 'utf8'); assert.match(content, new RegExp(`^---\\n[\\s\\S]*title: ${title}`)); assert.doesNotMatch(content, /^#\s+/m); assert.doesNotMatch(content, /:::caution\[Historical information\]/); assert.doesNotMatch(content, /\[\[|\{\{|NEWPAGE>|indexmenu>|~~NOCACHE~~/); } }); test('the recovered guide registry records source provenance', async () => { const supplemental = JSON.parse(await readFile('docs/supplemental-content.json', 'utf8')); for (const { slug, source } of recoveredGuides) { assert.deepEqual( supplemental.find(({ destination }) => destination === `${docsRoot}/${slug}.md`), { destination: `${docsRoot}/${slug}.md`, source, category: 'useful-guide-recovery', }, ); } }); test('published guides omit unsafe or legally questionable source recommendations', async () => { const linux = await readFile(`${docsRoot}/linux-tricks.md`, 'utf8'); const survival = await readFile(`${docsRoot}/surviving-dacs.md`, 'utf8'); assert.doesNotMatch(linux, /password=["']?/i); assert.doesNotMatch(survival, /Sci-Hub|Library Genesis|Library\.nu/i); }); test('Useful Information navigation exposes every practical guide', async () => { const landing = await readFile(`${docsRoot}/index.md`, 'utf8'); const sidebar = await readFile('src/config/sidebar.mjs', 'utf8'); assert.doesNotMatch(landing, /:::caution\[Historical information\]/); for (const slug of ['housing-guide', 'laptop-buying-advice', 'linux-tricks', 'surviving-dacs']) { assert.match(landing, new RegExp(`\\]\\(\\./${slug}/\\)`)); assert.match(sidebar, new RegExp(`slug: 'useful-information/${slug}'`)); } }); test('Surviving DACS links to its sibling Housing Guide route', async () => { const content = await readFile(`${docsRoot}/surviving-dacs.md`, 'utf8'); assert.match(content, /\]\(\.\.\/housing-guide\/\)/); assert.doesNotMatch(content, /\]\(\.\/housing-guide\/\)/); });