@v11g/agents-rock 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -0
- package/bin/agents-rock.mjs +4 -0
- package/package.json +13 -0
- package/plugins/solution-architect/.claude-plugin/plugin.json +9 -0
- package/plugins/solution-architect/skills/analyze-requirements/README.md +75 -0
- package/plugins/solution-architect/skills/analyze-requirements/SKILL.md +31 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/OFL.txt +98 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-mono-latin-600-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json +52 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/section-help.json +101 -0
- package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +2389 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/interview.md +53 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/likec4.md +157 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/project-types.md +60 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/research.md +78 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/viewer.md +772 -0
- package/plugins/solution-architect/skills/analyze-requirements/references/writing.md +206 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/cdp.mjs +74 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/chrome.mjs +66 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/companion-links.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-kinds.mjs +37 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-links.mjs +26 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-routes.mjs +27 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/doc-sections.mjs +78 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/embed.mjs +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/er-entities.mjs +16 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/fonts.mjs +39 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/frontmatter.mjs +17 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/inputs.mjs +41 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-config.mjs +41 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-extract.mjs +29 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/likec4-steps.mjs +22 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-defs.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-flows.mjs +46 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-inline.mjs +31 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-links.mjs +7 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-list.mjs +64 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-render.mjs +127 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-shape.mjs +19 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-tables.mjs +30 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-views.mjs +48 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/md-wide.mjs +44 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/nav.mjs +72 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/offline.mjs +19 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/port.mjs +13 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/quality-gate.mjs +113 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/section-help.mjs +49 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/slug-registry.mjs +11 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-clusters.mjs +15 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-deployment.mjs +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-elections.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-links.mjs +23 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-model-tables.mjs +24 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-palette.mjs +34 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-provenance.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/validate-tree.mjs +16 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-config.mjs +19 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-export.mjs +35 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/likec4-gen.mjs +39 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs +130 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/serve.mjs +71 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/browser.test.mjs +553 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/companion-links.test.mjs +60 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-kinds.test.mjs +41 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-links.test.mjs +104 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-routes.test.mjs +54 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/doc-sections.test.mjs +197 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/embed.test.mjs +28 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/er-entities.test.mjs +14 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/ARCHITECTURE.md +47 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/broken/model.c4 +27 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/c4-src/pass/model.c4 +29 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/adr/0001-sample.md +18 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimate.html +2 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/docs/estimation.md +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model-broken.json +1 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/model.json +1 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/docs-pass/threat-model.md +8 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample-model.json +1 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fixtures/sample.c4 +28 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/fonts.test.mjs +38 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/frontmatter.test.mjs +27 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/inputs.test.mjs +72 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config-cli.test.mjs +26 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-config.test.mjs +74 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-export-cli.test.mjs +61 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-extract.test.mjs +37 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-gen-cli.test.mjs +73 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/likec4-steps.test.mjs +32 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-flows.test.mjs +82 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-links.test.mjs +16 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-provenance.test.mjs +42 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-render.test.mjs +226 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-tables.test.mjs +30 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-views.test.mjs +76 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/md-wide.test.mjs +76 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/nav.test.mjs +236 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/offline.test.mjs +37 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gate.test.mjs +86 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gates.test.mjs +20 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/render.test.mjs +171 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/research-workflow.test.mjs +38 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/section-help.test.mjs +101 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/serve.test.mjs +48 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-clusters.test.mjs +46 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-deployment.test.mjs +23 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-elections.test.mjs +30 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-links.test.mjs +38 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-model-tables.test.mjs +51 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-provenance.test.mjs +28 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/validate-tree.test.mjs +43 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs +1206 -0
- package/plugins/solution-architect/skills/analyze-requirements/scripts/validate.mjs +88 -0
- package/plugins/solution-architect/skills/analyze-requirements/workflows/research.js +57 -0
- package/plugins/solution-architect/skills/estimate/README.md +67 -0
- package/plugins/solution-architect/skills/estimate/SKILL.md +64 -0
- package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +1128 -0
- package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +95 -0
- package/plugins/solution-architect/skills/estimate/references/interview.md +80 -0
- package/plugins/solution-architect/skills/estimate/references/slicing.md +55 -0
- package/plugins/solution-architect/skills/estimate/references/techniques.md +111 -0
- package/plugins/solution-architect/skills/estimate/references/writing.md +211 -0
- package/plugins/solution-architect/skills/estimate/scripts/compute.mjs +23 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +128 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/components.mjs +19 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +85 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +10 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +30 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/roadmap.mjs +32 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +122 -0
- package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +128 -0
- package/plugins/solution-architect/skills/estimate/scripts/render.mjs +65 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +623 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +88 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +34 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +112 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +58 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +30 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +60 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/quality-gates.test.mjs +20 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +71 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +121 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +129 -0
- package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +72 -0
- package/plugins/solution-architect/skills/estimate/scripts/validate.mjs +20 -0
- package/plugins/solution-architect/skills/new-lead/README.md +48 -0
- package/plugins/solution-architect/skills/new-lead/SKILL.md +113 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/detail.html +842 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/index.html +655 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/start.sh +3 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/stats.mjs +98 -0
- package/plugins/solution-architect/skills/new-lead/assets/dashboard/vendor/reactflow-bundle.js +473 -0
- package/plugins/solution-architect/skills/new-lead/assets/vendor-build/entry.jsx +33 -0
- package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package-lock.json +1055 -0
- package/plugins/solution-architect/skills/new-lead/assets/vendor-build/package.json +19 -0
- package/plugins/solution-architect/skills/new-lead/scripts/init-root.mjs +73 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lead-upsert.mjs +31 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/enrich.mjs +20 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +124 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/map.mjs +117 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/port.mjs +15 -0
- package/plugins/solution-architect/skills/new-lead/scripts/lib/registry.mjs +116 -0
- package/plugins/solution-architect/skills/new-lead/scripts/serve.mjs +163 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/e2e-workspace.test.mjs +59 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/enrich.test.mjs +16 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/ARCHITECTURE.md +16 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/brief.md +4 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/index.html +11 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/proposal-non-tech.html +2 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/dist/threat-model.html +2 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation-inputs.json +6 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/estimation.json +10 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/notes.md +3 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/proposal-non-tech.md +3 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads/acme-crm/rfp.md +3 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/fixtures/root/leads.json +25 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/init-root.test.mjs +81 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/lead-upsert.test.mjs +67 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/map.test.mjs +72 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/port.test.mjs +31 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/registry-io.test.mjs +57 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/registry.test.mjs +49 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/serve.test.mjs +205 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/stats.test.mjs +92 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/validate-cli.test.mjs +24 -0
- package/plugins/solution-architect/skills/new-lead/scripts/test/vendor-bundle.test.mjs +9 -0
- package/plugins/solution-architect/skills/new-lead/scripts/validate.mjs +9 -0
- package/plugins/solution-architect/skills/proposal/README.md +36 -0
- package/plugins/solution-architect/skills/proposal/SKILL.md +58 -0
- package/plugins/solution-architect/skills/proposal/assets/proposal-template.html +82 -0
- package/plugins/solution-architect/skills/proposal/references/interview.md +63 -0
- package/plugins/solution-architect/skills/proposal/references/review.md +28 -0
- package/plugins/solution-architect/skills/proposal/references/writing.md +102 -0
- package/plugins/solution-architect/skills/proposal/scripts/derive.mjs +22 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/checks-client.mjs +75 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/checks-doc.mjs +54 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/checks.mjs +17 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/figures.mjs +43 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/jargon.mjs +9 -0
- package/plugins/solution-architect/skills/proposal/scripts/lib/sections.mjs +32 -0
- package/plugins/solution-architect/skills/proposal/scripts/render.mjs +60 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +144 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/checks-doc.test.mjs +93 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/docs.test.mjs +51 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/e2e.test.mjs +30 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +81 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-fail.md +22 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-pass.md +55 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/quality-gates.test.mjs +20 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/render.test.mjs +70 -0
- package/plugins/solution-architect/skills/proposal/scripts/test/validate.test.mjs +40 -0
- package/plugins/solution-architect/skills/proposal/scripts/validate.mjs +20 -0
- package/src/cli/agents.mjs +12 -0
- package/src/cli/args.mjs +46 -0
- package/src/cli/install.mjs +68 -0
- package/src/cli/main.mjs +124 -0
- package/src/cli/picker.mjs +78 -0
- package/src/cli/registry.mjs +26 -0
- package/src/cli/uninstall.mjs +38 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import { existsSync, statSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { join, relative, extname, isAbsolute } from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { findFreePort } from './lib/port.mjs';
|
|
6
|
+
|
|
7
|
+
const TYPES = {
|
|
8
|
+
'.html': 'text/html',
|
|
9
|
+
'.js': 'text/javascript',
|
|
10
|
+
'.mjs': 'text/javascript',
|
|
11
|
+
'.css': 'text/css',
|
|
12
|
+
'.json': 'application/json',
|
|
13
|
+
'.svg': 'image/svg+xml',
|
|
14
|
+
'.png': 'image/png',
|
|
15
|
+
'.woff2': 'font/woff2',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function contentType(path) {
|
|
19
|
+
return TYPES[extname(path)] ?? 'application/octet-stream';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function resolvePath(dir, urlPath) {
|
|
23
|
+
const decoded = decodeURIComponent(urlPath.split('?')[0]);
|
|
24
|
+
const rel = decoded === '/' ? 'index.html' : decoded.slice(1);
|
|
25
|
+
const resolved = join(dir, rel);
|
|
26
|
+
const relToDir = relative(dir, resolved);
|
|
27
|
+
if (relToDir.startsWith('..') || isAbsolute(relToDir)) return null;
|
|
28
|
+
return resolved;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function handle(dir, req, res) {
|
|
32
|
+
try {
|
|
33
|
+
respond(dir, req, res);
|
|
34
|
+
} catch {
|
|
35
|
+
if (!res.headersSent) res.writeHead(400);
|
|
36
|
+
res.end();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function respond(dir, req, res) {
|
|
41
|
+
const resolved = resolvePath(dir, req.url);
|
|
42
|
+
if (resolved === null) {
|
|
43
|
+
res.writeHead(403);
|
|
44
|
+
res.end();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!existsSync(resolved) || statSync(resolved).isDirectory()) {
|
|
48
|
+
res.writeHead(404);
|
|
49
|
+
res.end();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
res.writeHead(200, { 'content-type': contentType(resolved) });
|
|
53
|
+
res.end(readFileSync(resolved));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function createServer({ dir, port }) {
|
|
57
|
+
return new Promise((resolve) => {
|
|
58
|
+
const server = http.createServer((req, res) => handle(dir, req, res));
|
|
59
|
+
server.listen(port, '127.0.0.1', () => resolve({ port, close: () => server.close() }));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function main() {
|
|
64
|
+
const dir = process.argv[2] ?? process.cwd();
|
|
65
|
+
const srv = await createServer({ dir, port: await findFreePort(4173) });
|
|
66
|
+
console.log(`serving ${dir} at http://localhost:${srv.port}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
70
|
+
main();
|
|
71
|
+
}
|
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
import { test, before, after, describe } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import { readFileSync, mkdtempSync, writeFileSync } from 'node:fs';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { openPage } from '../lib/cdp.mjs';
|
|
8
|
+
import { findChrome } from '../lib/chrome.mjs';
|
|
9
|
+
|
|
10
|
+
// Five batches of viewer work shipped verified only as template text. Text says a
|
|
11
|
+
// rule is present; it cannot say the rule wins, that the script survived boot, or
|
|
12
|
+
// that an embedded font was ever applied. These are the assertions that need a
|
|
13
|
+
// layout engine, and nothing else in the suite has one.
|
|
14
|
+
const fixtures = new URL('./fixtures/docs-pass/', import.meta.url).pathname;
|
|
15
|
+
const THEME = JSON.parse(readFileSync(
|
|
16
|
+
new URL('../../assets/mermaid-theme.json', import.meta.url), 'utf8'));
|
|
17
|
+
// Same two shapes validate-palette.mjs looks for, but wrapped so the result is
|
|
18
|
+
// valid JavaScript. render.test.mjs' stub is not — it only ever gets read as
|
|
19
|
+
// text, so the browser is the first thing to try running it, and it throws
|
|
20
|
+
// `SyntaxError: Unexpected token ':'` on boot. Worth knowing that the fixture
|
|
21
|
+
// there proves nothing about whether a bundle of that shape can execute.
|
|
22
|
+
const LIKEC4_STUB = '/*likec4*/var likec4Theme = {'
|
|
23
|
+
+ `primary:{elements:{fill:\`${THEME.likec4.brand}\`,stroke:\`#00524b\`,`
|
|
24
|
+
+ 'hiContrast:`#c7ffff`,loContrast:`#b2ffff`}}};'
|
|
25
|
+
+ 'var likec4Node = {shape:`rectangle`,color:`primary`};';
|
|
26
|
+
|
|
27
|
+
// The fixture set is four short sections. Narrowing the column by pinning
|
|
28
|
+
// reflows it by nothing measurable, so a scroll-anchoring check written against
|
|
29
|
+
// it passes whether the anchoring exists or not — which is what happened: on the
|
|
30
|
+
// real 20-document set the text under the reader moved 48px, and the fixture
|
|
31
|
+
// stayed green through a build with the correction deleted. This document exists
|
|
32
|
+
// to give the reflow something to move.
|
|
33
|
+
// The diagram has to be on this page and above the prose, which is the real
|
|
34
|
+
// set's arrangement: pinning both lifts a block out of the flow and narrows the
|
|
35
|
+
// column, and only the two together move the anchor.
|
|
36
|
+
const REFLOW_DOC = [
|
|
37
|
+
'# Reflow check', '',
|
|
38
|
+
'## Long enough to reflow', '',
|
|
39
|
+
'```mermaid', 'flowchart TD', ' A[Edge gateway] --> B[Settlement API]',
|
|
40
|
+
' B --> C[(Ledger)]', ' B --> D[Event publisher]', '```', '',
|
|
41
|
+
].concat(
|
|
42
|
+
[
|
|
43
|
+
'Settlement runs as a synchronous call and an outbound event, and the two disagree'
|
|
44
|
+
+ ' about time. The call returns when the ledger row is durable; the event is published'
|
|
45
|
+
+ ' after the transaction commits, which on a busy shard is tens of milliseconds later.',
|
|
46
|
+
'A partner that reads its own write through the event stream will therefore miss it,'
|
|
47
|
+
+ ' and the miss looks exactly like a dropped message rather than like a race. The read'
|
|
48
|
+
+ ' replica has the same shape of lag and the same shape of confusion.',
|
|
49
|
+
'Retries carry the idempotency key for twenty-six hours, one hour past the longest'
|
|
50
|
+
+ ' retry window any current partner uses. Inside that window a repeat returns the'
|
|
51
|
+
+ ' stored response verbatim, including the status code it first produced.',
|
|
52
|
+
'That last detail decides more than it looks like it does. A create that first failed'
|
|
53
|
+
+ ' validation returns the same failure on retry, even if the model it was validated'
|
|
54
|
+
+ ' against has since changed, because the alternative is a key that means two things.',
|
|
55
|
+
'Cancellation is where the boundary leaks. A settlement already in the capture window'
|
|
56
|
+
+ ' cannot be withdrawn, so cancel becomes a request rather than a command, and the'
|
|
57
|
+
+ ' caller learns the outcome from the event rather than from the response.',
|
|
58
|
+
'The gateway enforces authentication and the service trusts what reaches it. That is'
|
|
59
|
+
+ ' a deliberate trade recorded in the decision log, and it is revisited every time'
|
|
60
|
+
+ ' the gateway changes owner, because a misconfiguration there is a full bypass.',
|
|
61
|
+
'Rate limits are per credential rather than per address, advertised on every response'
|
|
62
|
+
+ ' so no caller has to discover them by exceeding one. The window slides over sixty'
|
|
63
|
+
+ ' seconds and is evaluated at the edge, never in the service.',
|
|
64
|
+
'A partner needing more than the settlement tier is moved to the batch interface'
|
|
65
|
+
+ ' instead of having the limit raised. The synchronous path is sized for interactive'
|
|
66
|
+
+ ' traffic, and seven thousand writes a minute is not interactive.',
|
|
67
|
+
].flatMap((p) => [p, ''])).concat(
|
|
68
|
+
// Heading text that collides with a spine key on purpose: this document is
|
|
69
|
+
// unclassified (reflow.md is not docs[0] and isn't a companion basename), so
|
|
70
|
+
// an explainer must not appear here. Without this, deleting the kind gate in
|
|
71
|
+
// injectSectionHelp still leaves "an excluded document grew an explainer"
|
|
72
|
+
// green, because none of this fixture's real headings matches a lookup key.
|
|
73
|
+
['## Security', ''],
|
|
74
|
+
).join('\n');
|
|
75
|
+
|
|
76
|
+
function buildViewer() {
|
|
77
|
+
const out = mkdtempSync(join(tmpdir(), 'analyze-requirements-browser-'));
|
|
78
|
+
const stub = (name, body) => { const p = join(out, name); writeFileSync(p, body); return p; };
|
|
79
|
+
execFileSync('node', [
|
|
80
|
+
'plugins/solution-architect/skills/analyze-requirements/scripts/render.mjs',
|
|
81
|
+
'--root', fixtures, '--arch', `${fixtures}ARCHITECTURE.md`,
|
|
82
|
+
'--docs', `${fixtures}docs/adr/0001-sample.md`, stub('reflow.md', REFLOW_DOC),
|
|
83
|
+
'--out', out,
|
|
84
|
+
'--likec4-bundle', stub('l.js', LIKEC4_STUB),
|
|
85
|
+
// Mermaid is stubbed: the diagram renderer is not what these check, and a
|
|
86
|
+
// 4.7 MB bundle would make the suite depend on a build step.
|
|
87
|
+
'--mermaid-bundle', stub('m.js', 'var mermaid={registerLayoutLoaders(){},initialize(){},'
|
|
88
|
+
+ 'async render(){return {svg:"<svg/>"}}},elkLayouts={};'),
|
|
89
|
+
'--theme', 'plugins/solution-architect/skills/analyze-requirements/assets/mermaid-theme.json',
|
|
90
|
+
], { stdio: 'pipe' });
|
|
91
|
+
return join(out, 'index.html');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
describe('the viewer in a real browser', { skip: findChrome() ? false : 'no chrome on PATH' }, () => {
|
|
95
|
+
let page;
|
|
96
|
+
|
|
97
|
+
before(async () => { page = await openPage(`file://${buildViewer()}`); });
|
|
98
|
+
after(() => page?.close());
|
|
99
|
+
|
|
100
|
+
// A single-file viewer is opened from disk as often as it is served, and
|
|
101
|
+
// file:// is where localStorage throws SecurityError. The guard around it is
|
|
102
|
+
// the one that keeps a failed theme read from taking the whole page.
|
|
103
|
+
test('boots from file:// with no console error', async () => {
|
|
104
|
+
assert.deepEqual(page.errors, []);
|
|
105
|
+
assert.equal(await page.eval('document.querySelectorAll(".page").length > 0'), true);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('the embedded faces are the ones actually used', async () => {
|
|
109
|
+
assert.equal(await page.eval('document.fonts.check(\'16px "IBM Plex Sans"\')'), true,
|
|
110
|
+
'IBM Plex Sans never loaded — the base64 @font-face did not take');
|
|
111
|
+
const used = await page.eval('getComputedStyle(document.body).fontFamily');
|
|
112
|
+
assert.match(used, /IBM Plex Sans/, `body resolved to ${used}`);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// One column, both edges. A `--prose` track capping paragraphs to 72ch was
|
|
116
|
+
// tried and reverted: it left the text ending ~240px short of the h2 rule above
|
|
117
|
+
// it and the table below it. Right edges are what the split broke, so both are
|
|
118
|
+
// measured, and across every kind of running text rather than `p` alone.
|
|
119
|
+
test('prose and blocks share both edges', async () => {
|
|
120
|
+
const drift = await page.eval(`(() => {
|
|
121
|
+
const vis = (s) => [...document.querySelectorAll(s)].find((e) => e.offsetParent);
|
|
122
|
+
const block = vis('.table-wrap').getBoundingClientRect();
|
|
123
|
+
return ['.main p', '.main ul', '.main h2', '.main h3']
|
|
124
|
+
.map((s) => [s, vis(s)]).filter(([, e]) => e)
|
|
125
|
+
.map(([s, e]) => {
|
|
126
|
+
const r = e.getBoundingClientRect();
|
|
127
|
+
return [s, Math.round(r.left - block.left), Math.round(r.right - block.right)];
|
|
128
|
+
});
|
|
129
|
+
})()`);
|
|
130
|
+
assert.ok(drift.length >= 2, `only ${drift.length} kinds of prose on the page to compare`);
|
|
131
|
+
for (const [sel, left, right] of drift) {
|
|
132
|
+
// A list indents its markers; nothing else may move on either side.
|
|
133
|
+
assert.ok(Math.abs(left) < 40, `${sel} starts ${left}px off the block edge`);
|
|
134
|
+
assert.ok(Math.abs(right) < 2, `${sel} ends ${right}px short of the block edge`);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// overflow-x: auto computes overflow-y to auto, so .table-scroll is a
|
|
139
|
+
// scrollport — and a sticky header has nothing to stick inside unless that
|
|
140
|
+
// scrollport is also given a height. Both halves are asserted, because the
|
|
141
|
+
// first version of this test only measured drift after scrolling, and a
|
|
142
|
+
// scrollport with no height cannot scroll: removing the cap made the check
|
|
143
|
+
// silently vacuous instead of red, which is the same failure shape as
|
|
144
|
+
// grepping a bundle for a hex that is present and never painted.
|
|
145
|
+
test('the table scrollport is bounded, which is what lets its header stick', async () => {
|
|
146
|
+
const css = await page.eval(`(() => {
|
|
147
|
+
const s = [...document.querySelectorAll('.table-scroll')].find((e) => e.offsetParent);
|
|
148
|
+
const c = getComputedStyle(s);
|
|
149
|
+
return { maxHeight: c.maxHeight, overflowY: c.overflowY,
|
|
150
|
+
th: getComputedStyle(s.querySelector('th')).position };
|
|
151
|
+
})()`);
|
|
152
|
+
assert.notEqual(css.maxHeight, 'none', 'an unbounded scrollport cannot hold a sticky header');
|
|
153
|
+
assert.match(css.overflowY, /auto|scroll/);
|
|
154
|
+
assert.equal(css.th, 'sticky');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// The fixture's table is two rows, so it never overflows the real cap. Forcing
|
|
158
|
+
// a small one is the only way to watch the header actually stay put — the rule
|
|
159
|
+
// under test is `position: sticky`, not the height the template chose.
|
|
160
|
+
test('a header held in a scrollport does not scroll away with its rows', async () => {
|
|
161
|
+
const stuck = await page.eval(`(() => {
|
|
162
|
+
const s = [...document.querySelectorAll('.table-scroll')].find((e) => e.offsetParent);
|
|
163
|
+
s.style.maxHeight = '48px';
|
|
164
|
+
const th = s.querySelector('th');
|
|
165
|
+
const before = th.getBoundingClientRect().top;
|
|
166
|
+
s.scrollTop = 40;
|
|
167
|
+
const moved = s.scrollTop > 0;
|
|
168
|
+
const drift = Math.abs(th.getBoundingClientRect().top - before);
|
|
169
|
+
s.style.maxHeight = '';
|
|
170
|
+
return { moved, drift };
|
|
171
|
+
})()`);
|
|
172
|
+
assert.equal(stuck.moved, true, 'the scrollport did not scroll, so nothing was proven');
|
|
173
|
+
assert.ok(stuck.drift < 2, `header drifted ${stuck.drift}px instead of sticking`);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('the theme toggle repaints the page', async () => {
|
|
177
|
+
const flip = await page.eval(`(() => {
|
|
178
|
+
const bg = () => getComputedStyle(document.body).backgroundColor;
|
|
179
|
+
const before = bg();
|
|
180
|
+
document.getElementById('theme-toggle').click();
|
|
181
|
+
return { before, after: bg(), attr: document.documentElement.dataset.theme };
|
|
182
|
+
})()`);
|
|
183
|
+
assert.notEqual(flip.before, flip.after, 'background did not change');
|
|
184
|
+
assert.ok(['dark', 'light'].includes(flip.attr));
|
|
185
|
+
await page.eval("document.getElementById('theme-toggle').click()");
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// The filter runs on every keystroke and now also reads document body text.
|
|
189
|
+
// Both the hit path and the empty state are states no text assertion reaches.
|
|
190
|
+
test('the rail filter hides what does not match, and says when nothing does', async () => {
|
|
191
|
+
const res = await page.eval(`(() => {
|
|
192
|
+
const f = document.getElementById('nav-filter');
|
|
193
|
+
const type = (v) => { f.value = v; f.dispatchEvent(new Event('input', { bubbles: true })); };
|
|
194
|
+
type('zzzznomatch');
|
|
195
|
+
const empty = getComputedStyle(document.getElementById('nav-empty')).display !== 'none';
|
|
196
|
+
type('');
|
|
197
|
+
const back = [...document.querySelectorAll('.nav-group')].every((g) => !g.hidden);
|
|
198
|
+
return { empty, back };
|
|
199
|
+
})()`);
|
|
200
|
+
assert.equal(res.empty, true, 'no empty state for a filter that matches nothing');
|
|
201
|
+
assert.equal(res.back, true, 'clearing the filter did not restore the rail');
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test('a rail link swaps which page is in the layout', async () => {
|
|
205
|
+
const nav = await page.eval(`(() => {
|
|
206
|
+
const shown = () => [...document.querySelectorAll('.page')].filter((p) => p.offsetParent);
|
|
207
|
+
const first = shown().length;
|
|
208
|
+
document.querySelector('.nav-link').click();
|
|
209
|
+
return { first, after: shown().length };
|
|
210
|
+
})()`);
|
|
211
|
+
assert.equal(nav.first, 1, `${nav.first} pages were in the layout at once`);
|
|
212
|
+
assert.equal(nav.after, 1, 'navigation left more than one page visible');
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Paper has no router. Every page is already in the DOM, only hidden, so print
|
|
216
|
+
// shows the whole set — which is what somebody printing an architecture
|
|
217
|
+
// document meant.
|
|
218
|
+
test('print reveals every page, not the routed one', async () => {
|
|
219
|
+
await page.send('Emulation.setEmulatedMedia', { media: 'print' });
|
|
220
|
+
const shown = await page.eval(
|
|
221
|
+
"[...document.querySelectorAll('.page')].filter((p) => p.offsetParent).length");
|
|
222
|
+
await page.send('Emulation.setEmulatedMedia', { media: '' });
|
|
223
|
+
assert.ok(shown > 1, `print showed ${shown} page(s) out of the whole set`);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// The point of the feature, and the only assertion that can make it: scroll to
|
|
227
|
+
// the bottom of the document and see whether the diagram is still on screen.
|
|
228
|
+
test('a pinned diagram survives scrolling to the end of the document', async () => {
|
|
229
|
+
const seen = await page.eval(`(() => {
|
|
230
|
+
const shell = [...document.querySelectorAll('.diagram-shell')].find((e) => e.offsetParent);
|
|
231
|
+
shell.querySelector('[data-pin]').click();
|
|
232
|
+
scrollTo(0, document.body.scrollHeight);
|
|
233
|
+
const r = shell.getBoundingClientRect();
|
|
234
|
+
return { onScreen: r.top < innerHeight && r.bottom > 0 && r.width > 0,
|
|
235
|
+
pressed: shell.querySelector('[data-pin]').getAttribute('aria-pressed') };
|
|
236
|
+
})()`);
|
|
237
|
+
assert.equal(seen.onScreen, true, 'the pinned diagram scrolled away with the prose');
|
|
238
|
+
assert.equal(seen.pressed, 'true');
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test('the pinned pane does not cover the prose it was pinned to read', async () => {
|
|
242
|
+
const lap = await page.eval(`(() => {
|
|
243
|
+
const shell = document.querySelector('.diagram-shell.is-pinned');
|
|
244
|
+
const p = [...document.querySelectorAll('.main p')].find((e) => e.offsetParent);
|
|
245
|
+
return p.getBoundingClientRect().right - shell.getBoundingClientRect().left;
|
|
246
|
+
})()`);
|
|
247
|
+
assert.ok(lap <= 0, `the pane overlaps the text column by ${lap}px`);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// Compared against the height the shell had *before* pinning: once pinned it is
|
|
251
|
+
// a full-height pane, so measuring it then compares the placeholder to the
|
|
252
|
+
// wrong box and reports ~400px of error against a correct placeholder.
|
|
253
|
+
test('the placeholder holds exactly the space the diagram left', async () => {
|
|
254
|
+
const fit = await page.eval(`(() => {
|
|
255
|
+
const shell = document.querySelector('.diagram-shell.is-pinned')
|
|
256
|
+
|| [...document.querySelectorAll('.diagram-shell')].find((e) => e.offsetParent);
|
|
257
|
+
if (shell.classList.contains('is-pinned')) shell.querySelector('[data-pin]').click();
|
|
258
|
+
const inFlow = shell.offsetHeight;
|
|
259
|
+
shell.querySelector('[data-pin]').click();
|
|
260
|
+
const slot = document.querySelector('.diagram-slot');
|
|
261
|
+
return slot ? Math.abs(parseFloat(slot.style.height) - inFlow) : null;
|
|
262
|
+
})()`);
|
|
263
|
+
assert.notEqual(fit, null, 'nothing was left holding the vacated space');
|
|
264
|
+
assert.ok(fit < 2, `the placeholder is ${fit}px off the height it replaced`);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// The first version of this measured document height and asserted it barely
|
|
268
|
+
// moved. That is the wrong quantity: reserving the gutter narrows the column,
|
|
269
|
+
// so the whole document legitimately reflows taller — 980px taller on the real
|
|
270
|
+
// 20-document set. What must not move is the text the reader is looking at, and
|
|
271
|
+
// on that same set it moved 48px until the anchor was restored. The fixture is
|
|
272
|
+
// too short to have shown either.
|
|
273
|
+
// Three things this test got wrong before they were measured, each of which
|
|
274
|
+
// made it green while measuring nothing:
|
|
275
|
+
// - `scrollTo(0, 500)` animates, because html sets scroll-behavior: smooth,
|
|
276
|
+
// so the page was still at the top when the anchor was read;
|
|
277
|
+
// - the router applies a frame after the click, so the long document was
|
|
278
|
+
// never the one on screen;
|
|
279
|
+
// - the window has to be narrow enough that the column is what binds, or the
|
|
280
|
+
// reserved gutter comes out of slack and nothing reflows at all.
|
|
281
|
+
//
|
|
282
|
+
// KNOWN LIMIT — this asserts the outcome but does not discriminate the code
|
|
283
|
+
// that produces it. Deleting `keepingPlace` leaves this green, because on a
|
|
284
|
+
// static fixture the whole reflow lands in one frame and Chrome's own scroll
|
|
285
|
+
// anchoring absorbs it. On a real set the LikeC4 webcomponent re-fits a frame
|
|
286
|
+
// later, after anchoring has run, and the anchor moves 48px. Measured on the
|
|
287
|
+
// 20-document EOS set, both ways, twice. Guarding that needs a fixture with an
|
|
288
|
+
// asynchronously-resizing diagram, which is a real bundle, which is a build
|
|
289
|
+
// step this suite deliberately does not have. What this test does still catch:
|
|
290
|
+
// pinning that stops reflowing, stops scrolling, or throws.
|
|
291
|
+
test('pinning keeps the reader where they were', async () => {
|
|
292
|
+
await page.send('Emulation.setDeviceMetricsOverride',
|
|
293
|
+
{ width: 1240, height: 800, deviceScaleFactor: 1, mobile: false });
|
|
294
|
+
const res = await page.eval(`(async () => {
|
|
295
|
+
const frame = () => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
|
|
296
|
+
// These tests share one page, and an earlier one leaves a diagram pinned.
|
|
297
|
+
// Pinning a second only swaps which diagram is in the pane — the gutter is
|
|
298
|
+
// already reserved, so nothing reflows and the check measures nothing.
|
|
299
|
+
dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
|
|
300
|
+
await frame();
|
|
301
|
+
[...document.querySelectorAll('.nav-link')]
|
|
302
|
+
.find((a) => a.textContent.includes('Long enough to reflow')).click();
|
|
303
|
+
await frame();
|
|
304
|
+
scrollTo({ top: 500, behavior: 'instant' });
|
|
305
|
+
await frame();
|
|
306
|
+
const shell = [...document.querySelectorAll('.diagram-shell')].find((e) => e.offsetParent);
|
|
307
|
+
const anchor = [...document.querySelectorAll('.main p')]
|
|
308
|
+
.find((e) => e.offsetParent && e.getBoundingClientRect().top > 120);
|
|
309
|
+
const before = anchor.getBoundingClientRect();
|
|
310
|
+
shell.querySelector('[data-pin]').click();
|
|
311
|
+
await frame();
|
|
312
|
+
const after = anchor.getBoundingClientRect();
|
|
313
|
+
shell.querySelector('[data-pin]').click();
|
|
314
|
+
return { jump: Math.round(after.top - before.top),
|
|
315
|
+
narrowed: Math.round(before.width - after.width),
|
|
316
|
+
scrolled: Math.round(scrollY) };
|
|
317
|
+
})()`);
|
|
318
|
+
await page.send('Emulation.clearDeviceMetricsOverride');
|
|
319
|
+
assert.ok(res.scrolled > 100, 'the page never scrolled, so nothing was anchored');
|
|
320
|
+
assert.ok(res.narrowed > 20, `the column narrowed by ${res.narrowed}px — nothing reflowed`);
|
|
321
|
+
assert.ok(Math.abs(res.jump) < 8, `the text under the reader moved ${res.jump}px`);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
test('escape releases the pin and puts the diagram back in the flow', async () => {
|
|
325
|
+
const after = await page.eval(`(() => {
|
|
326
|
+
dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
|
|
327
|
+
return { pinned: document.querySelectorAll('.diagram-shell.is-pinned').length,
|
|
328
|
+
slots: document.querySelectorAll('.diagram-slot').length,
|
|
329
|
+
gutter: document.body.classList.contains('has-pin') };
|
|
330
|
+
})()`);
|
|
331
|
+
assert.deepEqual(after, { pinned: 0, slots: 0, gutter: false });
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
test('the skip link moves focus into the document', async () => {
|
|
335
|
+
const landed = await page.eval(`(() => {
|
|
336
|
+
const skip = document.querySelector('.skip');
|
|
337
|
+
skip.click();
|
|
338
|
+
document.getElementById('main-content').focus();
|
|
339
|
+
return document.activeElement.id;
|
|
340
|
+
})()`);
|
|
341
|
+
assert.equal(landed, 'main-content');
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// Template text says the loop is present. It cannot say the button was built,
|
|
345
|
+
// that the lookup hit, or that a click opens anything — the panel is created in
|
|
346
|
+
// script from a global, so a boot-order or key mistake shows up only here.
|
|
347
|
+
test('a spine heading offers an explainer that opens on click', async () => {
|
|
348
|
+
const found = await page.eval(`(() => {
|
|
349
|
+
var h = [].slice.call(document.querySelectorAll('[data-kind="spine"] h2'))
|
|
350
|
+
.filter(function (el) { return el.textContent.indexOf('Core Components') >= 0; })[0];
|
|
351
|
+
if (!h) return { err: 'no Core Components heading under a spine page' };
|
|
352
|
+
var btn = h.querySelector('.help-btn');
|
|
353
|
+
if (!btn) return { err: 'no help button in the heading' };
|
|
354
|
+
var panel = h.nextElementSibling;
|
|
355
|
+
return {
|
|
356
|
+
tag: panel && panel.tagName,
|
|
357
|
+
cls: panel && panel.className,
|
|
358
|
+
expanded: btn.getAttribute('aria-expanded'),
|
|
359
|
+
controls: btn.getAttribute('aria-controls'),
|
|
360
|
+
panelId: panel && panel.id,
|
|
361
|
+
open: panel && panel.open,
|
|
362
|
+
};
|
|
363
|
+
})()`);
|
|
364
|
+
assert.equal(found.err, undefined, found.err);
|
|
365
|
+
assert.equal(found.tag, 'DETAILS');
|
|
366
|
+
assert.equal(found.cls, 'help');
|
|
367
|
+
assert.equal(found.expanded, 'false', 'a closed panel must not report itself open');
|
|
368
|
+
assert.equal(found.controls, found.panelId, 'aria-controls does not reach the panel');
|
|
369
|
+
assert.equal(found.open, false);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
// The reason the panel is a <details> driven by a button rather than a bare
|
|
373
|
+
// summary: the state has to be readable from the button, and both have to agree.
|
|
374
|
+
test('clicking the explainer toggles both the panel and the button state', async () => {
|
|
375
|
+
// aria-expanded is set from the <details> element's own "toggle" event,
|
|
376
|
+
// which the HTML spec queues as a task rather than firing inline with the
|
|
377
|
+
// click — so a tick has to pass before the button's attribute catches up.
|
|
378
|
+
const cycle = await page.eval(`(async () => {
|
|
379
|
+
var tick = function () { return new Promise(function (r) { setTimeout(r, 0); }); };
|
|
380
|
+
var h = [].slice.call(document.querySelectorAll('[data-kind="spine"] h2'))
|
|
381
|
+
.filter(function (el) { return el.textContent.indexOf('Core Components') >= 0; })[0];
|
|
382
|
+
var btn = h.querySelector('.help-btn');
|
|
383
|
+
var panel = h.nextElementSibling;
|
|
384
|
+
btn.click();
|
|
385
|
+
await tick();
|
|
386
|
+
var opened = { open: panel.open, aria: btn.getAttribute('aria-expanded'),
|
|
387
|
+
text: panel.textContent };
|
|
388
|
+
btn.click();
|
|
389
|
+
await tick();
|
|
390
|
+
return { opened: opened, closed: { open: panel.open,
|
|
391
|
+
aria: btn.getAttribute('aria-expanded') } };
|
|
392
|
+
})()`);
|
|
393
|
+
assert.equal(cycle.opened.open, true);
|
|
394
|
+
assert.equal(cycle.opened.aria, 'true');
|
|
395
|
+
assert.match(cycle.opened.text, /What goes here/);
|
|
396
|
+
// The content is the asset's, not a label the loop invented.
|
|
397
|
+
assert.match(cycle.opened.text, /responsible for/);
|
|
398
|
+
assert.equal(cycle.closed.open, false);
|
|
399
|
+
assert.equal(cycle.closed.aria, 'false');
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
// A document with no kind renders exactly as it does today. The ADR fixture is
|
|
403
|
+
// the case the spec excludes by name: §14 is already the home for that guidance.
|
|
404
|
+
test('a document with no kind gets no explainer', async () => {
|
|
405
|
+
const count = await page.eval(
|
|
406
|
+
"document.querySelectorAll('.page:not([data-kind]) .help-btn').length");
|
|
407
|
+
assert.equal(count, 0, 'an excluded document grew an explainer');
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
// Subheadings are out of scope, and an h3 that happens to share a spine
|
|
411
|
+
// heading's text must not pick one up.
|
|
412
|
+
test('subheadings get no explainer', async () => {
|
|
413
|
+
assert.equal(await page.eval("document.querySelectorAll('.doc h3 .help-btn').length"), 0);
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
test('injecting the explainers logs no error', async () => {
|
|
417
|
+
assert.deepEqual(page.errors, []);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
// The zoom, pan and expand controls shipped covered by template text alone —
|
|
421
|
+
// text can say the handler is wired, not that clicking it moves anything. The
|
|
422
|
+
// pin control was the only one of the six with a browser assertion.
|
|
423
|
+
const SHELL = `(() => {
|
|
424
|
+
const shell = [...document.querySelectorAll('.diagram-shell')].find((e) => e.offsetParent);
|
|
425
|
+
if (shell.classList.contains('is-pinned')) shell.querySelector('[data-pin]').click();
|
|
426
|
+
return shell;
|
|
427
|
+
})()`;
|
|
428
|
+
|
|
429
|
+
test('the zoom control scales the canvas and reports the new level', async () => {
|
|
430
|
+
const z = await page.eval(`(() => {
|
|
431
|
+
const shell = ${SHELL};
|
|
432
|
+
const canvas = shell.querySelector('.diagram-canvas');
|
|
433
|
+
const readout = shell.querySelector('[data-zoom-reset]');
|
|
434
|
+
readout.click();
|
|
435
|
+
const reset = canvas.style.transform;
|
|
436
|
+
shell.querySelector('[data-zoom-in]').click();
|
|
437
|
+
return { reset, after: canvas.style.transform,
|
|
438
|
+
text: readout.textContent, aria: readout.getAttribute('aria-label') };
|
|
439
|
+
})()`);
|
|
440
|
+
assert.match(z.reset, /scale\(1\)/, 'reset did not put the canvas back to 1x');
|
|
441
|
+
assert.match(z.after, /scale\(1\.2\)/, `zoom-in left the transform at ${z.after}`);
|
|
442
|
+
// The readout doubles as the reset button, so the level has to reach both the
|
|
443
|
+
// visible text and the accessible name.
|
|
444
|
+
assert.equal(z.text, '120%');
|
|
445
|
+
assert.match(z.aria, /currently 120%/);
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
test('the expand control flips its own pressed state', async () => {
|
|
449
|
+
const e = await page.eval(`(() => {
|
|
450
|
+
const shell = ${SHELL};
|
|
451
|
+
const btn = shell.querySelector('[data-expand]');
|
|
452
|
+
btn.click();
|
|
453
|
+
const on = { cls: shell.classList.contains('is-expanded'),
|
|
454
|
+
aria: btn.getAttribute('aria-pressed') };
|
|
455
|
+
btn.click();
|
|
456
|
+
return { on, off: { cls: shell.classList.contains('is-expanded'),
|
|
457
|
+
aria: btn.getAttribute('aria-pressed') } };
|
|
458
|
+
})()`);
|
|
459
|
+
assert.deepEqual(e.on, { cls: true, aria: 'true' });
|
|
460
|
+
assert.deepEqual(e.off, { cls: false, aria: 'false' });
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
// Pan was unbounded once: the canvas could be thrown clear of the viewport and
|
|
464
|
+
// the way back was a button the reader had to already know was a reset. The
|
|
465
|
+
// clamp is proved by panning past the edge twice — the second run must move
|
|
466
|
+
// nothing, because the first already sat on the limit.
|
|
467
|
+
test('a zoomed diagram pans, and stops at the edge of its own frame', async () => {
|
|
468
|
+
const p = await page.eval(`(() => {
|
|
469
|
+
const shell = ${SHELL};
|
|
470
|
+
const vp = shell.querySelector('.diagram-viewport');
|
|
471
|
+
const canvas = shell.querySelector('.diagram-canvas');
|
|
472
|
+
shell.querySelector('[data-zoom-reset]').click();
|
|
473
|
+
const atRest = vp.classList.contains('is-pannable');
|
|
474
|
+
for (let i = 0; i < 4; i += 1) shell.querySelector('[data-zoom-in]').click();
|
|
475
|
+
const zoomed = vp.classList.contains('is-pannable');
|
|
476
|
+
const xOf = () => {
|
|
477
|
+
const m = /translate\\((-?[\\d.]+)px,\\s*(-?[\\d.]+)px\\)/.exec(canvas.style.transform);
|
|
478
|
+
return m ? parseFloat(m[1]) : null;
|
|
479
|
+
};
|
|
480
|
+
vp.focus();
|
|
481
|
+
const pan = (n) => { for (let i = 0; i < n; i += 1) {
|
|
482
|
+
vp.dispatchEvent(new KeyboardEvent('keydown',
|
|
483
|
+
{ key: 'ArrowRight', bubbles: true, cancelable: true }));
|
|
484
|
+
} };
|
|
485
|
+
pan(30);
|
|
486
|
+
const first = xOf();
|
|
487
|
+
pan(30);
|
|
488
|
+
return { atRest, zoomed, first, second: xOf(), unclamped: 30 * 48 };
|
|
489
|
+
})()`);
|
|
490
|
+
assert.equal(p.atRest, false, 'a diagram that fits its box was still pannable');
|
|
491
|
+
assert.equal(p.zoomed, true, 'a 2x zoom left the diagram unpannable');
|
|
492
|
+
assert.ok(Math.abs(p.first) > 0, 'arrow keys panned a pannable diagram nowhere');
|
|
493
|
+
assert.ok(Math.abs(p.first) < p.unclamped,
|
|
494
|
+
`pan reached ${Math.abs(p.first)}px of an unclamped ${p.unclamped}px`);
|
|
495
|
+
assert.equal(p.second, p.first, 'panning past the edge kept moving the canvas');
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
/* The rail's current-position marking is driven by the scroll spy, not by the
|
|
499
|
+
click handler, so it needs a real IntersectionObserver to have run. Driven by
|
|
500
|
+
scrolling a chosen heading under the topbar rather than by clicking its link:
|
|
501
|
+
the spy's band is a thin strip below the bar, and on a document this short a
|
|
502
|
+
click often cannot bring its own target into it — the mark then correctly
|
|
503
|
+
lags behind the link that was clicked, which makes the click a test of
|
|
504
|
+
scroll distance rather than of the marking. */
|
|
505
|
+
test('the rail marks one heading at a time and names it in the breadcrumb', async () => {
|
|
506
|
+
const spy = await page.eval(`(async () => {
|
|
507
|
+
const settle = () => new Promise((r) => requestAnimationFrame(() => setTimeout(r, 80)));
|
|
508
|
+
const read = () => {
|
|
509
|
+
const on = [...document.querySelectorAll('.nav-link.is-active')];
|
|
510
|
+
return { links: on.length, href: on[0] && on[0].getAttribute('href'),
|
|
511
|
+
/* The rail link's own text, not the heading's: the heading has had a '#'
|
|
512
|
+
deep-link anchor prepended and a '?' explainer button appended, so its
|
|
513
|
+
textContent is no longer the title the breadcrumb shows. */
|
|
514
|
+
text: on[0] && on[0].textContent.trim(),
|
|
515
|
+
groups: document.querySelectorAll('.nav-group.is-current').length,
|
|
516
|
+
secs: document.querySelectorAll('.nav-sec.is-current').length,
|
|
517
|
+
crumb: document.getElementById('crumb').textContent.trim() };
|
|
518
|
+
};
|
|
519
|
+
// Earlier tests leave whichever document they needed routed, and only the
|
|
520
|
+
// routed one has headings in the layout — so route to the spine first.
|
|
521
|
+
document.querySelector('.nav-link').click();
|
|
522
|
+
await settle();
|
|
523
|
+
/* Swept rather than aimed at one heading: the band is thin and the fixture
|
|
524
|
+
document is short, so scrolling saturates before an arbitrary heading can
|
|
525
|
+
be placed in it. The sweep asks a weaker question the fixture can answer —
|
|
526
|
+
across the whole document, which headings does the rail ever mark. */
|
|
527
|
+
const seen = [];
|
|
528
|
+
const height = document.documentElement.scrollHeight;
|
|
529
|
+
for (let i = 0; i <= 10; i += 1) {
|
|
530
|
+
scrollTo(0, Math.round((height * i) / 10));
|
|
531
|
+
await settle();
|
|
532
|
+
const at = read();
|
|
533
|
+
if (at.links || at.href) seen.push(at);
|
|
534
|
+
}
|
|
535
|
+
return { seen, marks: [...new Set(seen.map((s) => s.href))] };
|
|
536
|
+
})()`);
|
|
537
|
+
assert.ok(spy.seen.length > 0, 'the rail marked nothing anywhere in the document');
|
|
538
|
+
for (const at of spy.seen) {
|
|
539
|
+
// One at each level: the previous mark has to be cleared, not added to.
|
|
540
|
+
assert.equal(at.links, 1, `${at.links} rail links were active at once`);
|
|
541
|
+
assert.equal(at.groups, 1, `${at.groups} nav groups claimed to be current`);
|
|
542
|
+
assert.equal(at.secs, 1, `${at.secs} nav sections claimed to be current`);
|
|
543
|
+
// Section / document / heading — the heading is the mark's own link text.
|
|
544
|
+
assert.ok(at.crumb.endsWith(at.text), `breadcrumb "${at.crumb}" does not end at ${at.text}`);
|
|
545
|
+
}
|
|
546
|
+
assert.ok(spy.marks.length >= 2,
|
|
547
|
+
`the mark never moved: it sat on ${spy.marks[0]} down the whole document`);
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
test('driving the diagram and the rail logs no error', async () => {
|
|
551
|
+
assert.deepEqual(page.errors, []);
|
|
552
|
+
});
|
|
553
|
+
});
|