@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
package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs
ADDED
|
@@ -0,0 +1,1206 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { embed } from '../lib/embed.mjs';
|
|
5
|
+
|
|
6
|
+
const tpl = readFileSync(new URL('../../assets/viewer-template.html', import.meta.url), 'utf8');
|
|
7
|
+
|
|
8
|
+
test('template has exactly the eight slots and no external URLs', () => {
|
|
9
|
+
const markers = [...tpl.matchAll(/<!-- slot:(\w+) -->/g)].map((m) => m[1]).sort();
|
|
10
|
+
assert.deepEqual(markers,
|
|
11
|
+
['DOC', 'FONTS', 'LIKEC4_BUNDLE', 'MERMAID_BUNDLE', 'NAV', 'SECTION_HELP', 'THEME', 'TITLE']);
|
|
12
|
+
assert.doesNotMatch(tpl, /https?:\/\/(?!www\.w3\.org)/);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// The faces have to be declared before the stacks that name them, and the whole
|
|
16
|
+
// point is that the bytes are not in this file: 100KB of base64 would turn a
|
|
17
|
+
// readable design document into a blob with a stylesheet round it.
|
|
18
|
+
test('the font slot sits at the head of the stylesheet, not in the repo', () => {
|
|
19
|
+
const style = tpl.indexOf('<style>');
|
|
20
|
+
assert.ok(tpl.indexOf('<!-- slot:FONTS -->') > style);
|
|
21
|
+
assert.ok(tpl.indexOf('<!-- slot:FONTS -->') < tpl.indexOf('--font-display'));
|
|
22
|
+
assert.doesNotMatch(tpl, /base64,[A-Za-z0-9+/]{200,}/,
|
|
23
|
+
'font bytes belong in the slot, not committed into the template');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('template embeds cleanly and keeps required controls', () => {
|
|
27
|
+
const out = embed({ template: tpl, slots: {
|
|
28
|
+
TITLE: 't', NAV: '<a href="#x">x</a>', DOC: '<h2 id="x">x</h2>',
|
|
29
|
+
LIKEC4_BUNDLE: '/*l*/', MERMAID_BUNDLE: '/*m*/', THEME: '{"themeVariables":{}}',
|
|
30
|
+
FONTS: '/*fonts*/', SECTION_HELP: '{"spine":{},"companions":{}}',
|
|
31
|
+
} });
|
|
32
|
+
for (const control of ['data-zoom-in', 'data-zoom-out', 'data-zoom-reset', 'data-expand', 'data-fullscreen']) {
|
|
33
|
+
assert.match(out, new RegExp(control));
|
|
34
|
+
}
|
|
35
|
+
assert.match(out, /registerLayoutLoaders/);
|
|
36
|
+
assert.match(out, /theme:\s*'base'/);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('the rail is a labelled landmark with a filter and a mobile toggle', () => {
|
|
40
|
+
assert.match(tpl, /<nav[^>]*class="[^"]*sidebar[^"]*"[^>]*aria-label=/);
|
|
41
|
+
assert.match(tpl, /id="nav-filter"/);
|
|
42
|
+
assert.match(tpl, /id="nav-toggle"/);
|
|
43
|
+
assert.match(tpl, /aria-expanded=/);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('the rail tracks the reader with scroll spy over grouped links', () => {
|
|
47
|
+
assert.match(tpl, /IntersectionObserver/);
|
|
48
|
+
assert.match(tpl, /is-active/);
|
|
49
|
+
assert.match(tpl, /nav-group/);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('the rail styles and scripts a section level above the document groups', () => {
|
|
53
|
+
assert.match(tpl, /\.nav-sec__head\s*\{/);
|
|
54
|
+
assert.match(tpl, /\.nav-sec\[open\]/);
|
|
55
|
+
// The filter and the scroll spy both have to reach through the section, or a
|
|
56
|
+
// hit inside a collapsed Decision Records block is invisible.
|
|
57
|
+
assert.match(tpl, /sections\s*=\s*\[\]\.slice\.call\(document\.querySelectorAll\('\.nav-sec'\)\)/);
|
|
58
|
+
assert.match(tpl, /closest\('\.nav-sec'\)/);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('live counts use tabular figures so filtering does not jiggle the rail', () => {
|
|
62
|
+
const counts = tpl.match(/\.nav-sec__count,\s*\.nav-group__count \{[\s\S]*?\}/)[0];
|
|
63
|
+
assert.match(counts, /font-variant-numeric:\s*tabular-nums/);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('icon buttons carry a 40px hit area without overlapping each other', () => {
|
|
67
|
+
const hit = tpl.match(/\.icon-btn::after \{[\s\S]*?\}/)[0];
|
|
68
|
+
assert.match(hit, /inset:\s*-(\d+)px/);
|
|
69
|
+
assert.match(tpl, /\.icon-btn:active \{[^}]*scale:\s*\.96/);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('the theme icons cross-fade instead of popping via display', () => {
|
|
73
|
+
assert.doesNotMatch(tpl, /\.i-sun \{ display: none; \}/);
|
|
74
|
+
assert.match(tpl, /filter:\s*blur\(4px\)/);
|
|
75
|
+
assert.match(tpl, /cubic-bezier\(\.2, 0, 0, 1\)/);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('layout is responsive and honours reduced motion', () => {
|
|
79
|
+
assert.match(tpl, /@media\s*\(max-width:/);
|
|
80
|
+
assert.match(tpl, /prefers-reduced-motion/);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('long-form reading defaults are set on the content column', () => {
|
|
84
|
+
assert.match(tpl, /--measure:/);
|
|
85
|
+
assert.match(tpl, /scroll-margin-top:/);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('code blocks keep their own line breaks so tree connectors stay aligned', () => {
|
|
89
|
+
const pre = tpl.match(/\npre \{[\s\S]*?\}/)[0];
|
|
90
|
+
assert.match(pre, /white-space:\s*pre\s*;/);
|
|
91
|
+
assert.doesNotMatch(pre, /pre-wrap/);
|
|
92
|
+
assert.doesNotMatch(pre, /word-break/);
|
|
93
|
+
assert.match(pre, /overflow:\s*auto/);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const bodyRule = tpl.match(/\nbody \{[\s\S]*?\n\}/)[0];
|
|
97
|
+
const num = (src, prop) => Number(src.match(new RegExp(`${prop}:\\s*([\\d.]+)`))[1]);
|
|
98
|
+
|
|
99
|
+
test('sub-headings outrank body text so a long document keeps its structure', () => {
|
|
100
|
+
// h3 was 16px against 16.5px body: sub-sections read as bold paragraphs, and
|
|
101
|
+
// a 21-document scroll loses its second level entirely.
|
|
102
|
+
const h3 = num(tpl.match(/\.main h3 \{[\s\S]*?\}/)[0], 'font-size');
|
|
103
|
+
assert.ok(h3 > num(bodyRule, 'font-size'), `h3 ${h3}px must outrank body text`);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('paragraphs are separated by at least a full line', () => {
|
|
107
|
+
const gap = Number(tpl.match(/\.main p \{[\s\S]*?margin:\s*0 0 ([\d.]+)px/)[1]);
|
|
108
|
+
const line = num(bodyRule, 'font-size') * num(bodyRule, 'line-height');
|
|
109
|
+
assert.ok(gap >= line * 0.8, `${gap}px gap is short against a ${line.toFixed(1)}px line`);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('headings balance their line breaks', () => {
|
|
113
|
+
assert.match(tpl, /\.main :is\(h2, h3\) \{[^}]*text-wrap: balance/);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('a code block too wide for the column scrolls inside it', () => {
|
|
117
|
+
// It used to break out to a 1080px track. A block wider than the prose above
|
|
118
|
+
// it moves the left edge, and the reader re-finds it on every one.
|
|
119
|
+
const pre = tpl.match(/\npre \{[\s\S]*?\}/)[0];
|
|
120
|
+
assert.match(pre, /overflow:\s*auto/);
|
|
121
|
+
assert.match(pre, /max-height:/);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('inline code inside a heading drops the chip it wears in prose', () => {
|
|
125
|
+
// A .855em chip on a clamp(30px, 3.4vw, 43px) display heading is a 37px grey
|
|
126
|
+
// box that outweighs the words around it.
|
|
127
|
+
const rule = tpl.match(/:is\(\.doc-head, \.main h2, \.main h3\) code \{[\s\S]*?\}/)[0];
|
|
128
|
+
assert.match(rule, /background:\s*none/);
|
|
129
|
+
assert.match(rule, /padding:\s*0/);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('a deep-linked heading marks where the reader landed', () => {
|
|
133
|
+
assert.match(tpl, /:target/);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('table figures line up down their column', () => {
|
|
137
|
+
assert.match(tpl, /\ntd \{[^}]*tabular-nums/);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('diagram controls are icon buttons with accessible names', () => {
|
|
141
|
+
assert.match(tpl, /aria-label="Zoom in"/);
|
|
142
|
+
assert.match(tpl, /aria-label="Fullscreen"/);
|
|
143
|
+
assert.doesNotMatch(tpl, />Exp</);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test('mermaid theme json parses and bans color in classDefs', () => {
|
|
147
|
+
const theme = JSON.parse(readFileSync(new URL('../../assets/mermaid-theme.json', import.meta.url), 'utf8'));
|
|
148
|
+
assert.ok(theme.themeVariables.fontFamily.includes('IBM Plex'));
|
|
149
|
+
assert.doesNotMatch(JSON.stringify(theme), /"color"/);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// The toggle re-rendered mermaid and left LikeC4 in whichever mode it booted
|
|
153
|
+
// in, so dark mode showed a light diagram on a dark page. The webcomponent
|
|
154
|
+
// reads a color-scheme attribute; the viewer never set it.
|
|
155
|
+
test('the theme toggle reaches LikeC4, not just mermaid', () => {
|
|
156
|
+
assert.match(tpl, /setAttribute\('color-scheme'/);
|
|
157
|
+
assert.match(tpl, /querySelectorAll\('c4-view'\)/);
|
|
158
|
+
// Both renderers move on one call, or they drift apart again the next time
|
|
159
|
+
// somebody adds a third thing to the toggle.
|
|
160
|
+
const toggle = tpl.match(/theme-toggle'\)\.addEventListener[\s\S]*?\n\}\);/)[0];
|
|
161
|
+
assert.match(toggle, /syncDiagramTheme|applyTheme/);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// One file is the palette for both renderers: mermaid reads it at runtime,
|
|
165
|
+
// LikeC4 bakes it in at generate time. Leaving them in two places is how the
|
|
166
|
+
// diagrams drifted to teal and blue in the first place.
|
|
167
|
+
const theme = JSON.parse(readFileSync(new URL('../../assets/mermaid-theme.json', import.meta.url), 'utf8'));
|
|
168
|
+
|
|
169
|
+
// The two renderers were teal-on-pale and teal-on-solid: mermaid drew a light
|
|
170
|
+
// tinted fill with a dark border, LikeC4 a solid fill with light text. LikeC4's
|
|
171
|
+
// leaf fill cannot be softened — opacity reaches the node data but its renderer
|
|
172
|
+
// only applies it to compound groups — so mermaid is the one that moves.
|
|
173
|
+
test('mermaid fills match the exact hexes LikeC4 derives from the same brand', () => {
|
|
174
|
+
assert.match(theme.likec4.brand, /^#[0-9a-f]{6}$/, 'brand is not a hex');
|
|
175
|
+
assert.equal(theme.themeVariables.primaryColor, theme.likec4.brand);
|
|
176
|
+
assert.equal(theme.themeVariables.primaryBorderColor, theme.likec4.brandStroke);
|
|
177
|
+
assert.equal(theme.themeVariables.primaryTextColor, theme.likec4.brandText);
|
|
178
|
+
assert.equal(theme.themeVariables.secondaryColor, theme.likec4.muted);
|
|
179
|
+
assert.equal(theme.themeVariables.secondaryBorderColor, theme.likec4.mutedStroke);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// A solid fill carries its own text colour, so it is legible in either mode.
|
|
183
|
+
// LikeC4 proves the point: sampled pixel-for-pixel, its node fill is #0f766e in
|
|
184
|
+
// light AND dark — only the canvas behind it flips.
|
|
185
|
+
test('the element palette does not change between light and dark', () => {
|
|
186
|
+
for (const key of ['primaryColor', 'primaryBorderColor', 'primaryTextColor',
|
|
187
|
+
'secondaryColor', 'lineColor']) {
|
|
188
|
+
assert.equal(theme.dark[key], undefined, `${key} must not be re-stated per mode`);
|
|
189
|
+
assert.equal(theme.light[key], undefined, `${key} must not be re-stated per mode`);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// Merged, not swapped: the mode block holds only what genuinely differs, so a
|
|
194
|
+
// shared value cannot be updated in one mode and forgotten in the other.
|
|
195
|
+
test('the mode palette is merged over the shared one', () => {
|
|
196
|
+
assert.match(tpl, /Object\.assign\(\{\}, t\.themeVariables/);
|
|
197
|
+
assert.match(tpl, /isDark\(\) \? t\.dark : t\.light/);
|
|
198
|
+
assert.match(tpl, /ARCH_DOCS_THEME/);
|
|
199
|
+
assert.match(tpl, /rerenderDiagrams\(\)/);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// A subgraph panel, an edge-label chip and the prose ink are chrome, not
|
|
203
|
+
// elements: they sit against the canvas, so they have to flip with it. Holding
|
|
204
|
+
// only one mode's values is what put black boundary panels on a cream page.
|
|
205
|
+
// Both blocks state the same keys, or the next palette edit lands in one mode
|
|
206
|
+
// and the other keeps a stale hex with nothing to flag it.
|
|
207
|
+
test('every chrome value is stated for both modes, never only one', () => {
|
|
208
|
+
const l = Object.keys(theme.light).sort();
|
|
209
|
+
const d = Object.keys(theme.dark).sort();
|
|
210
|
+
assert.deepEqual(l, d, 'light and dark must state the same keys');
|
|
211
|
+
assert.ok(l.length >= 4, 'the mode blocks look empty');
|
|
212
|
+
for (const key of l) {
|
|
213
|
+
assert.equal(theme.themeVariables[key], undefined,
|
|
214
|
+
`${key} is per-mode, so a shared value for it only looks authoritative`);
|
|
215
|
+
assert.notEqual(theme.light[key], theme.dark[key], `${key} is the same in both modes`);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// The sync contract, measured rather than guessed: LikeC4's own render sampled
|
|
220
|
+
// pixel-for-pixel in each mode, and mermaid told to paint the same hex with the
|
|
221
|
+
// same chrome. Which mermaid variable paints which part was also found by
|
|
222
|
+
// rendering with marker colours — a subgraph takes clusterBkg/clusterBorder and
|
|
223
|
+
// its title takes titleColor, none of which fall back to the tertiary trio once
|
|
224
|
+
// they are set.
|
|
225
|
+
test('mermaid chrome matches the hexes LikeC4 paints in the same mode', () => {
|
|
226
|
+
const map = {
|
|
227
|
+
clusterBkg: 'groupFill',
|
|
228
|
+
clusterBorder: 'groupStroke',
|
|
229
|
+
titleColor: 'groupText',
|
|
230
|
+
};
|
|
231
|
+
for (const mode of ['light', 'dark']) {
|
|
232
|
+
for (const [mermaidVar, likec4Role] of Object.entries(map)) {
|
|
233
|
+
assert.equal(theme[mode][mermaidVar], theme.likec4[mode][likec4Role],
|
|
234
|
+
`${mode} ${mermaidVar} does not match LikeC4's ${likec4Role}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// WCAG relative luminance and contrast ratio. Diagram text is baked into the
|
|
240
|
+
// SVG, so an unreadable pairing cannot be fixed by the reader or by the theme
|
|
241
|
+
// toggle — it has to be caught here.
|
|
242
|
+
const lum = (h) => {
|
|
243
|
+
const ch = [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16) / 255)
|
|
244
|
+
.map((c) => (c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4));
|
|
245
|
+
return 0.2126 * ch[0] + 0.7152 * ch[1] + 0.0722 * ch[2];
|
|
246
|
+
};
|
|
247
|
+
const contrast = (a, b) => {
|
|
248
|
+
const [hi, lo] = [lum(a), lum(b)].sort((x, y) => y - x);
|
|
249
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
test('every diagram text pairing clears the WCAG AA ratio', () => {
|
|
253
|
+
const v = theme.themeVariables;
|
|
254
|
+
const pairs = [
|
|
255
|
+
['entity name on its fill', v.primaryColor, v.primaryTextColor],
|
|
256
|
+
['secondary node label', v.secondaryColor, v.secondaryTextColor],
|
|
257
|
+
// An ER attribute row is a second fill inside the entity, and the row text is
|
|
258
|
+
// locked to primaryTextColor with the entity name. Left unstated, mermaid
|
|
259
|
+
// derives the odd row by lightening primaryColor 75 points, which on a teal
|
|
260
|
+
// brand clamps to white and hides every other line of §8's ER diagram.
|
|
261
|
+
['ER attribute row, odd', v.rowOdd, v.primaryTextColor],
|
|
262
|
+
['ER attribute row, even', v.rowEven, v.primaryTextColor],
|
|
263
|
+
];
|
|
264
|
+
// The chrome pairings are per mode, and a ratio that only holds in one of them
|
|
265
|
+
// is the bug this pass exists to close.
|
|
266
|
+
for (const mode of ['light', 'dark']) {
|
|
267
|
+
const m = theme[mode];
|
|
268
|
+
pairs.push([`${mode} DFD boundary title on its panel`, m.clusterBkg, m.titleColor]);
|
|
269
|
+
}
|
|
270
|
+
for (const [what, bg, fg] of pairs) {
|
|
271
|
+
const ratio = contrast(bg, fg);
|
|
272
|
+
assert.ok(ratio >= 4.5, `${what}: ${fg} on ${bg} is only ${ratio.toFixed(2)}:1`);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// A relation label ("owns", "HTTPS + session cookie") is a word on a line, not a
|
|
277
|
+
// component, and no mermaid variable can say that: the label text is locked to
|
|
278
|
+
// primaryTextColor — the light ink solid teal fills need — so any chip mermaid
|
|
279
|
+
// paints has to be dark to stay legible, which on a cream page is a dark blob.
|
|
280
|
+
// Mermaid's SVG is in the page's own DOM, not a shadow root, so the viewer takes
|
|
281
|
+
// the label back instead: page surface behind it, page ink in front, both already
|
|
282
|
+
// flipping with the theme. That leaves no per-mode hex to state, which is why
|
|
283
|
+
// edgeLabelBackground is gone from the palette rather than tuned.
|
|
284
|
+
test('the viewer, not mermaid, paints the relation label', () => {
|
|
285
|
+
const rule = tpl.match(/\n\.diagram-canvas \.labelBkg,[\s\S]*?\n\}/)[0];
|
|
286
|
+
assert.match(rule, /background-color:\s*var\(--surface\)\s*!important/);
|
|
287
|
+
assert.match(rule, /color:\s*var\(--text\)\s*!important/);
|
|
288
|
+
// Per diagram type mermaid colours a different layer: the ER label its
|
|
289
|
+
// wrapping div, the flowchart label the innermost <p>. Missing one leaves that
|
|
290
|
+
// diagram type with a chip nothing else has.
|
|
291
|
+
for (const layer of [/\.labelBkg/, /span\.edgeLabel,/, /span\.edgeLabel p/]) {
|
|
292
|
+
assert.match(rule, layer, 'a label layer mermaid paints is not covered');
|
|
293
|
+
}
|
|
294
|
+
for (const block of ['themeVariables', 'light', 'dark']) {
|
|
295
|
+
assert.equal(theme[block].edgeLabelBackground, undefined,
|
|
296
|
+
`edgeLabelBackground in ${block} is overridden by the viewer, so it only misleads`);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// The same label, the other renderer. LikeC4 draws its relation label as
|
|
301
|
+
// div.likec4-edge-label inside a nested — but open — shadow root, so page CSS
|
|
302
|
+
// cannot select it and the chip survived while every mermaid label lost one:
|
|
303
|
+
// §10 stayed a dark blob on a cream page next to a §12 that did not. A style
|
|
304
|
+
// element pushed into the shadow root reaches it, and because custom properties
|
|
305
|
+
// inherit across the shadow boundary the same var() flips with the toggle
|
|
306
|
+
// without re-injecting anything.
|
|
307
|
+
test('the relation label loses its chip in LikeC4 too, not just mermaid', () => {
|
|
308
|
+
const css = tpl.match(/var CHIP_CSS =[\s\S]*?;\n/)[0];
|
|
309
|
+
assert.match(css, /\.likec4-edge-label/);
|
|
310
|
+
assert.match(css, /color:var\(--text\) !important/);
|
|
311
|
+
// transparent, not var(--surface) like the mermaid rule: LikeC4 breaks its edge
|
|
312
|
+
// line around the label, so an opaque chip is a white blob over a compound
|
|
313
|
+
// panel and masks nothing that needed masking.
|
|
314
|
+
assert.match(css, /background:transparent !important/);
|
|
315
|
+
|
|
316
|
+
const fn = tpl.match(/function stripEdgeChips[\s\S]*?\n\}\n/)[0];
|
|
317
|
+
// Nested roots: the label is not in the root c4-view opens, and the inner one
|
|
318
|
+
// is opened later, so descending only once silently reaches nothing.
|
|
319
|
+
assert.match(fn, /walk\(el\.shadowRoot\)/);
|
|
320
|
+
assert.match(tpl, /\[0, 200, 600, 1500, 3000\][\s\S]*?pinEdgeChips/,
|
|
321
|
+
'a shadow root cannot be observed into existence, so the walk has to retry');
|
|
322
|
+
assert.match(tpl, /pinEdgeChips/, 'the helper is never called');
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
// No fill may be semi-transparent any more. An 8-digit hex was how the old
|
|
326
|
+
// tinted fills were built, and it is exactly what LikeC4 cannot reproduce.
|
|
327
|
+
test('no fill is semi-transparent, because LikeC4 has no way to match one', () => {
|
|
328
|
+
const alpha = Object.entries(theme.themeVariables)
|
|
329
|
+
.filter(([, v]) => typeof v === 'string' && /^#[0-9a-f]{8}$/i.test(v));
|
|
330
|
+
assert.deepEqual(alpha, [], '8-digit hex fills cannot be matched by LikeC4');
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
/* ---------- one column ---------- */
|
|
334
|
+
|
|
335
|
+
// Diagrams and wide tables took a 1080px track centred on a 689px prose column,
|
|
336
|
+
// so every one of them started ~190px to the left of the paragraph above it.
|
|
337
|
+
// One column for everything: a block may be narrower than the measure, never
|
|
338
|
+
// wider, and every block shares the same left edge.
|
|
339
|
+
test('nothing breaks out of the content column', () => {
|
|
340
|
+
assert.doesNotMatch(tpl, /var\(--wide\)/);
|
|
341
|
+
assert.doesNotMatch(tpl, /--measure-wide/);
|
|
342
|
+
assert.doesNotMatch(tpl, /is-wide/);
|
|
343
|
+
assert.doesNotMatch(tpl, /sizeTables|sizeCode/);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
// Content-width made every narrow table a different width, so a page of them read
|
|
347
|
+
// as a ragged right edge against a fixed prose column. One width for all of them.
|
|
348
|
+
test('a table fills the column rather than hugging its content', () => {
|
|
349
|
+
const rule = tpl.match(/\n\.table-wrap \{[^}]*\}/)[0];
|
|
350
|
+
assert.match(rule, /width:\s*100%/);
|
|
351
|
+
assert.doesNotMatch(rule, /max-content/, 'content width is what made them ragged');
|
|
352
|
+
assert.match(tpl, /\.table-scroll \{[^}]*overflow-x:\s*auto/);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// Full width is a floor as well as a ceiling, so the cap still has to be there:
|
|
356
|
+
// without it a wide table pushes past the column instead of wrapping its cells,
|
|
357
|
+
// and 15 of the 18 tables in a real set grew a sideways scrollbar inside a
|
|
358
|
+
// vertical read.
|
|
359
|
+
test('a table too wide for the column wraps rather than scrolling sideways', () => {
|
|
360
|
+
const rule = tpl.match(/\ntable \{[\s\S]*?\}/)[0];
|
|
361
|
+
assert.match(rule, /width:\s*100%/);
|
|
362
|
+
assert.match(rule, /max-width:\s*100%/);
|
|
363
|
+
assert.doesNotMatch(rule, /max-content/);
|
|
364
|
+
const th = tpl.match(/\nth \{[\s\S]*?\}/)[0];
|
|
365
|
+
assert.doesNotMatch(th, /white-space:\s*nowrap/, 'a nowrap header sets a floor the cap cannot beat');
|
|
366
|
+
const td = tpl.match(/\ntd \{[\s\S]*?\}/)[0];
|
|
367
|
+
// Seven columns in an 891px measure is ~110px each, narrower than the words in
|
|
368
|
+
// them. `overflow-wrap: anywhere` does remove the resulting scroll — it is the
|
|
369
|
+
// only value min-content sizing reads — but it breaks every cell mid-word, and
|
|
370
|
+
// a table nobody can read is worse than one that scrolls. A tighter scale buys
|
|
371
|
+
// the columns real width instead.
|
|
372
|
+
assert.doesNotMatch(td, /overflow-wrap:\s*anywhere/, 'anywhere breaks cells mid-word');
|
|
373
|
+
assert.match(tpl, /\.table--wide \{[^}]*font-size:\s*12px/);
|
|
374
|
+
assert.match(tpl, /\.table--wide :is\(th, td\) \{[^}]*padding/);
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// LikeC4 fits a view once, at boot, against whatever box it has then. The
|
|
378
|
+
// router reveals a section before the element is upgraded, so that box is zero
|
|
379
|
+
// and the view renders at its natural size — off the edge of a 689px column.
|
|
380
|
+
test('a diagram is refit once its webcomponent boots', () => {
|
|
381
|
+
assert.match(tpl, /whenDefined\('c4-view'\)/);
|
|
382
|
+
assert.match(tpl, /new Event\('resize'\)/);
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
test('a diagram is the width of the column, not of the viewport', () => {
|
|
386
|
+
const rule = tpl.match(/\n\.diagram-shell \{[\s\S]*?\}/)[0];
|
|
387
|
+
assert.doesNotMatch(rule, /margin-left/);
|
|
388
|
+
assert.doesNotMatch(rule, /width:/);
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
/* ---------- scrollbars ---------- */
|
|
392
|
+
|
|
393
|
+
// The platform default is a ~15px grey slab. Inside a code block or a table
|
|
394
|
+
// card that is an object wider than the hairline border around it, and there
|
|
395
|
+
// are a dozen of them in a real set.
|
|
396
|
+
test('every scroll container in the page gets the same thin scrollbar', () => {
|
|
397
|
+
assert.match(tpl, /scrollbar-width:\s*thin/);
|
|
398
|
+
assert.match(tpl, /scrollbar-color:/);
|
|
399
|
+
const bar = tpl.match(/\n::-webkit-scrollbar \{[^}]*\}/)[0];
|
|
400
|
+
assert.match(bar, /width:\s*\d+px/);
|
|
401
|
+
assert.match(bar, /height:\s*\d+px/, 'a horizontal bar needs a height, not a width');
|
|
402
|
+
assert.match(tpl, /::-webkit-scrollbar-thumb \{[^}]*border-radius/);
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
test('the rail does not carry a second, different scrollbar', () => {
|
|
406
|
+
assert.doesNotMatch(tpl, /\.rail-scroll::-webkit-scrollbar/);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
test('the page itself never scrolls sideways', () => {
|
|
410
|
+
assert.match(tpl, /\nbody \{[\s\S]*?overflow-x:\s*clip/);
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
// overflow-x: auto computes the other axis from visible to auto, so the tab bar
|
|
414
|
+
// grew a vertical scrollbar for the 5px its tabs' hit areas stuck out of it.
|
|
415
|
+
test('the view tab bar cannot grow a scrollbar across its short axis', () => {
|
|
416
|
+
const bar = tpl.match(/\.view-tabs__bar \{[\s\S]*?\}/)[0];
|
|
417
|
+
assert.match(bar, /overflow-y:\s*hidden/);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
test('a tab hit area fits inside the bar that holds it', () => {
|
|
421
|
+
const pad = Number(tpl.match(/\.view-tabs__bar \{[\s\S]*?padding:\s*(\d+)px/)[1]);
|
|
422
|
+
const reach = Number(tpl.match(/\.view-tab::after \{[^}]*inset:\s*-(\d+)px/)[1]);
|
|
423
|
+
assert.equal(reach, pad, 'a hit area larger than the padding overflows the bar');
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
/* ---------- page routes ---------- */
|
|
427
|
+
|
|
428
|
+
// A 21-document scroll is not a page. Every document is its own page with its
|
|
429
|
+
// own route and its own progress: #/threat-model is the threat model, not an
|
|
430
|
+
// offset into a scroll that also holds twenty other documents.
|
|
431
|
+
test('one page is in the layout at a time, addressed by its own route', () => {
|
|
432
|
+
assert.match(tpl, /\.page\[hidden\] \{[^}]*display:\s*none/);
|
|
433
|
+
assert.match(tpl, /querySelectorAll\('\.page\[data-route\]'\)/);
|
|
434
|
+
assert.match(tpl, /'#\/'/);
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
test('a bare element id still resolves to the page that holds it', () => {
|
|
438
|
+
// Every in-page anchor the renderer writes is a bare id, and so is every rail
|
|
439
|
+
// link. Routing must not require rewriting them.
|
|
440
|
+
assert.match(tpl, /closest\('\.page'\)/);
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
test('the wider column is not the old prose measure', () => {
|
|
444
|
+
const width = Number(tpl.match(/--measure:\s*min\((\d+)ch/)[1]);
|
|
445
|
+
assert.ok(width >= 90, `${width}ch is still the narrow column`);
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
// A second `--prose` track capping paragraphs to 72ch was tried and reverted.
|
|
449
|
+
// The number is defensible on its own — 96ch renders ~108 characters a line on a
|
|
450
|
+
// real set, against the 66-75 the typographic convention asks for — but every h2
|
|
451
|
+
// here carries a full-width rule and the sections are dense with full-width
|
|
452
|
+
// tables. Capping only the paragraphs left the text ending ~240px short of both,
|
|
453
|
+
// and pushed trailing provenance markers onto their own line. Bringing the line
|
|
454
|
+
// length down means bringing `--measure` down and giving the tables somewhere
|
|
455
|
+
// else to go; it is not a thing paragraphs can be given on their own.
|
|
456
|
+
test('the column is one track, so prose and blocks share both edges', () => {
|
|
457
|
+
assert.doesNotMatch(tpl, /--prose:/, 'a second width track is back');
|
|
458
|
+
assert.match(tpl, /\.doc \{[^}]*max-width:\s*var\(--measure\)/, '.doc owns the column');
|
|
459
|
+
assert.doesNotMatch(tpl, /\.main :is\(p[^)]*\) \{[^}]*max-width/,
|
|
460
|
+
'running prose is capped separately from the blocks it sits between');
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
test('the top bar shows the progress of the open section, not of the whole set', () => {
|
|
464
|
+
const js = tpl.match(/---- reading progress ----[\s\S]*?passive: true \}\)/)[0];
|
|
465
|
+
assert.doesNotMatch(js, /document\.body\.scrollHeight/);
|
|
466
|
+
assert.match(js, /getBoundingClientRect/);
|
|
467
|
+
assert.match(tpl, /id="route-pos"/);
|
|
468
|
+
assert.match(tpl, /\.route-pos \{[^}]*tabular-nums/);
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
// A section shorter than the viewport has nothing to scroll, and "100%" on a
|
|
472
|
+
// page the reader has not touched reads as a bug rather than as a fact.
|
|
473
|
+
test('the readout is blank when the whole section already fits on screen', () => {
|
|
474
|
+
assert.match(tpl, /routePos\.textContent = span > 0 \?/);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
test('the progress line sits on the top bar rather than above it', () => {
|
|
478
|
+
assert.match(tpl, /#progress \{[^}]*top:\s*calc\(var\(--topbar-h\)/);
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// A CSS counter cannot count pages that are not in the layout: with one
|
|
482
|
+
// document on screen the band read "Document 01" on every one of them. The bar
|
|
483
|
+
// carries "2 / 5", which is the thing the number was standing in for.
|
|
484
|
+
test('the document band is gone and the bar carries the position', () => {
|
|
485
|
+
assert.doesNotMatch(tpl, /counter-increment/);
|
|
486
|
+
assert.doesNotMatch(tpl, /counter\(doc/);
|
|
487
|
+
assert.match(tpl, /\.page-pos \{[^}]*tabular-nums/);
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
// `.main a` is (0,1,1) and beats a bare class, so a row, a hit and a chip all
|
|
491
|
+
// grew the prose underline meant for links inside a sentence.
|
|
492
|
+
test('block links are not underlined like words in a sentence', () => {
|
|
493
|
+
const rule = tpl.match(/\.main :is\([^)]*\.record-row[^)]*\) \{[^}]*\}/)[0];
|
|
494
|
+
assert.match(rule, /\.page-chip/);
|
|
495
|
+
assert.match(rule, /text-decoration:\s*none/);
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
test('every page gets a position and prev/next across its own section', () => {
|
|
499
|
+
assert.match(tpl, /page-bar/);
|
|
500
|
+
assert.match(tpl, /data-prev/);
|
|
501
|
+
assert.match(tpl, /data-next/);
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
test('the rail routes from both levels instead of only toggling', () => {
|
|
505
|
+
assert.match(tpl, /data-route/);
|
|
506
|
+
assert.match(tpl, /nav-sec__head'\)/);
|
|
507
|
+
assert.match(tpl, /nav-group__head'\)/);
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
/* ---------- view tabs ---------- */
|
|
511
|
+
|
|
512
|
+
test('view tab groups are styled and only the selected panel shows', () => {
|
|
513
|
+
assert.match(tpl, /\.view-tabs \{/);
|
|
514
|
+
assert.match(tpl, /\.view-tab\[aria-selected="true"\]/);
|
|
515
|
+
assert.match(tpl, /\.view-panel\[hidden\] \{[^}]*display:\s*none/);
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
test('clicking a view tab swaps the panel and moves selection', () => {
|
|
519
|
+
assert.match(tpl, /querySelectorAll\('\.view-tabs'\)/);
|
|
520
|
+
assert.match(tpl, /ArrowRight/, 'tablist must be keyboard navigable');
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
/* ---------- definition grids and dead references ---------- */
|
|
524
|
+
|
|
525
|
+
test('definition grids lay out as a grid, not a stack of rows', () => {
|
|
526
|
+
const rule = tpl.match(/\n\.def-grid \{[^}]*\}/)[0];
|
|
527
|
+
assert.match(rule, /display:\s*grid/);
|
|
528
|
+
assert.match(rule, /repeat\(auto-fill/);
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
test('a definition term outranks its body without being a heading', () => {
|
|
532
|
+
assert.match(tpl, /\.def dt \{/);
|
|
533
|
+
assert.match(tpl, /\.def dd \{/);
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
// A reference the viewer does not contain is rendered as text, so it must not
|
|
537
|
+
// borrow the link colour — that is the whole point of unwrapping it.
|
|
538
|
+
test('an external reference is visually distinct from a live link', () => {
|
|
539
|
+
const rule = tpl.match(/\n\.ext-ref \{[^}]*\}/)[0];
|
|
540
|
+
assert.doesNotMatch(rule, /var\(--accent\)/);
|
|
541
|
+
assert.match(rule, /var\(--font-mono\)/);
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
/* ---------- routed sections ---------- */
|
|
545
|
+
|
|
546
|
+
test('a section with an index is browsed from it', () => {
|
|
547
|
+
assert.match(tpl, /querySelectorAll\('\.doc-section\[data-routed\]'\)/);
|
|
548
|
+
assert.match(tpl, /dataset\.landing/);
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
test('the router reads and writes the hash so deep links survive', () => {
|
|
552
|
+
assert.match(tpl, /hashchange/);
|
|
553
|
+
assert.match(tpl, /location\.hash/);
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
test('a record inside an indexed section also gets a link back to the index', () => {
|
|
557
|
+
assert.match(tpl, /data-back/);
|
|
558
|
+
assert.match(tpl, /'\u2039 All records'/);
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
// The author's own index is prose and goes stale. This set's docs/adr/README.md
|
|
562
|
+
// lists four records by filenames the repository never had; behind a routed
|
|
563
|
+
// section that hid the other eleven completely. So it is counted, not assumed.
|
|
564
|
+
test('the index lists every record when the author list does not', () => {
|
|
565
|
+
assert.match(tpl, /record-list/);
|
|
566
|
+
assert.match(tpl, /linksAll/);
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
// Hiding 15 of 17 documents breaks Ctrl+F across them. The text is still in the
|
|
570
|
+
// DOM, so the index searches it directly and names the record that matched.
|
|
571
|
+
test('the index searches the bodies of the records it hides', () => {
|
|
572
|
+
assert.match(tpl, /record-search/);
|
|
573
|
+
assert.match(tpl, /record-hits/);
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
test('a deep link into a hidden record opens it before scrolling', () => {
|
|
577
|
+
assert.match(tpl, /showPage/);
|
|
578
|
+
assert.match(tpl, /scrollIntoView|scrollTo/);
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
// "One index page with comprehensive information" — a list of titles is not
|
|
582
|
+
// comprehensive. Each record states its own status under a Status heading, so
|
|
583
|
+
// the index can total them without the renderer parsing anything.
|
|
584
|
+
test('the index totals the statuses of the records it lists', () => {
|
|
585
|
+
assert.match(tpl, /record-summary/);
|
|
586
|
+
assert.match(tpl, /statusOf/);
|
|
587
|
+
assert.match(tpl, /'status'/);
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
test('the search box goes after the index prose, not between it and the title', () => {
|
|
591
|
+
assert.match(tpl, /tagName === 'P'/);
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// The record bar sits above the record's title, so scrolling to the title
|
|
595
|
+
// itself puts the bar off screen and the reader loses prev/next.
|
|
596
|
+
test('landing on a page scrolls to the page, not past its bar', () => {
|
|
597
|
+
assert.match(tpl, /\.page \{[^}]*scroll-margin-top/);
|
|
598
|
+
assert.match(tpl, /classList\.contains\('doc-head'\)/);
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
// One record in a real set writes "**Status:** Accepted" as an inline label in
|
|
602
|
+
// its header block instead of under a Status heading. Both conventions count.
|
|
603
|
+
test('the status total reads an inline Status label as well as a heading', () => {
|
|
604
|
+
assert.match(tpl, /Status:\\s\*\(\[A-Za-z\]\+\)|Status:\\s\*/);
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
/* ---------- record drawer ---------- */
|
|
608
|
+
|
|
609
|
+
// §14 Decisions tables every ADR, so a Decision Records rail section was the same
|
|
610
|
+
// set a second time. A record now opens over the page that referenced it — the
|
|
611
|
+
// reader keeps the row they clicked from in view behind the panel.
|
|
612
|
+
test('the drawer exists as chrome, with a scrim and a close control', () => {
|
|
613
|
+
assert.match(tpl, /id="drawer"/);
|
|
614
|
+
assert.match(tpl, /id="drawer-scrim"/);
|
|
615
|
+
assert.match(tpl, /id="drawer-close"/);
|
|
616
|
+
assert.match(tpl, /aria-label="Close record"/);
|
|
617
|
+
// A dialog, not a div: the role is what tells a screen reader the page behind it
|
|
618
|
+
// is not the thing to read.
|
|
619
|
+
assert.match(tpl, /id="drawer"[^>]*role="dialog"/);
|
|
620
|
+
assert.match(tpl, /id="drawer"[^>]*aria-modal="true"/);
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
test('the drawer slides rather than appearing, and is off-screen when shut', () => {
|
|
624
|
+
const rule = tpl.match(/\n#drawer \{[^}]*\}/)[0];
|
|
625
|
+
assert.match(rule, /position:\s*fixed/);
|
|
626
|
+
assert.match(rule, /transform:\s*translateX\(100%\)/);
|
|
627
|
+
assert.match(rule, /transition:[^;]*transform/);
|
|
628
|
+
assert.match(tpl, /#drawer\.is-open \{[^}]*translateX\(0\)/);
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
// The record moves into the drawer rather than being cloned: a clone duplicates
|
|
632
|
+
// every heading id in it, and the first getElementById after that resolves to the
|
|
633
|
+
// copy nobody can see.
|
|
634
|
+
test('the record is moved into the drawer and put back on close', () => {
|
|
635
|
+
const fn = tpl.match(/function openDrawer[\s\S]*?\n\}/)[0];
|
|
636
|
+
assert.match(fn, /appendChild\(page\)/);
|
|
637
|
+
assert.doesNotMatch(fn, /cloneNode/);
|
|
638
|
+
const close = tpl.match(/function closeDrawer[\s\S]*?\n\}/)[0];
|
|
639
|
+
assert.match(close, /appendChild/, 'the record has to go back where it came from');
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
// The hash is the point: a drawer nobody can link to cannot be pasted to a
|
|
643
|
+
// colleague or survive a reload.
|
|
644
|
+
test('opening a record puts its own route in the hash', () => {
|
|
645
|
+
// Every anchor the renderer writes is a bare element id, and the router resolves
|
|
646
|
+
// either form — but left alone the address bar would read
|
|
647
|
+
// #doc-adr-0002-multi-tenancy while the panel says ADR 0002, and neither is the
|
|
648
|
+
// route somebody would paste.
|
|
649
|
+
assert.match(tpl, /location\.hash = '#\/' \+ page\.dataset\.route/);
|
|
650
|
+
const nav = tpl.match(/function navigate\([\s\S]*?\n\}/)[0];
|
|
651
|
+
assert.match(nav, /openDrawer/);
|
|
652
|
+
assert.match(nav, /closeDrawer/);
|
|
653
|
+
// The host page has to be in the layout before the record goes over it, or a
|
|
654
|
+
// cold load at #/0002 opens the drawer onto nothing.
|
|
655
|
+
assert.ok(nav.indexOf('showPage(page)') < nav.indexOf('openDrawer('),
|
|
656
|
+
'the record must open after its host page is shown');
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
// Escape and Back are the two ways every drawer on the web closes; a panel that
|
|
660
|
+
// traps the reader is worse than no panel.
|
|
661
|
+
test('escape, the scrim and the close button all leave by the same path', () => {
|
|
662
|
+
assert.match(tpl, /key === 'Escape' && openRecord\) leaveRecord\(\)/);
|
|
663
|
+
assert.match(tpl, /drawerScrim\.addEventListener\('click', leaveRecord\)/);
|
|
664
|
+
assert.match(tpl, /drawerClose\.addEventListener\('click', leaveRecord\)/);
|
|
665
|
+
// Closing goes through the hash, so Back does the same thing by the ordinary
|
|
666
|
+
// route and the panel can never disagree with the address bar.
|
|
667
|
+
const leave = tpl.match(/function leaveRecord[\s\S]*?\n\}/)[0];
|
|
668
|
+
assert.match(leave, /closeDrawer\(\)/);
|
|
669
|
+
assert.match(leave, /location\.hash/);
|
|
670
|
+
assert.match(tpl, /hashchange/);
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
// A record left hidden by the page router would open into an empty drawer.
|
|
674
|
+
test('the page router leaves record pages alone', () => {
|
|
675
|
+
const show = tpl.match(/function showPage\([\s\S]*?\n\}/)[0];
|
|
676
|
+
assert.match(show, /if \(!isRecord\(p\)\) p\.hidden/,
|
|
677
|
+
'hiding a record that is in the drawer opens an empty drawer');
|
|
678
|
+
// A record belongs to the section it came from, which is how it gets put back.
|
|
679
|
+
assert.match(tpl, /recordHome\.set\(p, sec\)/);
|
|
680
|
+
assert.match(tpl, /recordHome\.get\(openRecord\)\.appendChild/);
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
// Closing a record went through the host page's own route, and the router treats
|
|
684
|
+
// any route without an element id as "new page, start at the top" — so Escape
|
|
685
|
+
// threw the reader from §14 back to §1, and Back did the same. A route that
|
|
686
|
+
// resolves to the page already on screen is not a move.
|
|
687
|
+
test('closing a record leaves the host page where the reader left it', () => {
|
|
688
|
+
const nav = tpl.match(/function navigate\([\s\S]*?\n\}/)[0];
|
|
689
|
+
assert.match(nav, /var moved = page !== activePage/);
|
|
690
|
+
assert.match(nav, /if \(moved\) scrollTo\(/);
|
|
691
|
+
assert.doesNotMatch(nav, /\n\s*\{ scrollTo\(/,
|
|
692
|
+
'an unconditional jump to the top is what lost the reader their place');
|
|
693
|
+
// showPage assigns activePage, so the comparison has to happen before it.
|
|
694
|
+
assert.ok(nav.indexOf('var moved') < nav.indexOf('showPage(page)'),
|
|
695
|
+
'moved must be computed before showPage overwrites activePage');
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
/* ---------- state, focus, and the drawer's own label ---------- */
|
|
699
|
+
|
|
700
|
+
// The pill painted Accepted, Proposed and Superseded identically — text-faint on
|
|
701
|
+
// surface-3 — so the two records still up for decision in a set of fifteen looked
|
|
702
|
+
// exactly like the thirteen that were settled. statusOf() already extracts the
|
|
703
|
+
// leading word; nothing was reading it.
|
|
704
|
+
test('a status pill encodes which status it is', () => {
|
|
705
|
+
assert.match(tpl, /\.record-row__s\[data-status="proposed"\]/);
|
|
706
|
+
assert.match(tpl, /\.record-row__s\[data-status="superseded"\]/);
|
|
707
|
+
assert.match(tpl, /\.record-row__s\[data-status="unrecorded"\]/);
|
|
708
|
+
// Semantic colour is its own scale, not the teal accent: the accent already
|
|
709
|
+
// means "link or brand" everywhere else in the page.
|
|
710
|
+
assert.match(tpl, /--state-open:/);
|
|
711
|
+
assert.match(tpl, /--state-stop:/);
|
|
712
|
+
assert.doesNotMatch(tpl, /data-status="proposed"\] \{[^}]*var\(--accent\)/);
|
|
713
|
+
// Both themes, or the ochre that reads on cream disappears on near-black.
|
|
714
|
+
assert.ok(tpl.match(/--state-open:/g).length >= 2, 'state colours need a dark set too');
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
test('a superseded record is struck through, not merely recoloured', () => {
|
|
718
|
+
const rule = tpl.match(/\.record-row__s\[data-status="superseded"\][^{]*\{[^}]*\}/)[0];
|
|
719
|
+
assert.match(rule, /line-through/);
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
// An absent status is not a status. An outline says "nothing recorded here" where
|
|
723
|
+
// a filled pill would claim a value the record never gave.
|
|
724
|
+
test('an unrecorded status reads as absence', () => {
|
|
725
|
+
const rule = tpl.match(/\.record-row__s\[data-status="unrecorded"\][^{]*\{[^}]*\}/)[0];
|
|
726
|
+
assert.match(rule, /dashed/);
|
|
727
|
+
assert.match(rule, /background:\s*none|background:\s*transparent/);
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
test('the pill carries the status it is painted from', () => {
|
|
731
|
+
assert.match(tpl, /status\.dataset\.status = /);
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
// role="dialog" aria-modal="true" with focus left outside it: a keyboard reader
|
|
735
|
+
// opened a record and their next Tab walked the page behind the scrim. `inert`
|
|
736
|
+
// does the containment the manual trap would, and takes the page out of the
|
|
737
|
+
// accessibility tree at the same time.
|
|
738
|
+
test('the drawer takes focus and gives it back', () => {
|
|
739
|
+
const open = tpl.match(/function openDrawer[\s\S]*?\n\}/)[0];
|
|
740
|
+
assert.match(open, /document\.activeElement/, 'nothing remembers where focus came from');
|
|
741
|
+
assert.match(open, /\.focus\(\)/);
|
|
742
|
+
const close = tpl.match(/function closeDrawer[\s\S]*?\n\}/)[0];
|
|
743
|
+
assert.match(close, /\.focus\(\)/, 'focus has to return to the row that opened it');
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
test('the page behind the drawer is inert while it is open', () => {
|
|
747
|
+
assert.match(tpl, /function setBehindInert/);
|
|
748
|
+
assert.match(tpl, /\.inert = /);
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
// A 90-char ADR title in 10.5px uppercase letter-spaced mono is an eyebrow
|
|
752
|
+
// treatment applied to a paragraph. The H1 two lines below already says it.
|
|
753
|
+
test('the drawer bar names the record rather than repeating its title', () => {
|
|
754
|
+
assert.match(tpl, /function recordLabel/);
|
|
755
|
+
const fn = tpl.match(/function recordLabel[\s\S]*?\n\}/)[0];
|
|
756
|
+
assert.match(fn, /split\(':'\)/);
|
|
757
|
+
// The full title is still the dialog's accessible name.
|
|
758
|
+
assert.match(tpl, /drawerEl\.setAttribute\('aria-label'/);
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
test('the drawer bar shows the record status beside its name', () => {
|
|
762
|
+
assert.match(tpl, /id="drawer-status"/);
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
// The four provenance words are a closed vocabulary and now render as their own
|
|
766
|
+
// element; they need a treatment that is not the code chip they used to borrow.
|
|
767
|
+
test('a provenance marker is styled as evidence, not as code', () => {
|
|
768
|
+
assert.match(tpl, /\.prov \{/);
|
|
769
|
+
const rule = tpl.match(/\.prov \{[^}]*\}/)[0];
|
|
770
|
+
assert.doesNotMatch(rule, /var\(--accent-soft\)/, 'that is the code chip it was mistaken for');
|
|
771
|
+
});
|
|
772
|
+
|
|
773
|
+
// ---------------------------------------------------------------------------
|
|
774
|
+
// Robustness and consistency pass. Each of these was a rule the template states
|
|
775
|
+
// somewhere else and then breaks here, or a failure with no visible state.
|
|
776
|
+
// ---------------------------------------------------------------------------
|
|
777
|
+
|
|
778
|
+
const ref = readFileSync(new URL('../../references/viewer.md', import.meta.url), 'utf8');
|
|
779
|
+
|
|
780
|
+
// `overflow-x: auto` computes overflow-y from `visible` to `auto` — the same fact
|
|
781
|
+
// the tab bar's rule already documents. So .table-scroll is a scrollport, and
|
|
782
|
+
// without a height it never scrolls: the sticky header sticks to a box that
|
|
783
|
+
// cannot move, and a 40-row table scrolls its heading off under the top bar.
|
|
784
|
+
test('a table taller than the screen keeps its header in view', () => {
|
|
785
|
+
const scroll = tpl.match(/\.table-scroll \{[\s\S]*?\}/)[0];
|
|
786
|
+
assert.match(scroll, /max-height:/, 'a scrollport with no height never scrolls');
|
|
787
|
+
assert.match(tpl, /\nth \{[\s\S]*?position:\s*sticky/);
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
// The boot script runs before the body paints. localStorage throws when site
|
|
791
|
+
// data is blocked and in some file:// contexts, and this viewer is meant to open
|
|
792
|
+
// by double-click off a filesystem — an unguarded throw loses the theme and
|
|
793
|
+
// every script after it.
|
|
794
|
+
test('a blocked or file:// localStorage cannot stop the page painting', () => {
|
|
795
|
+
const uses = [...tpl.matchAll(/localStorage\.\w+/g)];
|
|
796
|
+
assert.ok(uses.length >= 2, 'the theme is still read and written');
|
|
797
|
+
for (const use of uses) {
|
|
798
|
+
const before = tpl.slice(Math.max(0, use.index - 300), use.index);
|
|
799
|
+
assert.match(before, /try\s*\{/, `unguarded ${use[0]}`);
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
// mermaid.render rejects on a syntax error. Unhandled, the element keeps its raw
|
|
804
|
+
// source text and the reader sees a slab of DSL in a diagram shell.
|
|
805
|
+
test('a diagram that fails to render says so instead of going blank', () => {
|
|
806
|
+
const fn = tpl.match(/async function renderMermaid[\s\S]*?\n\}/)[0];
|
|
807
|
+
assert.match(fn, /catch/);
|
|
808
|
+
assert.match(tpl, /\.diagram-error/);
|
|
809
|
+
});
|
|
810
|
+
|
|
811
|
+
// The 2px accent ring is the one focus treatment every interactive surface
|
|
812
|
+
// gets. Each entry here is a real tab stop with its own :focus-visible rule.
|
|
813
|
+
test('every interactive surface shows the same focus ring', () => {
|
|
814
|
+
const surfaces = [
|
|
815
|
+
'.nav-link', '.icon-btn', '.view-tab', '.page-chip', '.record-row',
|
|
816
|
+
'.record-hit', '.nav-sec__head', '.nav-group__head',
|
|
817
|
+
'.diagram-toolbar button', '.diagram-viewport', '.help-btn',
|
|
818
|
+
];
|
|
819
|
+
for (const sel of surfaces) {
|
|
820
|
+
assert.match(tpl, new RegExp(`\\${sel}[^{]*:focus-visible`), `${sel} has no focus ring`);
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
// .main is already offset by the rail and its own padding, so subtracting them
|
|
825
|
+
// again from 100vw restates the layout — and 100vw counts the scrollbar gutter,
|
|
826
|
+
// clipping ~15px of every block on Windows and Linux.
|
|
827
|
+
test('the measure is the column it sits in, not the viewport minus the rail', () => {
|
|
828
|
+
const measure = tpl.match(/--measure:[^;]+;/)[0];
|
|
829
|
+
assert.doesNotMatch(measure, /100vw/, 'includes the scrollbar gutter');
|
|
830
|
+
assert.match(measure, /min\(96ch,\s*100%\)/);
|
|
831
|
+
const narrow = tpl.match(/@media \(max-width: 960px\) \{[\s\S]*?\n\}/)[0];
|
|
832
|
+
assert.doesNotMatch(narrow, /--measure:/, '96ch already loses to 100% at this width');
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
// Without a declared scheme the browser paints the canvas white before the boot
|
|
836
|
+
// script runs, so a dark-mode reader gets a flash — and the UA scrollbar and the
|
|
837
|
+
// search field's clear button stay light inside a dark page.
|
|
838
|
+
test('the head states its colour scheme, its icon and its description', () => {
|
|
839
|
+
assert.match(tpl, /<meta name="color-scheme" content="light dark">/);
|
|
840
|
+
assert.match(tpl, /<link rel="icon"[^>]*data:image\/svg\+xml/);
|
|
841
|
+
assert.match(tpl, /<meta name="description"/);
|
|
842
|
+
});
|
|
843
|
+
|
|
844
|
+
test('the scroll spy reads the bar height rather than restating it', () => {
|
|
845
|
+
assert.doesNotMatch(tpl, /'-' \+ \(60\) \+ 'px/);
|
|
846
|
+
assert.match(tpl, /getPropertyValue\('--topbar-h'\)/);
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
test('no rule is declared twice', () => {
|
|
850
|
+
const preCode = tpl.match(/^pre code \{/gm) || [];
|
|
851
|
+
assert.equal(preCode.length, 1, `pre code declared ${preCode.length} times`);
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
// The reference describes the rejected design: content-width tables were what
|
|
855
|
+
// gave a page of them a ragged right edge, and the template has shipped a single
|
|
856
|
+
// full width for a while.
|
|
857
|
+
test('the viewer reference describes the table rule the template ships', () => {
|
|
858
|
+
assert.doesNotMatch(ref, /width:\s*max-content/);
|
|
859
|
+
assert.match(tpl.match(/\ntable \{[\s\S]*?\}/)[0], /width:\s*100%/);
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
// Step 2 used to say: npm pack mermaid, read the built ESM off disk, splice it
|
|
863
|
+
// in. Mermaid 11.x ships code-split ESM — no single file on disk carries the
|
|
864
|
+
// whole library, and none of them leaves a top-level `mermaid` binding once
|
|
865
|
+
// inlined, which is the one thing the template's init line needs. The procedure
|
|
866
|
+
// could not be followed, and nothing failed until a human tried it.
|
|
867
|
+
test('the documented mermaid bundle step produces the bindings the template needs', () => {
|
|
868
|
+
const entry = ref.match(/```js\n([^`]*globalThis\.mermaid[^`]*)```/);
|
|
869
|
+
assert.ok(entry, 'no entry file is shown that binds mermaid globally');
|
|
870
|
+
assert.match(entry[1], /globalThis\.mermaid\s*=/);
|
|
871
|
+
assert.match(entry[1], /globalThis\.elkLayouts\s*=/);
|
|
872
|
+
const cmd = ref.match(/npx esbuild[^\n]*/);
|
|
873
|
+
assert.ok(cmd, 'no bundling command is given');
|
|
874
|
+
assert.match(cmd[0], /--bundle/);
|
|
875
|
+
// IIFE, not esm: an inlined `export` has nothing to bind to, which is the
|
|
876
|
+
// failure the old wording walked into.
|
|
877
|
+
assert.match(cmd[0], /--format=iife/);
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
test('the reference no longer claims the ESM ships ready to splice', () => {
|
|
881
|
+
const step = ref.match(/\n2\. \*\*[\s\S]*?\n3\. \*\*/)[0];
|
|
882
|
+
assert.doesNotMatch(step, /read the built ESM file\s*\n?\s*off disk/);
|
|
883
|
+
// `npm pack` was the whole of the old procedure. Naming it as the source of a
|
|
884
|
+
// spliceable file is the same instruction under another verb.
|
|
885
|
+
assert.doesNotMatch(step, /`npm pack`[^\n]*then read/);
|
|
886
|
+
assert.match(step, /code-split/, 'the reason a bundling step exists is the fact worth keeping');
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
// ---------------------------------------------------------------------------
|
|
890
|
+
// Pinning a diagram. Diagrams are the payload of an architecture set and they
|
|
891
|
+
// sit inline in the flow, so scrolling to the paragraph that explains a
|
|
892
|
+
// container scrolls the container view off the screen. Expand and fullscreen
|
|
893
|
+
// both cover the prose, which answers a different question.
|
|
894
|
+
// ---------------------------------------------------------------------------
|
|
895
|
+
|
|
896
|
+
test('the diagram toolbar offers a pin', () => {
|
|
897
|
+
const bar = tpl.match(/function buildToolbar[\s\S]*?\n\}/)[0];
|
|
898
|
+
assert.match(bar, /data-pin/);
|
|
899
|
+
assert.match(bar, /data-pin aria-pressed="false"/, 'a toggle has to say which way it is');
|
|
900
|
+
});
|
|
901
|
+
|
|
902
|
+
test('a pinned diagram stops scrolling with the document', () => {
|
|
903
|
+
const rule = tpl.match(/\.diagram-shell\.is-pinned \{[^}]*\}/)[0];
|
|
904
|
+
assert.match(rule, /position:\s*fixed/);
|
|
905
|
+
assert.match(rule, /width:\s*var\(--pin-w\)/);
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
// A fixed pane over the column would cover the prose it was pinned to read
|
|
909
|
+
// alongside, which is the whole point lost.
|
|
910
|
+
test('the pinned pane is given its own gutter rather than covering the column', () => {
|
|
911
|
+
assert.match(tpl, /body\.has-pin \.main \{[^}]*padding-right/);
|
|
912
|
+
});
|
|
913
|
+
|
|
914
|
+
// Removing 320px+ from the flow shortens the document under the reader, and the
|
|
915
|
+
// browser keeps the scroll offset — so the page jumps by the height of whatever
|
|
916
|
+
// was pinned.
|
|
917
|
+
test('the vacated space is held open while a diagram is pinned', () => {
|
|
918
|
+
assert.match(tpl, /\.diagram-slot \{/);
|
|
919
|
+
const js = tpl.match(/function slotFor[\s\S]*?\n\}/)[0];
|
|
920
|
+
assert.match(js, /offsetHeight/, 'the placeholder has to be the height it replaced');
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
test('pinning a second diagram releases the first', () => {
|
|
924
|
+
const fn = tpl.match(/function pinDiagram[\s\S]*?\n\}/)[0];
|
|
925
|
+
assert.match(fn, /unpinDiagram\(\)/, 'nothing releases the diagram already pinned');
|
|
926
|
+
});
|
|
927
|
+
|
|
928
|
+
// The same exit the expand overlay got, for the same reason: a state entered by
|
|
929
|
+
// a button the reader has since scrolled away from needs a key that always works.
|
|
930
|
+
// Anchored on the diagram handler by name: there is a second Escape listener for
|
|
931
|
+
// the rail filter, and a generic `e.key !== 'Escape'` match finds whichever the
|
|
932
|
+
// file happens to declare first.
|
|
933
|
+
test('escape releases a pinned diagram', () => {
|
|
934
|
+
const handler = tpl.match(/if \(e\.key !== 'Escape'\) return;[\s\S]*?is-expanded[\s\S]*?\n\}\);/)[0];
|
|
935
|
+
assert.match(handler, /unpinDiagram\(\)/);
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
// Paper has no viewport to pin against. A fixed pane prints once, over page one.
|
|
939
|
+
test('print puts a pinned diagram back in the flow', () => {
|
|
940
|
+
const print = tpl.match(/@media print \{[\s\S]*?\n\}/)[0];
|
|
941
|
+
assert.match(print, /\.is-pinned[^}]*position:\s*static/);
|
|
942
|
+
assert.match(print, /\.diagram-slot[^}]*display:\s*none/);
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
// Below the breakpoint the column already has the screen to itself, so there is
|
|
946
|
+
// no gutter to put a pane in — offering the control would promise a layout the
|
|
947
|
+
// viewport cannot give.
|
|
948
|
+
test('the pin is withdrawn where there is no room for a pane', () => {
|
|
949
|
+
const narrow = tpl.match(/@media \(max-width: 1200px\) \{[\s\S]*?\n\}/);
|
|
950
|
+
assert.ok(narrow, 'no breakpoint withdraws the pin');
|
|
951
|
+
assert.match(narrow[0], /\[data-pin\][^}]*display:\s*none/);
|
|
952
|
+
assert.match(narrow[0], /\.diagram-shell\.is-pinned[^}]*position:\s*(relative|static)/,
|
|
953
|
+
'a diagram pinned before the resize stays stuck to a viewport with no gutter');
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
// The cap that makes the sticky header work is a screen affordance: paper has no
|
|
957
|
+
// scrollport, so a table taller than it would simply lose its last rows.
|
|
958
|
+
test('a capped table is uncapped for print', () => {
|
|
959
|
+
const print = tpl.match(/@media print \{[\s\S]*?\n\}/)[0];
|
|
960
|
+
assert.match(print, /\.table-scroll[^}]*max-height:\s*none/);
|
|
961
|
+
});
|
|
962
|
+
|
|
963
|
+
// ---------------------------------------------------------------------------
|
|
964
|
+
// Reaching the page without a mouse, and reaching a diagram without either a
|
|
965
|
+
// mouse or a keyboard-shaped assumption about who is reading.
|
|
966
|
+
// ---------------------------------------------------------------------------
|
|
967
|
+
|
|
968
|
+
// DOM order is topbar, rail, prose. A real set puts ~120 rail links between the
|
|
969
|
+
// two, and a keyboard reader had to walk every one of them to reach a sentence.
|
|
970
|
+
test('a keyboard reader can reach the document without walking the rail', () => {
|
|
971
|
+
assert.match(tpl, /class="skip"[^>]*href="#main-content"/);
|
|
972
|
+
assert.match(tpl, /<main[^>]*id="main-content"/);
|
|
973
|
+
// Focus has to be able to land there, or the link moves the viewport and
|
|
974
|
+
// leaves the tab position back up in the rail.
|
|
975
|
+
assert.match(tpl, /<main[^>]*tabindex="-1"/);
|
|
976
|
+
const body = tpl.slice(tpl.indexOf('<body>'));
|
|
977
|
+
assert.ok(body.indexOf('class="skip"') < body.indexOf('<button'),
|
|
978
|
+
'the skip link is not the first focusable thing in the body');
|
|
979
|
+
});
|
|
980
|
+
|
|
981
|
+
// It sits outside .main, so the drawer's own inert call does not cover it — and
|
|
982
|
+
// a skip link that works from behind a modal scrim lands the reader nowhere.
|
|
983
|
+
test('the skip link goes inert with the rest of the page behind a record', () => {
|
|
984
|
+
const fn = tpl.match(/function setBehindInert[\s\S]*?\n\}/)[0];
|
|
985
|
+
assert.match(fn, /\.skip/);
|
|
986
|
+
});
|
|
987
|
+
|
|
988
|
+
// The mouse pair never fires for touch, so a diagram on a phone could be zoomed
|
|
989
|
+
// and then not moved. Capture also retires the two document-level listeners this
|
|
990
|
+
// added once per diagram.
|
|
991
|
+
test('a diagram pans by pointer capture rather than by mouse events', () => {
|
|
992
|
+
assert.match(tpl, /pointerdown/);
|
|
993
|
+
assert.match(tpl, /setPointerCapture/);
|
|
994
|
+
assert.doesNotMatch(tpl, /addEventListener\('mousedown'/);
|
|
995
|
+
assert.doesNotMatch(tpl, /addEventListener\('mousemove'/);
|
|
996
|
+
});
|
|
997
|
+
|
|
998
|
+
// `touch-action: none` on a diagram sitting at 1:1 eats the page scroll of any
|
|
999
|
+
// reader whose finger happens to land on it while reading.
|
|
1000
|
+
test('touch panning is claimed only when there is something to pan', () => {
|
|
1001
|
+
assert.match(tpl, /\.diagram-viewport\.is-pannable[^{]*\{[^}]*touch-action:\s*none/);
|
|
1002
|
+
assert.match(tpl, /function pannable/);
|
|
1003
|
+
const base = tpl.match(/\n\.diagram-viewport \{[\s\S]*?\}/)[0];
|
|
1004
|
+
assert.doesNotMatch(base, /cursor:\s*grab/, 'a grab cursor promises movement that cannot happen');
|
|
1005
|
+
});
|
|
1006
|
+
|
|
1007
|
+
test('a zoomed diagram can be panned from the keyboard', () => {
|
|
1008
|
+
assert.match(tpl, /viewport\.tabIndex\s*=\s*0/);
|
|
1009
|
+
assert.match(tpl, /ArrowLeft/);
|
|
1010
|
+
// At 1:1 the arrows belong to the page: a reader who tabbed into a diagram on
|
|
1011
|
+
// the way down the document must not find their scroll keys taken.
|
|
1012
|
+
const keys = tpl.match(/function wireKeys[\s\S]*?\n\}/)[0];
|
|
1013
|
+
assert.match(keys, /is-pannable/);
|
|
1014
|
+
assert.match(tpl, /\.diagram-viewport:focus-visible/);
|
|
1015
|
+
// The viewport is built in script, so its name is set rather than written.
|
|
1016
|
+
assert.match(tpl, /setAttribute\('aria-label',[\s\S]{0,40}'Diagram\. Arrow keys pan/);
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
// The fullscreen path gets Escape from the browser. The expand path is an
|
|
1020
|
+
// ordinary fixed overlay covering the viewport, and had no way out but the
|
|
1021
|
+
// button that opened it.
|
|
1022
|
+
test('the expand overlay can be left by Escape and reports its state', () => {
|
|
1023
|
+
assert.match(tpl, /data-expand aria-pressed="false"/);
|
|
1024
|
+
// Named against the expanded-shell query, because the rail filter now has an
|
|
1025
|
+
// Escape guard of its own and it comes first in the file.
|
|
1026
|
+
assert.match(tpl,
|
|
1027
|
+
/if \(e\.key !== 'Escape'\) return;[\s\S]{0,240}?querySelectorAll\('\.diagram-shell\.is-expanded'\)/,
|
|
1028
|
+
'no Escape handler for the expanded overlay');
|
|
1029
|
+
});
|
|
1030
|
+
|
|
1031
|
+
// ---------------------------------------------------------------------------
|
|
1032
|
+
// Searching and printing the set rather than the page that happens to be open.
|
|
1033
|
+
// ---------------------------------------------------------------------------
|
|
1034
|
+
|
|
1035
|
+
// Ctrl+F reaches the open page; a routed section's index reaches its records.
|
|
1036
|
+
// Every other document in the set was reachable by neither — the rail filter
|
|
1037
|
+
// only ever matched heading labels.
|
|
1038
|
+
test('the whole set is searchable, not only the page on screen', () => {
|
|
1039
|
+
assert.match(tpl, /docText/);
|
|
1040
|
+
const grp = tpl.match(/function filterGroup[\s\S]*?\n\}/)[0];
|
|
1041
|
+
assert.match(grp, /docText|bodyHas/, 'the rail filter still reads headings only');
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
// The bar prepends "All records 3 / 15 Prev Next" to every page. Captured after
|
|
1045
|
+
// it, those become words the filter matches in every document at once.
|
|
1046
|
+
test('document text is captured before the page bars are prepended', () => {
|
|
1047
|
+
const captured = tpl.indexOf('docText.set');
|
|
1048
|
+
const bars = tpl.indexOf('barEl(walk, i');
|
|
1049
|
+
assert.ok(captured > 0, 'nothing captures document text');
|
|
1050
|
+
assert.ok(captured < bars, 'document text is captured after the bars are added');
|
|
1051
|
+
});
|
|
1052
|
+
|
|
1053
|
+
// The reader typed a phrase and got back a row whose visible labels do not
|
|
1054
|
+
// contain it. Unexplained, that row reads as a bug in the filter.
|
|
1055
|
+
test('a document matched only on its body text says so', () => {
|
|
1056
|
+
assert.match(tpl, /is-body-hit/);
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
test('a record search with no hits says so rather than going blank', () => {
|
|
1060
|
+
assert.match(tpl, /record-empty/);
|
|
1061
|
+
});
|
|
1062
|
+
|
|
1063
|
+
// Every page is already in the DOM, only hidden. Paper has no router.
|
|
1064
|
+
test('printing prints the whole set, not the page on screen', () => {
|
|
1065
|
+
const print = tpl.match(/@media print \{[\s\S]*?\n\}/)[0];
|
|
1066
|
+
assert.match(print, /\.doc-section\[hidden\]/);
|
|
1067
|
+
assert.match(print, /\.page-bar/, 'prev/next chips are navigation, not content');
|
|
1068
|
+
assert.match(print, /#drawer/, 'an open record prints from the drawer or not at all');
|
|
1069
|
+
});
|
|
1070
|
+
|
|
1071
|
+
test('the filter is one keystroke away and Escape leaves it', () => {
|
|
1072
|
+
assert.match(tpl, /e\.key === '\/'/);
|
|
1073
|
+
assert.match(tpl, /e\.metaKey \|\| e\.ctrlKey/);
|
|
1074
|
+
const esc = tpl.match(/filter\.addEventListener\('keydown'[\s\S]*?\n\}\);/)[0];
|
|
1075
|
+
assert.match(esc, /Escape/);
|
|
1076
|
+
// The same key closes the mobile rail and any open record, and a reader
|
|
1077
|
+
// clearing a search asked for neither.
|
|
1078
|
+
assert.match(esc, /stopPropagation/);
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
// ---------------------------------------------------------------------------
|
|
1082
|
+
// Diagram state the reader can see, movement they cannot lose, and a router
|
|
1083
|
+
// that does not animate its way across a document nobody asked to read.
|
|
1084
|
+
// ---------------------------------------------------------------------------
|
|
1085
|
+
|
|
1086
|
+
// The button said 1:1 at every zoom level, so the only readout of the diagram's
|
|
1087
|
+
// state was the diagram, and the only way to learn what the button did was to
|
|
1088
|
+
// press it.
|
|
1089
|
+
test('the zoom control reads out the level it resets', () => {
|
|
1090
|
+
assert.match(tpl, /Math\.round\(zoom \* 100\)/);
|
|
1091
|
+
const css = tpl.match(/\[data-zoom-reset\] \{[\s\S]*?\}/)[0];
|
|
1092
|
+
assert.match(css, /tabular-nums/, 'a live number in proportional digits shoves its neighbours');
|
|
1093
|
+
});
|
|
1094
|
+
|
|
1095
|
+
// Pan was unbounded: the canvas could be thrown clear of the viewport, and the
|
|
1096
|
+
// way back was a button the reader had to already know was a reset.
|
|
1097
|
+
test('a panned diagram cannot be dragged out of its own frame', () => {
|
|
1098
|
+
assert.match(tpl, /function panLimit/);
|
|
1099
|
+
// Clamped on the way to every transform write, so zoom, pan and reset all get
|
|
1100
|
+
// it rather than three call sites each remembering to.
|
|
1101
|
+
assert.match(tpl, /clampPan\(\);\s*canvas\.style\.transform/);
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
test('a route change lands instantly and an in-page anchor still glides', () => {
|
|
1105
|
+
const nav = tpl.match(/function navigate[\s\S]*?\n\}/)[0];
|
|
1106
|
+
assert.match(nav, /'instant'/);
|
|
1107
|
+
assert.match(nav, /moved/);
|
|
1108
|
+
// Passing behavior explicitly outranks the CSS, so the reduced-motion rule
|
|
1109
|
+
// that used to cover this no longer does on its own.
|
|
1110
|
+
assert.match(tpl, /matchMedia\('\(prefers-reduced-motion: reduce\)'\)/);
|
|
1111
|
+
});
|
|
1112
|
+
|
|
1113
|
+
/* ---------- section explainers ---------- */
|
|
1114
|
+
|
|
1115
|
+
// The viewer explains the system and never the sections themselves, so a reader
|
|
1116
|
+
// who lands on a heading they do not recognise has nowhere to turn. arc42 heads
|
|
1117
|
+
// each chapter with a fixed explanation; this is the same affordance.
|
|
1118
|
+
test('a spine heading gets a help toggle bound to a details panel', () => {
|
|
1119
|
+
const fn = tpl.match(/function helpEntryFor[\s\S]*?\n\}/)[0];
|
|
1120
|
+
// Keyed on heading text, not on the id: slugify keeps both spaces around a
|
|
1121
|
+
// stripped "&", and h2/h3 share one dedupe registry, so the slug can shift
|
|
1122
|
+
// under a heading without anything failing.
|
|
1123
|
+
assert.doesNotMatch(fn, /\.id\]/, 'keying on the id is the bug this avoids');
|
|
1124
|
+
assert.match(fn, /ARCH_DOCS_HELP/);
|
|
1125
|
+
// The <details> element itself is built in helpPanel, not injectSectionHelp.
|
|
1126
|
+
const panel = tpl.match(/function helpPanel[\s\S]*?\n\}/)[0];
|
|
1127
|
+
assert.match(panel, /'details'/);
|
|
1128
|
+
assert.match(panel, /help__body/);
|
|
1129
|
+
});
|
|
1130
|
+
|
|
1131
|
+
// The anchor loop prepends a '#' to the heading, so reading textContent after it
|
|
1132
|
+
// runs looks up "#Core Components" and finds nothing. Scoped to the loop body,
|
|
1133
|
+
// because `function injectSectionHelp(h, title)` also contains the call pattern
|
|
1134
|
+
// and sits above the loop — matching against the whole file would pass on the
|
|
1135
|
+
// declaration and prove nothing about the order things actually happen in.
|
|
1136
|
+
test('the heading text is read before the deep-link anchor is prepended', () => {
|
|
1137
|
+
const loop = tpl.match(/document\.querySelectorAll\('\.doc h1[\s\S]*?\n\}\);/)[0];
|
|
1138
|
+
const read = loop.indexOf('h.textContent');
|
|
1139
|
+
const call = loop.indexOf('injectSectionHelp(');
|
|
1140
|
+
const prepend = loop.indexOf('h.prepend(a)');
|
|
1141
|
+
assert.ok(read >= 0, 'the loop never reads the heading text');
|
|
1142
|
+
assert.ok(call >= 0, 'help is not injected in the heading pass');
|
|
1143
|
+
assert.ok(read < prepend, 'the title is read after the anchor is prepended');
|
|
1144
|
+
assert.ok(call < prepend, 'the explainer is injected after the anchor is prepended');
|
|
1145
|
+
});
|
|
1146
|
+
|
|
1147
|
+
// A toggle that does not say which way it is set is unreadable to a screen
|
|
1148
|
+
// reader, and the viewer already holds this line for its other toggles.
|
|
1149
|
+
test('the help toggle reports its own state and names what it controls', () => {
|
|
1150
|
+
const fn = tpl.match(/function helpButton[\s\S]*?\n\}/)[0];
|
|
1151
|
+
assert.match(fn, /aria-expanded/);
|
|
1152
|
+
assert.match(fn, /aria-label/, 'the button needs an accessible name');
|
|
1153
|
+
// The panel's summary is hidden because the button drives it, so aria-controls
|
|
1154
|
+
// is the only thing tying the state to the thing in that state.
|
|
1155
|
+
assert.match(fn, /aria-controls/);
|
|
1156
|
+
assert.match(fn, /panel\.id/);
|
|
1157
|
+
});
|
|
1158
|
+
|
|
1159
|
+
// Reading progress is derived from scroll offsets, so a panel opening under the
|
|
1160
|
+
// heading moves the readout. The move is reader-initiated, so recomputing is
|
|
1161
|
+
// enough — but nothing recomputes on its own.
|
|
1162
|
+
test('opening a panel resettles the reading progress readout', () => {
|
|
1163
|
+
const fn = tpl.match(/function wireHelpToggle[\s\S]*?\n\}/)[0];
|
|
1164
|
+
assert.match(fn, /tick\(\)/, 'the progress readout keeps a stale span');
|
|
1165
|
+
});
|
|
1166
|
+
|
|
1167
|
+
// Companion documents get one explainer under the h1, keyed by kind rather than
|
|
1168
|
+
// by heading text — the spec scopes per-heading explainers to the spine only.
|
|
1169
|
+
test('a companion document is explained once, at its title', () => {
|
|
1170
|
+
const fn = tpl.match(/function helpEntryFor[\s\S]*?\n\}/)[0];
|
|
1171
|
+
assert.match(fn, /companions/);
|
|
1172
|
+
// Read via the DOM property, not the attribute string: data-kind itself is
|
|
1173
|
+
// written by pageEl in doc-sections.mjs, not spelled out in the template.
|
|
1174
|
+
assert.match(fn, /dataset\.kind/);
|
|
1175
|
+
assert.match(fn, /tagName === 'H1'/);
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
// Excluded by the spec: §14 Decisions is already a spine section and already the
|
|
1179
|
+
// home for what an ADR is, so a per-record explainer is that guidance a second
|
|
1180
|
+
// time across seventeen records.
|
|
1181
|
+
test('only the spine gets per-heading explainers', () => {
|
|
1182
|
+
const fn = tpl.match(/function helpEntryFor[\s\S]*?\n\}/)[0];
|
|
1183
|
+
assert.match(fn, /\[data-kind="spine"\]|kind === 'spine'/);
|
|
1184
|
+
assert.doesNotMatch(fn, /h3/, 'subheadings are out of scope');
|
|
1185
|
+
});
|
|
1186
|
+
|
|
1187
|
+
// The button is chrome. Paper gets the prose, and a closed panel prints closed.
|
|
1188
|
+
test('print drops the help toggle', () => {
|
|
1189
|
+
const print = tpl.match(/@media print \{[\s\S]*?\n\}/)[0];
|
|
1190
|
+
assert.match(print, /\.help-btn/);
|
|
1191
|
+
});
|
|
1192
|
+
|
|
1193
|
+
// The <details> stays in the flow even with its toggle hidden, and it still
|
|
1194
|
+
// carries its own margin — hiding only the button leaves a blank box the
|
|
1195
|
+
// height of a collapsed panel behind every heading.
|
|
1196
|
+
test('print drops the whole help panel, not just its toggle', () => {
|
|
1197
|
+
const print = tpl.match(/@media print \{[\s\S]*?\n\}/)[0];
|
|
1198
|
+
assert.match(print, /details\.help[^{]*\{[^}]*display:\s*none/);
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1201
|
+
test('the help panel and its toggle are styled', () => {
|
|
1202
|
+
assert.match(tpl, /\.help-btn \{/);
|
|
1203
|
+
assert.match(tpl, /details\.help \{|\.help \{/);
|
|
1204
|
+
// A 40px hit area is the standard this template already holds for icon buttons.
|
|
1205
|
+
assert.match(tpl, /\.help-btn::after \{[^}]*inset:/);
|
|
1206
|
+
});
|