返回 DeepSeek-Reasonix
docs-codeblock-contract.test.mjs
根目录 / site / src / scripts / docs-codeblock-contract.test.mjs
1 import assert from "node:assert/strict";
2 import { readFile } from "node:fs/promises";
3 import test from "node:test";
4
5 const configSource = () => readFile(new URL("../../astro.config.mjs", import.meta.url), "utf8");
6 const docsSource = () => readFile(new URL("../pages/docs.astro", import.meta.url), "utf8");
7 const stylesSource = () => readFile(new URL("../styles/global.css", import.meta.url), "utf8");
8
9 test("Astro preserves documentation code sample newlines", async () => {
10 const config = await configSource();
11
12 assert.match(config, /compressHTML:\s*false/);
13 });
14
15 test("copyable documentation code blocks reserve space for their buttons", async () => {
16 const [page, styles] = await Promise.all([docsSource(), stylesSource()]);
17 const codeblocks = [...page.matchAll(/<div class="([^"]*\bcodeblock\b[^"]*)">([\s\S]*?)<\/div>/g)];
18 const copyable = codeblocks.filter(([, , body]) => body.includes("data-copy="));
19
20 assert.ok(copyable.length > 0);
21 for (const [, classes] of copyable) {
22 assert.match(classes, /(?:^|\s)codeblock--copy(?:\s|$)/);
23 }
24 assert.match(styles, /\.codeblock--copy\s*\{\s*padding-top:\s*52px;\s*\}/);
25 });
26
27 test("the macOS quarantine comment and command remain separate source lines", async () => {
28 const page = await docsSource();
29
30 assert.match(
31 page,
32 /# Quit Reasonix first, then run in Terminal\.<\/span>\nsudo xattr -rd com\.apple\.quarantine \/Applications\/Reasonix\.app/,
33 );
34 });
35
36 test("website documents the version-matched built-in docs command", async () => {
37 const page = await docsSource();
38
39 assert.match(page, /id="embedded-docs"/);
40 assert.match(page, /\/docs 1\.19\.5 changelog/);
41 assert.match(page, /AI configured for the current session/);
42 assert.match(page, /normally <code>\/reasonix:docs<\/code>/);
43 assert.match(page, /Reasonix never overwrites the existing command/);
44 assert.match(page, /Release CI rejects a build when its embedded corpus does not match/);
45 });
46
47 test("website exposes the Extension Protocol developer path", async () => {
48 const page = await docsSource();
49
50 assert.match(page, /href="#extensions"/);
51 assert.match(page, /id="extensions"/);
52 assert.match(page, /MCP or Extension Protocol\?/);
53 assert.match(page, /sdk\/go\/examples\/starterextension/);
54 assert.match(page, /plugin_root="\$\(pwd -P\)"/);
55 assert.match(page, /reasonix plugin install "\$plugin_root" --dry-run/);
56 assert.match(page, /reasonix plugin install "\$plugin_root" --link --replace --yes/);
57 assert.match(page, /sdk\/go\/v1\.0\.0/);
58 assert.match(page, /<strong>Full trust:<\/strong>/);
59 assert.match(page, /docs\/EXTENSIONS\.md/);
60 assert.match(page, /docs\/PLUGIN_PACKAGES\.md#manifest-v1-extensions/);
61 assert.match(page, /sdk\/go\/README\.md/);
62 assert.match(page, /docs\/EXTENSION_PROTOCOL\.md/);
63 });
64
64 lines Plain Text