mirror of
https://github.com/bmad-code-org/BMAD-METHOD.git
synced 2026-09-19 08:11:52 +08:00
2f6e46edbe
* refactor(docs-site): move the doc tooling out of tools/ The five doc scripts and their test exist because of Starlight: sidebar order frontmatter, the rehype link convention, the built site, and the Astro build itself. They now live under docs-site/scripts and docs-site/test, next to the rehype plugins and the site tests, which leaves tools/ Python-only. ESLint stops ignoring those two directories and its script rules now target them; the Astro sources stay excluded. * ci(docs): deploy the site from dev main moves only by release fast-forward, so a docs deploy tied to it would lag every doc change until the next release. Deploy on push to dev instead; main receives the same tree later and needs no deploy.
67 lines
1.8 KiB
JavaScript
67 lines
1.8 KiB
JavaScript
/**
|
|
* Tests for validatePublishedImplementationModel.
|
|
*
|
|
* Usage: node docs-site/test/test-validate-published-implementation-model.mjs
|
|
*/
|
|
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { validatePublishedImplementationModel } from '../scripts/validate-published-implementation-model.mjs';
|
|
|
|
const tests = [];
|
|
|
|
function test(name, run) {
|
|
tests.push({ name, run });
|
|
}
|
|
|
|
function makeSiteDir() {
|
|
return fs.mkdtempSync(path.join(os.tmpdir(), 'bmad-site-'));
|
|
}
|
|
|
|
test('succeeds on a clean site directory with HTML only', () => {
|
|
const siteDir = makeSiteDir();
|
|
try {
|
|
fs.writeFileSync(path.join(siteDir, 'index.html'), '<html><body><p>Build a Change</p></body></html>\n');
|
|
validatePublishedImplementationModel(siteDir);
|
|
} finally {
|
|
fs.rmSync(siteDir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test('throws with file:line when HTML contains an obsolete implementation term', () => {
|
|
const siteDir = makeSiteDir();
|
|
try {
|
|
fs.writeFileSync(path.join(siteDir, 'index.html'), '<html><body><p>Quick Dev is gone</p></body></html>\n');
|
|
assert.throws(
|
|
() => validatePublishedImplementationModel(siteDir),
|
|
(error) => {
|
|
assert.match(error.message, /index\.html:1: Quick Dev/);
|
|
return true;
|
|
},
|
|
);
|
|
} finally {
|
|
fs.rmSync(siteDir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
let failures = 0;
|
|
|
|
for (const { name, run } of tests) {
|
|
try {
|
|
run();
|
|
console.log(` \u001B[32m✓\u001B[0m ${name}`);
|
|
} catch (error) {
|
|
failures++;
|
|
console.error(` \u001B[31m✗\u001B[0m ${name}: ${error.message}`);
|
|
}
|
|
}
|
|
|
|
if (failures > 0) {
|
|
console.error(`\n${failures} implementation model test${failures === 1 ? '' : 's'} failed.`);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`\nAll ${tests.length} implementation model tests passed.`);
|