121 lines
4.7 KiB
JavaScript
121 lines
4.7 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { readFile } from 'node:fs/promises';
|
|
import test from 'node:test';
|
|
import { auditContent } from '../scripts/audit-content.mjs';
|
|
import { loadManifest } from '../scripts/lib/migration.mjs';
|
|
|
|
test('the full migration audit accounts for every source and destination', async () => {
|
|
const manifest = await loadManifest('docs/migration-manifest.json');
|
|
const result = await auditContent({
|
|
docsRoot: 'src/content/docs',
|
|
manifest,
|
|
});
|
|
|
|
assert.equal(result.sourceCount, 29);
|
|
assert.equal(result.destinationCount, 28);
|
|
assert.equal(result.pageCount, 28);
|
|
});
|
|
|
|
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',
|
|
'src/content/docs/master-ai/index.md',
|
|
'src/content/docs/master-ai/year-1/index.md',
|
|
'src/content/docs/master-ai/year-1/research-project-1.md',
|
|
'src/content/docs/master-ai/year-1/research-project-2.md',
|
|
'src/content/docs/master-ai/year-2/index.md',
|
|
'src/content/docs/master-dsdm/index.md',
|
|
'src/content/docs/master-dsdm/year-1/index.md',
|
|
'src/content/docs/master-dsdm/year-2/index.md',
|
|
'src/content/docs/useful-information/index.md',
|
|
'src/content/docs/useful-information/dke-locations.md',
|
|
'src/content/docs/useful-information/handy-locations.md',
|
|
'src/content/docs/useful-information/it-services.md',
|
|
'src/content/docs/useful-information/laptop-buying-advice.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);
|
|
});
|
|
}
|
|
|
|
for (const file of [
|
|
'src/content/docs/useful-information/it-services.md',
|
|
'src/content/docs/useful-information/laptop-buying-advice.md',
|
|
]) {
|
|
test(`${file} prominently identifies historical guidance`, async () => {
|
|
const content = await readFile(file, 'utf8');
|
|
assert.match(content, /:::caution\[Historical information\]/);
|
|
assert.match(content, /This information originated in the previous wiki and may be outdated\./);
|
|
});
|
|
}
|
|
|
|
test('Handy Locations retains its awaiting-content notices', async () => {
|
|
const content = await readFile(
|
|
'src/content/docs/useful-information/handy-locations.md',
|
|
'utf8',
|
|
);
|
|
assert.match(content, /:::note\[Awaiting content\]/);
|
|
assert.match(content, /This section is awaiting content\./);
|
|
});
|
|
|
|
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('/', '\\/')}\\)`));
|
|
});
|
|
}
|