import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; import test from 'node:test'; const forbidden = [/\[\[/, /\{\{/, /~~NOCACHE~~/, /NEWPAGE>/, /indexmenu>/]; for (const file of [ 'src/content/docs/bachelor/index.md', 'src/content/docs/bachelor/year-1/index.md', 'src/content/docs/bachelor/year-1/project-1-1.md', 'src/content/docs/bachelor/year-1/project-1-2.md', 'src/content/docs/bachelor/year-2/index.md', 'src/content/docs/bachelor/year-2/honours-programme.md', 'src/content/docs/bachelor/year-2/project-2-1.md', 'src/content/docs/bachelor/year-2/project-2-2.md', 'src/content/docs/bachelor/year-3/index.md', 'src/content/docs/bachelor/year-3/bachelors-thesis.md', 'src/content/docs/bachelor/year-3/honours-programme.md', 'src/content/docs/bachelor/year-3/project-3-1.md', 'src/content/docs/bachelor/year-3/study-abroad.md', ]) { test(`${file} contains clean migrated Markdown`, async () => { const content = await readFile(file, 'utf8'); assert.match(content, /^---\n[\s\S]*title:/); assert.match(content, /This information originated in the previous wiki and may be outdated\./); for (const pattern of forbidden) assert.doesNotMatch(content, pattern); }); } test('Year 2 honours programme retains its awaiting-content notice', async () => { const content = await readFile( 'src/content/docs/bachelor/year-2/honours-programme.md', 'utf8', ); assert.match(content, /:::note\[Awaiting content\]/); assert.match(content, /This page is awaiting content\./); }); test('Year 3 honours programme retains its awaiting-content notice', async () => { const content = await readFile( 'src/content/docs/bachelor/year-3/honours-programme.md', 'utf8', ); assert.match(content, /:::note\[Awaiting content\]/); assert.match(content, /This page is awaiting content\./); }); test('Year 3 study abroad page identifies 2022 advice as historical', async () => { const content = await readFile( 'src/content/docs/bachelor/year-3/study-abroad.md', 'utf8', ); assert.match(content, /2022/); assert.match(content, /must be verified/i); }); for (const { file, correctHref, shallowHref } of [ { file: 'src/content/docs/bachelor/year-2/project-2-1.md', correctHref: '../../year-1/project-1-1/', shallowHref: '../year-1/project-1-1/', }, { file: 'src/content/docs/bachelor/year-2/project-2-2.md', correctHref: '../../year-1/project-1-2/', shallowHref: '../year-1/project-1-2/', }, ]) { test(`${file} links to its Year 1 prerequisite from the nested route`, async () => { const content = await readFile(file, 'utf8'); assert.match(content, new RegExp(`\\]\\(${correctHref.replaceAll('/', '\\/')}\\)`)); assert.doesNotMatch(content, new RegExp(`\\]\\(${shallowHref.replaceAll('/', '\\/')}\\)`)); }); }