gentle-pi 4.6.0 → 4.8.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 -55
- package/assets/agents/gentle-ai-explore.md +4 -3
- package/assets/agents/gentle-ai-verify.md +23 -6
- package/assets/agents/gentle-ai-worker.md +9 -6
- package/assets/agents/jd-fix-agent.md +1 -0
- package/assets/agents/jd-judge-a.md +2 -3
- package/assets/agents/jd-judge-b.md +2 -3
- package/assets/agents/review-readability.md +1 -5
- package/assets/agents/review-reliability.md +1 -5
- package/assets/agents/review-resilience.md +1 -5
- package/assets/agents/review-risk.md +1 -5
- package/assets/design-canvas/canvas-api.js +45 -0
- package/assets/design-canvas/canvas-boards.js +456 -0
- package/assets/design-canvas/canvas-boot.js +217 -0
- package/assets/design-canvas/canvas-checks.js +491 -0
- package/assets/design-canvas/canvas-comments.js +315 -0
- package/assets/design-canvas/canvas-compare.js +159 -0
- package/assets/design-canvas/canvas-events.js +75 -0
- package/assets/design-canvas/canvas-export.js +393 -0
- package/assets/design-canvas/canvas-focus.js +203 -0
- package/assets/design-canvas/canvas-handoffs.js +150 -0
- package/assets/design-canvas/canvas-i18n-es.js +392 -0
- package/assets/design-canvas/canvas-i18n.js +108 -0
- package/assets/design-canvas/canvas-layout.js +526 -0
- package/assets/design-canvas/canvas-menu.js +213 -0
- package/assets/design-canvas/canvas-messages.js +86 -0
- package/assets/design-canvas/canvas-minimap.js +163 -0
- package/assets/design-canvas/canvas-parts.js +401 -0
- package/assets/design-canvas/canvas-popover.js +234 -0
- package/assets/design-canvas/canvas-rail.js +348 -0
- package/assets/design-canvas/canvas-sizes.js +524 -0
- package/assets/design-canvas/canvas-store.js +164 -0
- package/assets/design-canvas/canvas-tokens.js +674 -0
- package/assets/design-canvas/canvas-ui.js +24 -0
- package/assets/design-canvas/canvas-view.js +184 -0
- package/assets/design-canvas/canvas.css +759 -16
- package/assets/design-canvas/canvas.js +2 -1497
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +6 -1
- package/assets/migrations/agent-body-history.json +40 -1
- package/assets/orchestrator-delegation-reference.md +10 -16
- package/assets/orchestrator-delegation.md +5 -5
- package/assets/orchestrator-full-delegation-card.md +64 -0
- package/assets/orchestrator-full-delegation.md +34 -0
- package/assets/orchestrator-memory.md +5 -5
- package/assets/orchestrator-prompts.md +2 -2
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +14 -13
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +12 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +21 -25
- package/bin/gentle-shell.mjs +292 -65
- package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
- package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
- package/docs/agent-status.md +61 -0
- package/docs/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +20 -10
- package/docs/delegated-verification.md +46 -8
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +40 -0
- package/docs/gentle-shell.md +91 -30
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +17 -4
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +142 -45
- package/docs/render-cache-performance.md +11 -1
- package/docs/review-coordinator.md +53 -0
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/review-request-context.md +19 -0
- package/docs/review-windows-acl.md +18 -0
- package/docs/voice.md +6 -3
- package/docs/work-continuity.md +11 -1
- package/docs/yolo-mode.md +5 -5
- package/extensions/ask-user-choice.ts +1 -0
- package/extensions/ask-user-question.ts +3 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/child-safety.ts +3 -0
- package/extensions/gentle-agent-status.ts +99 -0
- package/extensions/gentle-agents.ts +559 -66
- package/extensions/gentle-ai.ts +2001 -518
- package/extensions/gentle-design.ts +69 -3
- package/extensions/gentle-desktop-rpc.ts +143 -0
- package/extensions/gentle-guide.ts +3 -0
- package/extensions/gentle-shell.ts +398 -115
- package/extensions/gentle-todo.ts +66 -27
- package/extensions/gentle-tps.ts +48 -0
- package/extensions/quiet-tools.ts +38 -8
- package/extensions/skill-registry.ts +349 -167
- package/extensions/startup-banner.ts +30 -3
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-profile-pin.ts +3 -3
- package/lib/agent-profiles.ts +160 -2
- package/lib/agent-status.ts +105 -0
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +93 -6
- package/lib/agents-history.ts +24 -5
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +55 -7
- package/lib/agents-protocol.ts +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +272 -16
- package/lib/agents-session-transport.ts +17 -1
- package/lib/auto-permission-runtime.ts +1 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +197 -32
- package/lib/card-content-policy.ts +8 -6
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- package/lib/command-palette.ts +133 -17
- package/lib/context-backstop.ts +14 -5
- package/lib/delivery-conflict-markers.ts +349 -0
- package/lib/design-canvas-assets.ts +36 -0
- package/lib/design-canvas-server.ts +241 -23
- package/lib/design-comments.ts +94 -4
- package/lib/design-handoffs.ts +2 -1
- package/lib/design-layout.ts +125 -0
- package/lib/design-parts.ts +281 -0
- package/lib/design-system-tokens.ts +111 -0
- package/lib/desktop-agents-service.ts +294 -0
- package/lib/desktop-design-service.ts +233 -0
- package/lib/desktop-jobs-service.ts +263 -0
- package/lib/desktop-rpc-agents.ts +294 -0
- package/lib/desktop-rpc-config.ts +731 -0
- package/lib/desktop-rpc-design.ts +138 -0
- package/lib/desktop-rpc-jobs.ts +181 -0
- package/lib/desktop-rpc-permissions.ts +177 -0
- package/lib/desktop-rpc-profiles.ts +196 -0
- package/lib/desktop-rpc-usage.ts +229 -0
- package/lib/desktop-rpc.ts +225 -0
- package/lib/desktop-usage-service.ts +310 -0
- package/lib/destructive-command-guard.ts +236 -17
- package/lib/execution-surface-guard.ts +20 -0
- package/lib/exploration-budget.ts +4 -2
- package/lib/gentle-ai-binary.ts +1 -1
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +204 -14
- package/lib/gentle-shell-bundled.ts +106 -28
- package/lib/gentle-shell-launcher.ts +43 -8
- package/lib/herdr-activity.ts +14 -2
- package/lib/herdr-busy.ts +45 -0
- package/lib/hidden-tools.ts +35 -0
- package/lib/image-attachments.ts +33 -0
- package/lib/image-disk-cache.ts +137 -0
- package/lib/inprocess-reviewer.ts +358 -144
- package/lib/jobs-view.ts +198 -11
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +31 -4
- package/lib/nan-provider.ts +42 -28
- package/lib/native-choice-list.ts +20 -2
- package/lib/native-review-cli.ts +172 -20
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/orchestrator-mode-policy.ts +105 -0
- package/lib/questionnaire/questionnaire-view.ts +105 -12
- package/lib/rdd-mode-control.ts +32 -0
- package/lib/reply-language-anchor.ts +129 -0
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-blocker.ts +92 -0
- package/lib/review-candidate-symlink-scan.ts +136 -0
- package/lib/review-candidate-view-owner.ts +81 -44
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +116 -0
- package/lib/review-coordinator.ts +407 -0
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-failure-facts.ts +49 -0
- package/lib/review-host-relay.ts +51 -11
- package/lib/review-integration-v2.ts +63 -4
- package/lib/review-relay-phase-timing.ts +45 -0
- package/lib/review-start-context.ts +17 -0
- package/lib/reviewer-stream.ts +87 -0
- package/lib/session-profile-freeze.ts +4 -2
- package/lib/shell-bar.ts +140 -58
- package/lib/shell-changes.ts +2 -0
- package/lib/shell-panel.ts +17 -3
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-sidebar-layout.ts +112 -40
- package/lib/shell-sidebar.ts +7 -0
- package/lib/shell-todo.ts +10 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/verifier-admission.ts +1 -1
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/visual-customization-policy.ts +36 -16
- package/lib/visual-customize-view.ts +216 -21
- package/lib/visual-layout-preview.ts +9 -5
- package/lib/visual-profiles.ts +2 -2
- package/lib/windows-session-transport.ts +53 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +46 -16
- package/package.json +3 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-ai-binary.mjs +1 -1
- package/runtime/gentle-shell-bundled.mjs +106 -28
- package/runtime/gentle-shell-launcher.mjs +42 -7
- package/runtime/native-review-cli.mjs +169 -17
- package/runtime/review-integration-v2.mjs +63 -4
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +179 -0
- package/scripts/build-runtime-modules.mjs +1 -0
- package/scripts/bundled-install.mjs +38 -8
- package/scripts/download-progress.mjs +68 -0
- package/scripts/gentle-ai-installer.mjs +41 -18
- package/scripts/gentle-ai-proxy.mjs +294 -0
- package/scripts/install-gentle-ai.mjs +14 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +33 -22
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-runner.mjs +27 -12
- package/scripts/installer-server.mjs +46 -16
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/render-cache-host.mjs +72 -0
- package/scripts/render-cache-performance-worker.mjs +5 -4
- package/scripts/render-cache-performance.mjs +6 -1
- package/scripts/run-test-suite.mjs +40 -28
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +50 -19
- package/scripts/voice-worker.cjs +32 -6
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +16 -13
- package/skills/gentle-ai/SKILL.md +7 -7
- package/skills/gentle-ui-design/SKILL.md +46 -0
- package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
- package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
- package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
- package/skills/gentle-ui-design/references/task-and-content.md +60 -0
- package/skills/judgment-day/SKILL.md +2 -2
- package/skills/judgment-day/references/prompts-and-formats.md +1 -1
- package/skills/rdd-defect-workflow/SKILL.md +6 -6
- package/skills/skill-improver/SKILL.md +2 -2
- package/skills/skill-registry/SKILL.md +11 -11
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +10 -11
- package/tests/agent-home.test.ts +28 -9
- package/tests/agent-profiles-workflow.test.ts +163 -0
- package/tests/agent-prompt-diet-contract.test.ts +101 -0
- package/tests/agent-risk-escalation.test.ts +1 -1
- package/tests/agent-status.test.ts +143 -0
- package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
- package/tests/agent-tool-overlay.test.ts +89 -0
- package/tests/agents-config.test.ts +106 -1
- package/tests/agents-history.test.ts +31 -0
- package/tests/agents-jobs-frames.test.ts +93 -0
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner-drain.test.ts +193 -0
- package/tests/agents-runner.test.ts +215 -3
- package/tests/agents-session-transport.test.ts +34 -0
- package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
- package/tests/append-system-prompt-route.test.ts +12 -1
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-choice.test.ts +4 -3
- package/tests/ask-user-question.test.ts +99 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/auto-permission-runtime.test.ts +1 -1
- package/tests/autonomous-guard.test.ts +346 -10
- package/tests/bounded-stop-contract.test.ts +51 -3
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bridge-cost.test.ts +19 -4
- package/tests/bundled-install.test.ts +31 -6
- package/tests/card-content-policy.test.ts +3 -3
- package/tests/chained-pr-skill.test.ts +8 -6
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-safety.test.ts +11 -0
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codegraph-tools.test.ts +11 -5
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/command-palette.test.ts +284 -1
- package/tests/delegate-for-reason-contract.test.ts +32 -10
- package/tests/delivery-conflict-markers.test.ts +348 -0
- package/tests/design-canvas-all-sizes.test.ts +631 -0
- package/tests/design-canvas-allowlist.test.ts +32 -0
- package/tests/design-canvas-assets.test.ts +11 -695
- package/tests/design-canvas-boards.test.ts +77 -0
- package/tests/design-canvas-checks.test.ts +655 -0
- package/tests/design-canvas-compare.test.ts +79 -0
- package/tests/design-canvas-events.test.ts +59 -0
- package/tests/design-canvas-export.test.ts +1168 -0
- package/tests/design-canvas-focus.test.ts +113 -0
- package/tests/design-canvas-handoffs.test.ts +59 -0
- package/tests/design-canvas-i18n-review.test.ts +513 -0
- package/tests/design-canvas-i18n-views.test.ts +259 -0
- package/tests/design-canvas-i18n.test.ts +526 -0
- package/tests/design-canvas-inspector.test.ts +937 -0
- package/tests/design-canvas-layout.test.ts +1222 -0
- package/tests/design-canvas-minimap.test.ts +413 -0
- package/tests/design-canvas-modules.test.ts +90 -0
- package/tests/design-canvas-parts.test.ts +721 -0
- package/tests/design-canvas-rail.test.ts +799 -0
- package/tests/design-canvas-server.test.ts +855 -17
- package/tests/design-canvas-sizes.test.ts +548 -0
- package/tests/design-canvas-store.test.ts +180 -0
- package/tests/design-canvas-tokens.test.ts +965 -0
- package/tests/design-canvas-view.test.ts +299 -0
- package/tests/design-comments.test.ts +201 -1
- package/tests/design-handoffs.test.ts +20 -0
- package/tests/design-layout.test.ts +100 -0
- package/tests/design-parts.test.ts +260 -0
- package/tests/design-system-tokens.test.ts +215 -0
- package/tests/desktop-rpc-agents.test.ts +893 -0
- package/tests/desktop-rpc-config.test.ts +1452 -0
- package/tests/desktop-rpc-design.test.ts +662 -0
- package/tests/desktop-rpc-jobs.test.ts +796 -0
- package/tests/desktop-rpc-permissions.test.ts +311 -0
- package/tests/desktop-rpc-profiles.test.ts +140 -0
- package/tests/desktop-rpc-safety.test.ts +119 -0
- package/tests/desktop-rpc-usage.test.ts +697 -0
- package/tests/desktop-rpc.test.ts +252 -0
- package/tests/destructive-command-guard.test.ts +52 -0
- package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/download-progress.test.ts +71 -0
- package/tests/engram-safety.test.ts +111 -0
- package/tests/execution-surface-guard.test.ts +55 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
- package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
- package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -31
- package/tests/fixtures/proxy-tls/proxy.crt +19 -0
- package/tests/fixtures/proxy-tls/proxy.key +28 -0
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
- package/tests/fixtures/session-profile-v1/replay.ts +53 -6
- package/tests/full-delegation-closure.test.ts +160 -0
- package/tests/full-delegation-notices.test.ts +76 -0
- package/tests/generic-agent-tools.test.ts +3 -3
- package/tests/gentle-agent-status.test.ts +74 -0
- package/tests/gentle-agents-child-jobs.test.ts +237 -0
- package/tests/gentle-agents.test.ts +1403 -20
- package/tests/gentle-ai-binary.test.ts +3 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-elapsed-store.test.ts +19 -0
- package/tests/gentle-ai-exploration-budget.test.ts +18 -2
- package/tests/gentle-ai-installer.test.ts +135 -51
- package/tests/gentle-ai-proxy.test.ts +434 -0
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +233 -43
- package/tests/gentle-design.test.ts +386 -1
- package/tests/gentle-herdr-activity.test.ts +9 -6
- package/tests/gentle-shell-bin.test.ts +123 -0
- package/tests/gentle-shell-bundled.test.ts +293 -31
- package/tests/gentle-shell-launcher.test.ts +78 -11
- package/tests/gentle-shell.test.ts +1017 -146
- package/tests/gentle-todo.test.ts +51 -11
- package/tests/gentle-tps.test.ts +123 -0
- package/tests/gentle-ui-design-skill.test.ts +59 -0
- package/tests/herdr-busy.test.ts +59 -0
- package/tests/herdr-task-summary-policy.test.ts +8 -4
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/image-disk-cache.test.ts +163 -0
- package/tests/independent-recovery-delivery.test.ts +97 -0
- package/tests/inprocess-reviewer.test.ts +249 -4
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +115 -14
- package/tests/installer-preflight.test.ts +54 -5
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-runner.test.ts +79 -44
- package/tests/installer-server.test.ts +215 -13
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- package/tests/jobs-view.test.ts +260 -6
- package/tests/judgment-day-severity-admission.test.ts +46 -0
- package/tests/lazy-module-contradictions-contract.test.ts +158 -0
- package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
- package/tests/maintainer/pi-update-source.maintest.ts +48 -18
- package/tests/modal-mouse-boundaries.test.ts +136 -0
- package/tests/model-fallback-policy.test.ts +26 -7
- package/tests/model-routing-authority.test.ts +178 -2
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-choice-list.test.ts +77 -2
- package/tests/native-review-capability-contract.test.ts +17 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- package/tests/native-review-cli.test.ts +269 -1
- package/tests/native-review-parity.test.ts +24 -5
- package/tests/native-review-refusal-identity.test.ts +25 -0
- package/tests/no-self-pause-contract.test.ts +13 -2
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +35 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +154 -0
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-mode-policy.test.ts +175 -0
- package/tests/orchestrator-prompt-budget.test.ts +13 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
- package/tests/orchestrator-rdd-ownership.test.ts +4 -3
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +16 -13
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +372 -0
- package/tests/persona-neutral-voseo.test.ts +4 -4
- package/tests/persona-reply-language.test.ts +1 -1
- package/tests/persona-single-channel.test.ts +13 -5
- package/tests/pi-update-launcher.test.ts +25 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- package/tests/pnpm-workspace-config.test.ts +58 -0
- package/tests/pnpm-workspace-policy.test.ts +47 -0
- package/tests/primary-context-files.test.ts +233 -0
- package/tests/primary-context-three-files.test.ts +174 -0
- package/tests/primary-session-prompt.test.ts +13 -0
- package/tests/profile-pin.test.ts +29 -2
- package/tests/profile-tier-footer.test.ts +5 -0
- package/tests/profiles-panel-delegation-mode.test.ts +422 -0
- package/tests/provider-defect-handoff.test.ts +9 -2
- package/tests/questionnaire-view.test.ts +115 -0
- package/tests/quiet-bash-runtime.test.ts +1 -1
- package/tests/quiet-tool-rendering.test.ts +48 -0
- package/tests/rdd-aware-verification-contract.test.ts +17 -12
- package/tests/rdd-customize.test.ts +287 -0
- package/tests/rdd-mode-cache.test.ts +450 -0
- package/tests/rdd-mode-control.test.ts +407 -0
- package/tests/rdd-mode-scope-regression.test.ts +137 -0
- package/tests/rdd-off-independent-regression.test.ts +69 -0
- package/tests/rdd-status-line.test.ts +112 -1
- package/tests/render-cache-performance.test.ts +171 -2
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +189 -0
- package/tests/request-context-append-only.test.ts +218 -0
- package/tests/request-context-placement.test.ts +148 -0
- package/tests/review-agent-end-preflight.test.ts +80 -2
- package/tests/review-blocker.test.ts +193 -0
- package/tests/review-candidate-owner-retry.test.ts +1 -1
- package/tests/review-candidate-symlink-scan.test.ts +157 -0
- package/tests/review-candidate-view.test.ts +66 -1
- package/tests/review-candidate-windows-boundary.test.ts +131 -0
- package/tests/review-candidate-windows-probe.test.ts +63 -0
- package/tests/review-committed-restart-ack.test.ts +129 -0
- package/tests/review-continuation-registry.test.ts +107 -0
- package/tests/review-contract-prompt.test.ts +1 -1
- package/tests/review-controller-native-routing.test.ts +261 -5
- package/tests/review-controller-workspace-root.test.ts +230 -3
- package/tests/review-controller.test.ts +98 -12
- package/tests/review-coordinator-correction-gate.test.ts +105 -0
- package/tests/review-coordinator-findings.test.ts +206 -0
- package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
- package/tests/review-coordinator-runtime.test.ts +117 -0
- package/tests/review-coordinator.test.ts +462 -0
- package/tests/review-delivery-preflight.test.ts +462 -0
- package/tests/review-due-compaction.test.ts +31 -0
- package/tests/review-due-public-boundary.test.ts +26 -0
- package/tests/review-failure-facts.test.ts +87 -0
- package/tests/review-host-relay-routing.test.ts +258 -4
- package/tests/review-host-relay.test.ts +39 -0
- package/tests/review-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-integration-v2.test.ts +46 -3
- package/tests/review-json-arguments.test.ts +105 -11
- package/tests/review-last-event-closure.test.ts +68 -0
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +95 -32
- package/tests/review-one-call-findings.test.ts +131 -0
- package/tests/review-one-call-followups.test.ts +308 -0
- package/tests/review-one-call-reviewer-requests.test.ts +207 -0
- package/tests/review-one-call.test.ts +452 -0
- package/tests/review-owner-identity.test.ts +60 -24
- package/tests/review-relay-phase-timing.test.ts +128 -0
- package/tests/review-relay-transport-agent.test.ts +39 -2
- package/tests/review-reviewer-evidence.test.ts +223 -0
- package/tests/review-risk-assessment.test.ts +126 -8
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +53 -3
- package/tests/review-start-context.test.ts +19 -0
- package/tests/review-tool-prose-budget.test.ts +122 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/run-test-suite.test.ts +122 -1
- package/tests/runtime-harness.mjs +4 -1
- package/tests/sensitive-path-tools.test.ts +181 -5
- package/tests/session-profile-append-controller-pi.test.ts +60 -31
- package/tests/session-profile-binding.test.ts +19 -1
- package/tests/session-profile-disk-reader-pi.test.ts +58 -16
- package/tests/session-profile-extension.test.ts +2 -2
- package/tests/session-profile-v1-compat.test.ts +35 -1
- package/tests/shell-bar.test.ts +186 -42
- package/tests/shell-panel.test.ts +50 -22
- package/tests/shell-prompt.test.ts +17 -0
- package/tests/shell-sidebar-fullscreen.test.ts +5 -5
- package/tests/shell-sidebar-layout.test.ts +294 -23
- package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
- package/tests/shell-surface-transparent.test.ts +89 -0
- package/tests/shell-todo.test.ts +12 -0
- package/tests/shell-usage.test.ts +59 -10
- package/tests/skill-contradictions-contract.test.ts +122 -0
- package/tests/skill-registry-watcher.test.ts +216 -2
- package/tests/skill-registry.test.ts +1461 -5
- package/tests/startup-banner.test.ts +152 -1
- package/tests/startup-home-repo.test.ts +2 -0
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +264 -0
- package/tests/task-size-routing-contract.test.ts +45 -12
- package/tests/test-strength-contract.test.ts +2 -1
- package/tests/todo-request-append-only.test.ts +214 -0
- package/tests/tool-batching-contract.test.ts +3 -1
- package/tests/update-agent-body-history.test.ts +138 -0
- package/tests/verification-tiers-contract.test.ts +229 -0
- package/tests/verifier-admission.test.ts +49 -0
- package/tests/verifier-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +162 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/visual-customization-policy.test.ts +39 -6
- package/tests/visual-customize-view.test.ts +573 -9
- package/tests/visual-layout-preview.test.ts +15 -1
- package/tests/visual-profiles.test.ts +11 -0
- package/tests/voice-worker.test.ts +73 -2
- package/tests/windows-session-transport.test.ts +126 -0
- package/tests/work-continuity-contract.test.ts +77 -6
- package/tests/writer-admission-messages.test.ts +232 -0
- package/tests/writer-batch-admission.test.ts +66 -0
- package/tests/writer-edit-surface-scope.test.ts +52 -20
- package/tests/writer-feature-document-admission.test.ts +276 -0
- package/tests/yolo-customize.test.ts +27 -4
- package/tests/yolo-mode.test.ts +62 -18
- package/tests/yolo-session-policy.test.ts +270 -1
- package/skills/_shared/review-ledger-contract.md +0 -106
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
- /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import test from "node:test";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { boardsOf, click, findAll, handoffDoc, loadCanvas, memoryStorage, read, SVG_NS, texts, withClass, type FakeElement } from "./support/design-canvas-dom.ts";
|
|
6
|
+
|
|
7
|
+
// The tool rail and its shortcuts (canvas-rail.js) and the shared menu (canvas-menu.js):
|
|
8
|
+
// Move, Comment, Overview and Settings; the ? list of keyboard shortcuts; single keys a
|
|
9
|
+
// person can change, saved in this browser.
|
|
10
|
+
|
|
11
|
+
const SHORTCUTS_KEY = "gentle-design:shortcuts";
|
|
12
|
+
const SHORTCUT_IDS = ["navigate", "comment", "fit", "panel", "minimap", "help"];
|
|
13
|
+
const DEFAULT_KEYS = ["V", "C", "F", "]", "M", "?"];
|
|
14
|
+
const SYSTEM_REPLY = { "/t/api/system": { exists: true, file: "system.html", width: 1440, height: 1200 } };
|
|
15
|
+
const COMMENT_STATUS = "Comment mode: click an element in an artboard";
|
|
16
|
+
const UNSAVED = "This browser could not save the change, so it holds for this page only.";
|
|
17
|
+
|
|
18
|
+
/** The canvas with an in-memory (or a throwing) localStorage; `stored` seeds the shortcuts entry (a string goes in as is). */
|
|
19
|
+
async function loadRail(options: { stored?: unknown; broken?: boolean; full?: boolean; replies?: Record<string, unknown> } = {}) {
|
|
20
|
+
const seed = options.stored === undefined ? {} : { [SHORTCUTS_KEY]: typeof options.stored === "string" ? options.stored : JSON.stringify(options.stored) };
|
|
21
|
+
const storage = memoryStorage(seed, options.broken);
|
|
22
|
+
// `full`: reads work, every write throws (a full or read-only storage).
|
|
23
|
+
const localStorage = options.full ? { getItem: storage.localStorage.getItem, setItem() { throw new Error("QuotaExceededError"); } } : storage.localStorage;
|
|
24
|
+
const canvas = await loadCanvas(300, options.replies ?? {}, {}, { localStorage });
|
|
25
|
+
// The fake DOM starts every element visible; index.html starts these hidden.
|
|
26
|
+
canvas.document.getElementById("gd-popover").hidden = true;
|
|
27
|
+
canvas.document.getElementById("gd-menu").hidden = true;
|
|
28
|
+
const shortcutWrites = () => storage.writes.filter(([key]) => key === SHORTCUTS_KEY).map(([, value]) => value);
|
|
29
|
+
const stored = () => (storage.data.has(SHORTCUTS_KEY) ? JSON.parse(storage.data.get(SHORTCUTS_KEY)!) : undefined);
|
|
30
|
+
return { ...canvas, storage, shortcutWrites, stored };
|
|
31
|
+
}
|
|
32
|
+
type Rail = Awaited<ReturnType<typeof loadRail>>;
|
|
33
|
+
|
|
34
|
+
const $ = (canvas: Rail, id: string) => canvas.document.getElementById(id);
|
|
35
|
+
|
|
36
|
+
/** A key press delivered to the document's keydown listeners, as the browser would from `target`. */
|
|
37
|
+
function press(canvas: Rail, key: string, init: Record<string, unknown> = {}, target?: FakeElement) {
|
|
38
|
+
const event: any = { key, shiftKey: false, ctrlKey: false, metaKey: false, altKey: false, target: target ?? canvas.document.body, defaultPrevented: false, preventDefault() { event.defaultPrevented = true; }, ...init };
|
|
39
|
+
for (const listener of canvas.document.listeners.get("keydown") ?? []) listener(event);
|
|
40
|
+
return event;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const pressed = (canvas: Rail, id: string) => $(canvas, id).getAttribute("aria-pressed");
|
|
44
|
+
const keyOn = (target: FakeElement, key: string, init: Record<string, unknown> = {}) => target.dispatch("keydown", { key, shiftKey: false, ...init });
|
|
45
|
+
const menuEl = (canvas: Rail) => $(canvas, "gd-menu");
|
|
46
|
+
// Settings' items: actions (menuitem), the Technical details checkbox (menuitemcheckbox) and the language radios (menuitemradio).
|
|
47
|
+
const menuItems = (canvas: Rail) => findAll(menuEl(canvas), (element) => ["menuitem", "menuitemcheckbox", "menuitemradio"].includes(element.getAttribute("role") ?? ""));
|
|
48
|
+
const itemLabels = (canvas: Rail) => menuItems(canvas).map((item) => texts(item, "gd-menu-label")[0]);
|
|
49
|
+
const settingsButton = (canvas: Rail) => $(canvas, "gd-rail-settings");
|
|
50
|
+
const openSettings = (canvas: Rail) => {
|
|
51
|
+
settingsButton(canvas).dispatch("click");
|
|
52
|
+
return menuItems(canvas);
|
|
53
|
+
};
|
|
54
|
+
const fitWorld = (canvas: Rail) => {
|
|
55
|
+
Object.defineProperty(canvas.world, "offsetWidth", { value: 2000 });
|
|
56
|
+
Object.defineProperty(canvas.world, "offsetHeight", { value: 400 });
|
|
57
|
+
};
|
|
58
|
+
const zoomIn = (canvas: Rail) => canvas.viewport.dispatch("wheel", { deltaX: 0, deltaY: 40, deltaMode: 0, ctrlKey: true, metaKey: false, shiftKey: false, clientX: 300, clientY: 300 });
|
|
59
|
+
|
|
60
|
+
// ---- the rail
|
|
61
|
+
|
|
62
|
+
test("the rail's Move and Comment form a pressed pair over Comment mode", async () => {
|
|
63
|
+
const canvas = await loadRail();
|
|
64
|
+
const navigate = $(canvas, "gd-tool-navigate");
|
|
65
|
+
const comment = $(canvas, "gd-comment");
|
|
66
|
+
assert.deepEqual([pressed(canvas, "gd-tool-navigate"), pressed(canvas, "gd-comment")], ["true", "false"]);
|
|
67
|
+
|
|
68
|
+
comment.dispatch("click");
|
|
69
|
+
assert.deepEqual([pressed(canvas, "gd-tool-navigate"), pressed(canvas, "gd-comment")], ["false", "true"]);
|
|
70
|
+
assert.ok(canvas.world.classes.has("gd-commenting"));
|
|
71
|
+
assert.equal($(canvas, "gd-status").textContent, COMMENT_STATUS);
|
|
72
|
+
assert.deepEqual(canvas.frames()[0].contentWindow!.posted.at(-1), { type: "gd:mode", enabled: true, inspect: false });
|
|
73
|
+
|
|
74
|
+
navigate.dispatch("click");
|
|
75
|
+
assert.deepEqual([pressed(canvas, "gd-tool-navigate"), pressed(canvas, "gd-comment")], ["true", "false"]);
|
|
76
|
+
assert.ok(!canvas.world.classes.has("gd-commenting"));
|
|
77
|
+
assert.deepEqual(canvas.frames()[0].contentWindow!.posted.at(-1), { type: "gd:mode", enabled: false, inspect: false });
|
|
78
|
+
|
|
79
|
+
// Comment keeps toggling, Move while moving changes nothing, and the nav chip stays main's.
|
|
80
|
+
comment.dispatch("click");
|
|
81
|
+
comment.dispatch("click");
|
|
82
|
+
assert.equal(pressed(canvas, "gd-comment"), "false");
|
|
83
|
+
navigate.dispatch("click");
|
|
84
|
+
assert.equal(pressed(canvas, "gd-tool-navigate"), "true");
|
|
85
|
+
assert.equal(canvas.navMode.textContent, "Navigating");
|
|
86
|
+
|
|
87
|
+
// Esc in the canvas leaves Comment mode and the pair follows.
|
|
88
|
+
comment.dispatch("click");
|
|
89
|
+
press(canvas, "Escape");
|
|
90
|
+
assert.deepEqual([pressed(canvas, "gd-tool-navigate"), pressed(canvas, "gd-comment")], ["true", "false"]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("comment mode on the rail keeps main's pick routing: a click on an artboard picks instead of focusing", async () => {
|
|
94
|
+
const canvas = await loadRail();
|
|
95
|
+
const [first] = canvas.boards;
|
|
96
|
+
first.frame.rect = { left: 100, top: 100, width: 200, height: 150 };
|
|
97
|
+
$(canvas, "gd-comment").dispatch("click");
|
|
98
|
+
click(first.shield!, 150, 130);
|
|
99
|
+
assert.equal(canvas.navMode.textContent, "Navigating");
|
|
100
|
+
assert.deepEqual(first.frame.contentWindow!.posted.at(-1), { type: "gd:pick-at", x: 100, y: 60 });
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("the rail's Overview fits the canvas, and is off in focus mode and in Compare", async () => {
|
|
104
|
+
const canvas = await loadRail({ replies: { "/t/api/designs/alpha/handoffs": handoffDoc("01-a.html", { "01-a.html": { status: "implemented", previewUrl: "http://localhost:5173/" } }) } });
|
|
105
|
+
fitWorld(canvas);
|
|
106
|
+
zoomIn(canvas);
|
|
107
|
+
assert.notEqual(canvas.zoomLevel.textContent, "45%");
|
|
108
|
+
const fit = $(canvas, "gd-rail-fit");
|
|
109
|
+
fit.dispatch("click");
|
|
110
|
+
assert.equal(canvas.zoomLevel.textContent, "45%");
|
|
111
|
+
|
|
112
|
+
click(canvas.boards[0].shield!, 200, 200);
|
|
113
|
+
assert.equal(fit.disabled, true, "off while an artboard is in focus");
|
|
114
|
+
$(canvas, "gd-back").dispatch("click");
|
|
115
|
+
assert.equal(fit.disabled, false);
|
|
116
|
+
|
|
117
|
+
withClass(boardsOf(canvas)[0], "gd-compare-start")[0].dispatch("click");
|
|
118
|
+
assert.equal(fit.disabled, true, "off over Compare");
|
|
119
|
+
$(canvas, "gd-compare-back").dispatch("click");
|
|
120
|
+
assert.equal(fit.disabled, false);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const IMPLEMENTED_REPLY = { "/t/api/designs/alpha/handoffs": handoffDoc("01-a.html", { "01-a.html": { status: "implemented", previewUrl: "http://localhost:5173/" } }) };
|
|
124
|
+
|
|
125
|
+
test("Compare covers the rail: it is inert until Back to canvas, keys leave the mode alone, and a design.json reload keeps Overview off", async () => {
|
|
126
|
+
const canvas = await loadRail({ replies: IMPLEMENTED_REPLY });
|
|
127
|
+
const rail = $(canvas, "gd-rail");
|
|
128
|
+
const fit = $(canvas, "gd-rail-fit");
|
|
129
|
+
assert.equal(rail.inert, false);
|
|
130
|
+
|
|
131
|
+
withClass(boardsOf(canvas)[0], "gd-compare-start")[0].dispatch("click");
|
|
132
|
+
assert.equal($(canvas, "gd-compare").hidden, false);
|
|
133
|
+
assert.equal(rail.inert, true, "Move, Comment, Overview and Settings leave the keyboard and the pointer while Compare covers them");
|
|
134
|
+
assert.equal(press(canvas, "c").defaultPrevented, false);
|
|
135
|
+
assert.equal(pressed(canvas, "gd-comment"), "false", "Comment mode does not change behind Compare");
|
|
136
|
+
|
|
137
|
+
await canvas.serverEvent("change", { slug: "alpha", file: "design.json" });
|
|
138
|
+
assert.equal($(canvas, "gd-compare").hidden, false, "the reload keeps Compare open");
|
|
139
|
+
assert.equal(fit.disabled, true, "Overview stays off after a design.json reload");
|
|
140
|
+
assert.equal(rail.inert, true, "and the rail stays inert");
|
|
141
|
+
|
|
142
|
+
$(canvas, "gd-compare-back").dispatch("click");
|
|
143
|
+
assert.deepEqual([rail.inert, fit.disabled], [false, false]);
|
|
144
|
+
press(canvas, "c");
|
|
145
|
+
assert.equal(pressed(canvas, "gd-comment"), "true", "the keys work again after Compare");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// ---- single-key shortcuts
|
|
149
|
+
|
|
150
|
+
test("V, C, F, ] and ? drive the tools from the keyboard, without letter case", async () => {
|
|
151
|
+
const canvas = await loadRail();
|
|
152
|
+
fitWorld(canvas);
|
|
153
|
+
const panel = $(canvas, "gd-panel");
|
|
154
|
+
|
|
155
|
+
assert.equal(press(canvas, "c").defaultPrevented, true);
|
|
156
|
+
assert.equal(pressed(canvas, "gd-comment"), "true");
|
|
157
|
+
press(canvas, "v");
|
|
158
|
+
assert.equal(pressed(canvas, "gd-comment"), "false");
|
|
159
|
+
press(canvas, "C");
|
|
160
|
+
assert.equal(pressed(canvas, "gd-comment"), "true", "the shortcuts ignore letter case");
|
|
161
|
+
press(canvas, "V");
|
|
162
|
+
assert.equal(pressed(canvas, "gd-tool-navigate"), "true");
|
|
163
|
+
|
|
164
|
+
zoomIn(canvas);
|
|
165
|
+
press(canvas, "f");
|
|
166
|
+
assert.equal(canvas.zoomLevel.textContent, "45%");
|
|
167
|
+
|
|
168
|
+
press(canvas, "]");
|
|
169
|
+
assert.equal(panel.hidden, true);
|
|
170
|
+
assert.equal(pressed(canvas, "gd-panel-toggle"), "false");
|
|
171
|
+
press(canvas, "]");
|
|
172
|
+
assert.equal(panel.hidden, false);
|
|
173
|
+
|
|
174
|
+
press(canvas, "?", { shiftKey: true });
|
|
175
|
+
assert.ok($(canvas, "gd-shortcuts").hasAttribute("open"));
|
|
176
|
+
// Single keys do nothing while the list is open, except ? which closes it.
|
|
177
|
+
assert.equal(press(canvas, "c").defaultPrevented, false);
|
|
178
|
+
assert.equal(pressed(canvas, "gd-comment"), "false");
|
|
179
|
+
press(canvas, "?", { shiftKey: true });
|
|
180
|
+
assert.ok(!$(canvas, "gd-shortcuts").hasAttribute("open"));
|
|
181
|
+
assert.equal(canvas.document.activeElement, settingsButton(canvas), "closing the list returns focus to Settings");
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("browser chords, typing, the open comment box and focus mode leave single keys alone; Shift+Esc still leaves focus", async () => {
|
|
185
|
+
const canvas = await loadRail();
|
|
186
|
+
for (const init of [{ ctrlKey: true }, { metaKey: true }, { altKey: true }]) assert.equal(press(canvas, "c", init).defaultPrevented, false);
|
|
187
|
+
assert.equal(pressed(canvas, "gd-comment"), "false", "browser chords are left alone");
|
|
188
|
+
|
|
189
|
+
const editable = canvas.document.createElement("div");
|
|
190
|
+
editable.setAttribute("contenteditable", "true");
|
|
191
|
+
const typing = [...["input", "textarea", "select"].map((tag) => canvas.document.createElement(tag)), editable];
|
|
192
|
+
for (const field of typing) {
|
|
193
|
+
for (const key of ["c", "v", "f", "]", "?"]) assert.equal(press(canvas, key, {}, field).defaultPrevented, false);
|
|
194
|
+
}
|
|
195
|
+
assert.equal(pressed(canvas, "gd-comment"), "false", "typing never switches tools");
|
|
196
|
+
assert.equal($(canvas, "gd-panel").hidden, false);
|
|
197
|
+
assert.ok(!$(canvas, "gd-shortcuts").hasAttribute("open"));
|
|
198
|
+
|
|
199
|
+
const popover = $(canvas, "gd-popover");
|
|
200
|
+
popover.hidden = false;
|
|
201
|
+
press(canvas, "c");
|
|
202
|
+
press(canvas, "]");
|
|
203
|
+
assert.equal(pressed(canvas, "gd-comment"), "false", "no shortcuts while the comment box is open");
|
|
204
|
+
assert.equal($(canvas, "gd-panel").hidden, false);
|
|
205
|
+
popover.hidden = true;
|
|
206
|
+
|
|
207
|
+
click(canvas.boards[0].shield!, 200, 200);
|
|
208
|
+
const transform = canvas.world.style.transform;
|
|
209
|
+
for (const key of ["c", "v", "f", "]", "?"]) assert.equal(press(canvas, key).defaultPrevented, false, `${key} is left alone in focus mode`);
|
|
210
|
+
assert.equal(pressed(canvas, "gd-comment"), "false");
|
|
211
|
+
assert.equal(canvas.world.style.transform, transform);
|
|
212
|
+
press(canvas, "Escape", { shiftKey: true });
|
|
213
|
+
assert.equal(canvas.navMode.textContent, "Navigating", "Shift+Esc still leaves focus mode");
|
|
214
|
+
press(canvas, "c");
|
|
215
|
+
assert.equal(pressed(canvas, "gd-comment"), "true", "shortcuts work again outside focus mode");
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// AltGr reports Ctrl+Alt on Windows; getModifierState("AltGraph") tells it apart from a chord.
|
|
219
|
+
const ALT_GRAPH = { ctrlKey: true, altKey: true, getModifierState: (modifier: string) => modifier === "AltGraph" };
|
|
220
|
+
const CTRL_ALT = { ctrlKey: true, altKey: true, getModifierState: () => false };
|
|
221
|
+
|
|
222
|
+
test("a key typed with AltGr is a printable key, while Ctrl, Alt and Cmd chords stay ignored", async () => {
|
|
223
|
+
const canvas = await loadRail();
|
|
224
|
+
const panel = $(canvas, "gd-panel");
|
|
225
|
+
assert.equal(press(canvas, "]", ALT_GRAPH).defaultPrevented, true, "] typed with AltGr");
|
|
226
|
+
assert.equal(panel.hidden, true, "toggles the comments panel");
|
|
227
|
+
for (const init of [CTRL_ALT, { ctrlKey: true, getModifierState: () => false }, { altKey: true }, { ...ALT_GRAPH, metaKey: true }]) {
|
|
228
|
+
assert.equal(press(canvas, "]", init).defaultPrevented, false, JSON.stringify(init));
|
|
229
|
+
}
|
|
230
|
+
assert.equal(panel.hidden, true, "chords leave the panel alone");
|
|
231
|
+
|
|
232
|
+
assert.equal(changeKey(canvas, "comment", "@", ALT_GRAPH).defaultPrevented, true);
|
|
233
|
+
assert.equal(keysMessage(canvas), "“Comment on an element” is now @.", "AltGr punctuation can be assigned");
|
|
234
|
+
assert.equal(rowKey(canvas, "comment"), "@");
|
|
235
|
+
for (const init of [CTRL_ALT, { ...ALT_GRAPH, metaKey: true }]) {
|
|
236
|
+
changeKey(canvas, "fit", "#", init);
|
|
237
|
+
assert.equal(keysMessage(canvas), "Use a single letter, digit or punctuation key, without Ctrl, Alt or Cmd. Nothing changed.", JSON.stringify(init));
|
|
238
|
+
}
|
|
239
|
+
assert.deepEqual(canvas.stored(), { comment: "@" });
|
|
240
|
+
closeList(canvas);
|
|
241
|
+
assert.equal(press(canvas, "@", ALT_GRAPH).defaultPrevented, true);
|
|
242
|
+
assert.equal(pressed(canvas, "gd-comment"), "true", "the AltGr key runs its action");
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test("[ and Z are not shortcuts in this canvas", async () => {
|
|
246
|
+
const canvas = await loadRail();
|
|
247
|
+
for (const key of ["[", "z"]) assert.equal(press(canvas, key).defaultPrevented, false, key);
|
|
248
|
+
assert.equal($(canvas, "gd-panel").hidden, false);
|
|
249
|
+
assert.equal(pressed(canvas, "gd-comment"), "false");
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// ---- Settings and the shared menu
|
|
253
|
+
|
|
254
|
+
test("Settings opens the shared menu with Design system board, Keyboard shortcuts and Technical details, with the menu keyboard behavior", async () => {
|
|
255
|
+
const canvas = await loadRail();
|
|
256
|
+
const settings = settingsButton(canvas);
|
|
257
|
+
const dialog = $(canvas, "gd-shortcuts");
|
|
258
|
+
const items = openSettings(canvas);
|
|
259
|
+
assert.equal(menuEl(canvas).hidden, false);
|
|
260
|
+
assert.equal(settings.getAttribute("aria-expanded"), "true");
|
|
261
|
+
assert.equal(menuEl(canvas).getAttribute("aria-label"), "Settings");
|
|
262
|
+
assert.deepEqual(itemLabels(canvas), ["Design system board", "Keyboard shortcuts", "Technical details", "Español", "English", "Match the browser"]);
|
|
263
|
+
assert.deepEqual(items.map((item) => [item.localName, item.getAttribute("tabindex")]), Array(6).fill(["button", "-1"]));
|
|
264
|
+
const last = items[5];
|
|
265
|
+
// Each item leads with a sprite icon built in the SVG namespace of the page's sprite.
|
|
266
|
+
for (const [item, name] of [[items[0], "#i-palette"], [items[1], "#i-keys"], [items[2], "#i-code"]] as const) {
|
|
267
|
+
const [svg] = findAll(item, (element) => element.localName === "svg");
|
|
268
|
+
assert.equal(svg.namespaceURI, SVG_NS);
|
|
269
|
+
assert.equal(svg.getAttribute("aria-hidden"), "true");
|
|
270
|
+
assert.deepEqual(findAll(svg, (element) => element.localName === "use").map((use) => [use.namespaceURI, use.getAttribute("href")]), [[SVG_NS, name]]);
|
|
271
|
+
}
|
|
272
|
+
assert.equal(canvas.document.activeElement, items[0], "focus moves to the first item");
|
|
273
|
+
assert.equal(items[0].getAttribute("aria-disabled"), "true", "no design system board, nothing to show");
|
|
274
|
+
assert.equal(items[1].getAttribute("aria-keyshortcuts"), "?");
|
|
275
|
+
assert.deepEqual(texts(items[1], "gd-menu-kbd"), ["?"]);
|
|
276
|
+
items[0].dispatch("click");
|
|
277
|
+
assert.equal(menuEl(canvas).hidden, false, "a disabled item does nothing");
|
|
278
|
+
assert.equal(canvas.navMode.textContent, "Navigating");
|
|
279
|
+
|
|
280
|
+
keyOn(items[0], "ArrowDown");
|
|
281
|
+
assert.equal(canvas.document.activeElement, items[1]);
|
|
282
|
+
keyOn(items[1], "ArrowDown");
|
|
283
|
+
assert.equal(canvas.document.activeElement, items[2]);
|
|
284
|
+
keyOn(items[2], "ArrowDown");
|
|
285
|
+
assert.equal(canvas.document.activeElement, items[3], "on to the language radios");
|
|
286
|
+
keyOn(items[3], "End");
|
|
287
|
+
assert.equal(canvas.document.activeElement, last);
|
|
288
|
+
keyOn(last, "ArrowDown");
|
|
289
|
+
assert.equal(canvas.document.activeElement, items[0], "the arrows wrap");
|
|
290
|
+
keyOn(items[0], "End");
|
|
291
|
+
assert.equal(canvas.document.activeElement, last);
|
|
292
|
+
keyOn(last, "Home");
|
|
293
|
+
assert.equal(canvas.document.activeElement, items[0]);
|
|
294
|
+
keyOn(items[0], "ArrowUp");
|
|
295
|
+
assert.equal(canvas.document.activeElement, last);
|
|
296
|
+
assert.equal(press(canvas, "c", {}, last).defaultPrevented, false, "single keys stay off while it is open");
|
|
297
|
+
assert.equal(pressed(canvas, "gd-comment"), "false");
|
|
298
|
+
assert.equal(keyOn(last, "Escape").defaultPrevented, true);
|
|
299
|
+
assert.equal(menuEl(canvas).hidden, true);
|
|
300
|
+
assert.deepEqual(menuEl(canvas).children, [], "a closed menu keeps no items");
|
|
301
|
+
assert.equal(settings.getAttribute("aria-expanded"), "false");
|
|
302
|
+
assert.equal(canvas.document.activeElement, settings, "Escape returns focus to Settings");
|
|
303
|
+
|
|
304
|
+
keyOn(settings, "ArrowUp");
|
|
305
|
+
const again = menuItems(canvas);
|
|
306
|
+
assert.equal(canvas.document.activeElement, again[again.length - 1], "ArrowUp opens on the last item");
|
|
307
|
+
keyOn(again[1], "Enter");
|
|
308
|
+
assert.equal(menuEl(canvas).hidden, true);
|
|
309
|
+
assert.ok(dialog.hasAttribute("open"), "Keyboard shortcuts opens the list");
|
|
310
|
+
$(canvas, "gd-shortcuts-close").dispatch("click");
|
|
311
|
+
assert.ok(!dialog.hasAttribute("open"));
|
|
312
|
+
assert.equal(canvas.document.activeElement, settings, "closing the list returns focus to Settings");
|
|
313
|
+
|
|
314
|
+
keyOn(settings, "ArrowDown");
|
|
315
|
+
assert.equal(canvas.document.activeElement, menuItems(canvas)[0], "ArrowDown opens on the first item");
|
|
316
|
+
keyOn(menuItems(canvas)[0], "Tab");
|
|
317
|
+
assert.equal(menuEl(canvas).hidden, true, "Tab closes it");
|
|
318
|
+
|
|
319
|
+
const pointerdown = (target: FakeElement) => (canvas.document.listeners.get("pointerdown") ?? []).forEach((listener) => listener({ target, button: 0 }));
|
|
320
|
+
openSettings(canvas);
|
|
321
|
+
pointerdown(menuItems(canvas)[1]);
|
|
322
|
+
assert.equal(menuEl(canvas).hidden, false, "a press inside keeps it open");
|
|
323
|
+
pointerdown(canvas.viewport);
|
|
324
|
+
assert.equal(menuEl(canvas).hidden, true, "a press outside closes it");
|
|
325
|
+
openSettings(canvas);
|
|
326
|
+
settings.dispatch("click");
|
|
327
|
+
assert.equal(menuEl(canvas).hidden, true, "Settings toggles it");
|
|
328
|
+
assert.equal(canvas.document.activeElement, settings);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
test("Settings' Design system board shows the system board in focus mode", async () => {
|
|
332
|
+
const canvas = await loadRail({ replies: SYSTEM_REPLY });
|
|
333
|
+
const [system] = openSettings(canvas);
|
|
334
|
+
assert.equal(system.getAttribute("aria-disabled"), null);
|
|
335
|
+
system.dispatch("click");
|
|
336
|
+
assert.equal(menuEl(canvas).hidden, true);
|
|
337
|
+
assert.equal(canvas.navMode.textContent, "Using: Design system · Shift+Esc to exit");
|
|
338
|
+
assert.equal($(canvas, "gd-rail-fit").disabled, true);
|
|
339
|
+
$(canvas, "gd-back").dispatch("click");
|
|
340
|
+
assert.equal($(canvas, "gd-rail-fit").disabled, false);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test("Settings' Design system board rechecks the board when chosen: if it vanished meanwhile, the focused view and panel stay", async () => {
|
|
344
|
+
const canvas = await loadRail({ replies: SYSTEM_REPLY });
|
|
345
|
+
const panel = $(canvas, "gd-panel");
|
|
346
|
+
// The system board is the first board; focus the design's first artboard.
|
|
347
|
+
click(canvas.boards[1].shield!, 200, 200);
|
|
348
|
+
const using = "Using: First · Shift+Esc to exit";
|
|
349
|
+
assert.equal(canvas.navMode.textContent, using);
|
|
350
|
+
assert.equal(panel.hidden, true);
|
|
351
|
+
const transform = canvas.world.style.transform;
|
|
352
|
+
|
|
353
|
+
const [system] = openSettings(canvas);
|
|
354
|
+
assert.equal(system.getAttribute("aria-disabled"), null);
|
|
355
|
+
canvas.replies["/t/api/system"] = { exists: false };
|
|
356
|
+
await canvas.serverEvent("change", { slug: null, file: "system.html" });
|
|
357
|
+
assert.equal(boardsOf(canvas).length, 2, "the system board is gone");
|
|
358
|
+
assert.equal(canvas.navMode.textContent, using, "the focused artboard is still focused");
|
|
359
|
+
|
|
360
|
+
let thrown = "";
|
|
361
|
+
try {
|
|
362
|
+
system.dispatch("click");
|
|
363
|
+
} catch (error) {
|
|
364
|
+
thrown = String(error);
|
|
365
|
+
}
|
|
366
|
+
assert.equal(thrown, "", "choosing it does not throw");
|
|
367
|
+
assert.equal(menuEl(canvas).hidden, true);
|
|
368
|
+
assert.equal(canvas.navMode.textContent, using, "focus mode is unchanged");
|
|
369
|
+
assert.equal(boardsOf(canvas).findIndex((wrapper) => wrapper.classes.has("gd-focus-board")), 0, "on the same artboard");
|
|
370
|
+
assert.equal($(canvas, "gd-back").hidden, false);
|
|
371
|
+
assert.equal(panel.hidden, true, "the panel stays as it was");
|
|
372
|
+
assert.equal(canvas.world.style.transform, transform, "and so does the view");
|
|
373
|
+
$(canvas, "gd-back").dispatch("click");
|
|
374
|
+
assert.deepEqual([canvas.navMode.textContent, panel.hidden], ["Navigating", false], "Back to canvas still restores the panel");
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// ---- changing the single keys
|
|
378
|
+
|
|
379
|
+
const keyRows = (canvas: Rail) => withClass($(canvas, "gd-keys-custom"), "gd-key-row");
|
|
380
|
+
const keyRow = (canvas: Rail, id: string) => keyRows(canvas).find((row) => row.dataset.shortcut === id)!;
|
|
381
|
+
const rowKey = (canvas: Rail, id: string) => texts(keyRow(canvas, id), "gd-key-current")[0];
|
|
382
|
+
const rowKeys = (canvas: Rail) => SHORTCUT_IDS.map((id) => rowKey(canvas, id));
|
|
383
|
+
const rowChange = (canvas: Rail, id: string) => withClass(keyRow(canvas, id), "gd-key-change")[0];
|
|
384
|
+
const rowReset = (canvas: Rail, id: string) => withClass(keyRow(canvas, id), "gd-key-reset")[0];
|
|
385
|
+
const keysMessage = (canvas: Rail) => $(canvas, "gd-keys-message").textContent;
|
|
386
|
+
const shortcutsOpen = (canvas: Rail) => $(canvas, "gd-shortcuts").hasAttribute("open");
|
|
387
|
+
const closeList = (canvas: Rail) => $(canvas, "gd-shortcuts-close").dispatch("click");
|
|
388
|
+
/** Opens the list (as Settings' Keyboard shortcuts does), presses Change on `id`'s row and then `key`; returns the key's event. */
|
|
389
|
+
function changeKey(canvas: Rail, id: string, key: string, init: Record<string, unknown> = {}) {
|
|
390
|
+
if (!shortcutsOpen(canvas)) openSettings(canvas)[1].dispatch("click");
|
|
391
|
+
rowChange(canvas, id).dispatch("click");
|
|
392
|
+
return press(canvas, key, init, rowChange(canvas, id));
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
test("the shortcuts list shows each rail and panel action with its key, Change and Reset, and one Restore defaults", async () => {
|
|
396
|
+
const canvas = await loadRail();
|
|
397
|
+
assert.deepEqual(keyRows(canvas).map((row) => row.dataset.shortcut), SHORTCUT_IDS, "the six single-key actions, in this order");
|
|
398
|
+
const labels = SHORTCUT_IDS.map((id) => texts(keyRow(canvas, id), "gd-key-action")[0]);
|
|
399
|
+
// The fixed rows below (0 fits too) never repeat a changeable action's name.
|
|
400
|
+
const fixedRows = [...read("index.html").matchAll(/<dd>([^<]+)<\/dd>/g)].map((match) => match[1]);
|
|
401
|
+
for (const label of labels) assert.ok(!fixedRows.includes(label), `${label} is named once in the list`);
|
|
402
|
+
assert.deepEqual(labels, ["Move around the canvas", "Comment on an element", "Overview (fit all directions)", "Show or hide the comments panel", "Show or hide the minimap", "Show keyboard shortcuts"]);
|
|
403
|
+
assert.deepEqual(rowKeys(canvas), DEFAULT_KEYS);
|
|
404
|
+
assert.equal(rowChange(canvas, "navigate").textContent, "Change");
|
|
405
|
+
assert.equal(rowChange(canvas, "navigate").getAttribute("aria-label"), "Change the key for “Move around the canvas” (V)");
|
|
406
|
+
assert.equal(rowReset(canvas, "comment").textContent, "Reset");
|
|
407
|
+
assert.equal(rowReset(canvas, "comment").getAttribute("aria-label"), "Reset “Comment on an element” to C");
|
|
408
|
+
assert.equal(keysMessage(canvas), "");
|
|
409
|
+
assert.deepEqual(canvas.shortcutWrites(), [], "reading the defaults writes nothing");
|
|
410
|
+
// Every place that names a key names the current one.
|
|
411
|
+
for (const [id, key, title] of [["gd-tool-navigate", "V", "Move around the canvas (V)"], ["gd-comment", "C", "Comment on an element (C)"], ["gd-rail-fit", "F", "See all the directions (F)"], ["gd-panel-toggle", "]", "Comments panel (])"]]) {
|
|
412
|
+
assert.equal($(canvas, id).title, title);
|
|
413
|
+
assert.equal($(canvas, id).getAttribute("aria-keyshortcuts"), key);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
test("a new key triggers its action, the old one does not, and the rail, the list and Settings show it", async () => {
|
|
418
|
+
const canvas = await loadRail();
|
|
419
|
+
assert.equal(changeKey(canvas, "comment", "k").defaultPrevented, true, "the key is taken by the list");
|
|
420
|
+
assert.equal(pressed(canvas, "gd-comment"), "false", "assigning does not run the action");
|
|
421
|
+
assert.equal(rowKey(canvas, "comment"), "K");
|
|
422
|
+
assert.equal(keysMessage(canvas), "“Comment on an element” is now K.");
|
|
423
|
+
assert.deepEqual(canvas.stored(), { comment: "k" });
|
|
424
|
+
closeList(canvas);
|
|
425
|
+
assert.equal(press(canvas, "c").defaultPrevented, false, "the old key is free");
|
|
426
|
+
assert.equal(pressed(canvas, "gd-comment"), "false");
|
|
427
|
+
assert.equal(press(canvas, "K").defaultPrevented, true, "case does not matter");
|
|
428
|
+
assert.equal(pressed(canvas, "gd-comment"), "true");
|
|
429
|
+
assert.equal($(canvas, "gd-comment").title, "Comment on an element (K)");
|
|
430
|
+
assert.equal($(canvas, "gd-comment").getAttribute("aria-keyshortcuts"), "K");
|
|
431
|
+
assert.equal(rowChange(canvas, "comment").getAttribute("aria-label"), "Change the key for “Comment on an element” (K)");
|
|
432
|
+
assert.equal(rowReset(canvas, "comment").getAttribute("aria-label"), "Reset “Comment on an element” to C", "Reset names the default");
|
|
433
|
+
|
|
434
|
+
changeKey(canvas, "navigate", "x");
|
|
435
|
+
changeKey(canvas, "fit", "g");
|
|
436
|
+
changeKey(canvas, "panel", "p");
|
|
437
|
+
changeKey(canvas, "help", "/");
|
|
438
|
+
assert.deepEqual(canvas.stored(), { navigate: "x", comment: "k", fit: "g", panel: "p", help: "/" });
|
|
439
|
+
closeList(canvas);
|
|
440
|
+
assert.equal($(canvas, "gd-tool-navigate").title, "Move around the canvas (X)");
|
|
441
|
+
assert.equal($(canvas, "gd-rail-fit").title, "See all the directions (G)");
|
|
442
|
+
assert.equal($(canvas, "gd-panel-toggle").title, "Comments panel (P)");
|
|
443
|
+
assert.equal($(canvas, "gd-panel-toggle").getAttribute("aria-keyshortcuts"), "P");
|
|
444
|
+
press(canvas, "x");
|
|
445
|
+
assert.equal(pressed(canvas, "gd-comment"), "false", "X moves around the canvas");
|
|
446
|
+
press(canvas, "k");
|
|
447
|
+
assert.equal(pressed(canvas, "gd-comment"), "true", "K selects Comment");
|
|
448
|
+
assert.equal(press(canvas, "v").defaultPrevented, false, "the old Move key is free");
|
|
449
|
+
assert.equal(pressed(canvas, "gd-comment"), "true", "V no longer selects Move");
|
|
450
|
+
press(canvas, "]");
|
|
451
|
+
assert.equal($(canvas, "gd-panel").hidden, false, "] is free");
|
|
452
|
+
press(canvas, "p");
|
|
453
|
+
assert.equal($(canvas, "gd-panel").hidden, true, "P toggles the comments panel");
|
|
454
|
+
const items = openSettings(canvas);
|
|
455
|
+
assert.equal(items[1].getAttribute("aria-keyshortcuts"), "/");
|
|
456
|
+
assert.deepEqual(texts(items[1], "gd-menu-kbd"), ["/"]);
|
|
457
|
+
keyOn(items[1], "Escape");
|
|
458
|
+
press(canvas, "?", { shiftKey: true });
|
|
459
|
+
assert.equal(shortcutsOpen(canvas), false, "? is free");
|
|
460
|
+
press(canvas, "/");
|
|
461
|
+
assert.equal(shortcutsOpen(canvas), true, "/ opens the list");
|
|
462
|
+
press(canvas, "?", { shiftKey: true });
|
|
463
|
+
assert.equal(shortcutsOpen(canvas), true);
|
|
464
|
+
press(canvas, "/");
|
|
465
|
+
assert.equal(shortcutsOpen(canvas), false, "and closes it");
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
test("holding a shortcut key runs it once: the browser's repeated keydowns are ignored", async () => {
|
|
469
|
+
const canvas = await loadRail();
|
|
470
|
+
const panel = $(canvas, "gd-panel");
|
|
471
|
+
press(canvas, "]");
|
|
472
|
+
assert.equal(panel.hidden, true);
|
|
473
|
+
assert.equal(press(canvas, "]", { repeat: true }).defaultPrevented, false, "a repeat is not taken");
|
|
474
|
+
assert.equal(panel.hidden, true, "and does not show the panel again");
|
|
475
|
+
press(canvas, "c");
|
|
476
|
+
press(canvas, "v", { repeat: true });
|
|
477
|
+
assert.equal(pressed(canvas, "gd-comment"), "true", "a held V does not switch to Move");
|
|
478
|
+
press(canvas, "?", { shiftKey: true });
|
|
479
|
+
press(canvas, "?", { shiftKey: true, repeat: true });
|
|
480
|
+
assert.equal(shortcutsOpen(canvas), true, "a held ? leaves the list open");
|
|
481
|
+
// Holding the key just given to the list's own action does not close the list either.
|
|
482
|
+
changeKey(canvas, "help", "/");
|
|
483
|
+
assert.equal(press(canvas, "/", { repeat: true }).defaultPrevented, false);
|
|
484
|
+
assert.equal(shortcutsOpen(canvas), true);
|
|
485
|
+
press(canvas, "/");
|
|
486
|
+
assert.equal(shortcutsOpen(canvas), false, "a new press still closes it");
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
test("custom keys are restored on load, and a stored entry that is unusable, unknown or taken is ignored", async () => {
|
|
490
|
+
const restored = await loadRail({ stored: { navigate: "x", help: "/" } });
|
|
491
|
+
assert.deepEqual(rowKeys(restored), ["X", "C", "F", "]", "M", "/"]);
|
|
492
|
+
assert.equal($(restored, "gd-tool-navigate").title, "Move around the canvas (X)");
|
|
493
|
+
press(restored, "/");
|
|
494
|
+
assert.equal(shortcutsOpen(restored), true);
|
|
495
|
+
assert.deepEqual(restored.shortcutWrites(), [], "loading writes nothing");
|
|
496
|
+
|
|
497
|
+
for (const stored of ["not json", "[1, 2]", "\"x\"", "null", "42", JSON.stringify({ navigate: "vv", comment: "Enter", fit: " ", panel: 7, help: "0", minimap: "zz", bogus: "z" })]) {
|
|
498
|
+
const canvas = await loadRail({ stored });
|
|
499
|
+
assert.deepEqual(rowKeys(canvas), DEFAULT_KEYS, stored);
|
|
500
|
+
press(canvas, "c");
|
|
501
|
+
assert.equal(pressed(canvas, "gd-comment"), "true", `${stored}: the canvas still works`);
|
|
502
|
+
assert.equal(press(canvas, "z").defaultPrevented, false, `${stored}: z names no action here`);
|
|
503
|
+
press(canvas, "v");
|
|
504
|
+
assert.equal(pressed(canvas, "gd-comment"), "false");
|
|
505
|
+
}
|
|
506
|
+
// Two actions stored on one key: neither takes it.
|
|
507
|
+
const twice = await loadRail({ stored: { navigate: "q", comment: "q", fit: "w" } });
|
|
508
|
+
assert.deepEqual(rowKeys(twice), ["V", "C", "W", "]", "M", "?"]);
|
|
509
|
+
// A stored key equal to another action's default is refused too, and that refusal can free another one.
|
|
510
|
+
const chained = await loadRail({ stored: { navigate: "c" } });
|
|
511
|
+
assert.deepEqual(rowKeys(chained), DEFAULT_KEYS);
|
|
512
|
+
// Keys swapped between two actions are both kept.
|
|
513
|
+
const swapped = await loadRail({ stored: { navigate: "c", comment: "v" } });
|
|
514
|
+
assert.deepEqual(rowKeys(swapped), ["C", "V", "F", "]", "M", "?"]);
|
|
515
|
+
press(swapped, "c");
|
|
516
|
+
assert.equal(pressed(swapped, "gd-comment"), "false", "C now moves around the canvas");
|
|
517
|
+
press(swapped, "v");
|
|
518
|
+
assert.equal(pressed(swapped, "gd-comment"), "true");
|
|
519
|
+
|
|
520
|
+
const broken = await loadRail({ broken: true, stored: { navigate: "x" } });
|
|
521
|
+
assert.deepEqual(rowKeys(broken), DEFAULT_KEYS, "unreadable storage keeps the defaults");
|
|
522
|
+
changeKey(broken, "comment", "k");
|
|
523
|
+
assert.equal(rowKey(broken, "comment"), "K", "and a change still applies for this page");
|
|
524
|
+
assert.equal(keysMessage(broken), `“Comment on an element” is now K. ${UNSAVED}`);
|
|
525
|
+
closeList(broken);
|
|
526
|
+
press(broken, "k");
|
|
527
|
+
assert.equal(pressed(broken, "gd-comment"), "true");
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
test("when the browser cannot save a key, the list says it holds for this page only", async () => {
|
|
531
|
+
const canvas = await loadRail({ full: true, stored: { navigate: "x" } });
|
|
532
|
+
assert.deepEqual(rowKeys(canvas), ["X", "C", "F", "]", "M", "?"], "a readable storage still restores the keys");
|
|
533
|
+
changeKey(canvas, "comment", "k");
|
|
534
|
+
assert.equal(keysMessage(canvas), `“Comment on an element” is now K. ${UNSAVED}`);
|
|
535
|
+
assert.ok($(canvas, "gd-keys-message").classes.has("gd-error"), "the warning reads as an error");
|
|
536
|
+
assert.equal(rowKey(canvas, "comment"), "K", "the key holds for this page");
|
|
537
|
+
rowReset(canvas, "comment").dispatch("click");
|
|
538
|
+
assert.equal(keysMessage(canvas), `“Comment on an element” is back to C. ${UNSAVED}`);
|
|
539
|
+
$(canvas, "gd-keys-restore").dispatch("click");
|
|
540
|
+
assert.equal(keysMessage(canvas), `All shortcuts are back to their defaults. ${UNSAVED}`);
|
|
541
|
+
assert.deepEqual(rowKeys(canvas), DEFAULT_KEYS);
|
|
542
|
+
assert.deepEqual(canvas.shortcutWrites(), [], "nothing was written");
|
|
543
|
+
|
|
544
|
+
// A storage that saves keeps the plain message.
|
|
545
|
+
const saving = await loadRail();
|
|
546
|
+
changeKey(saving, "comment", "k");
|
|
547
|
+
assert.equal(keysMessage(saving), "“Comment on an element” is now K.");
|
|
548
|
+
assert.ok(!$(saving, "gd-keys-message").classes.has("gd-error"));
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
test("a key whose lower case is not one character, like İ, is refused when assigned and ignored when stored", async () => {
|
|
552
|
+
const canvas = await loadRail();
|
|
553
|
+
changeKey(canvas, "comment", "İ", { shiftKey: true });
|
|
554
|
+
assert.equal(keysMessage(canvas), "Use a single letter, digit or punctuation key, without Ctrl, Alt or Cmd. Nothing changed.");
|
|
555
|
+
assert.equal(rowKey(canvas, "comment"), "C");
|
|
556
|
+
assert.deepEqual(canvas.shortcutWrites(), []);
|
|
557
|
+
// A letter beyond ASCII whose lower case is one character still works, in either case.
|
|
558
|
+
changeKey(canvas, "comment", "Ñ", { shiftKey: true });
|
|
559
|
+
assert.equal(keysMessage(canvas), "“Comment on an element” is now Ñ.");
|
|
560
|
+
assert.deepEqual(canvas.stored(), { comment: "ñ" });
|
|
561
|
+
|
|
562
|
+
for (const stored of [{ comment: "İ" }, { comment: "i̇" }]) {
|
|
563
|
+
const reloaded = await loadRail({ stored });
|
|
564
|
+
assert.deepEqual(rowKeys(reloaded), DEFAULT_KEYS, JSON.stringify(stored));
|
|
565
|
+
press(reloaded, "c");
|
|
566
|
+
assert.equal(pressed(reloaded, "gd-comment"), "true", `${JSON.stringify(stored)}: C still comments`);
|
|
567
|
+
}
|
|
568
|
+
const kept = await loadRail({ stored: { comment: "Ñ" } });
|
|
569
|
+
assert.equal(rowKey(kept, "comment"), "Ñ", "a stored Ñ is kept, lower case");
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
test("a key another action uses is refused with a message naming it, and nothing changes", async () => {
|
|
573
|
+
const canvas = await loadRail();
|
|
574
|
+
assert.equal(changeKey(canvas, "navigate", "C", { shiftKey: true }).defaultPrevented, true);
|
|
575
|
+
assert.equal(keysMessage(canvas), "C is already used by “Comment on an element”. Nothing changed.");
|
|
576
|
+
assert.ok($(canvas, "gd-keys-message").classes.has("gd-error"), "a refusal reads as an error");
|
|
577
|
+
assert.deepEqual([rowKey(canvas, "navigate"), rowKey(canvas, "comment")], ["V", "C"]);
|
|
578
|
+
assert.deepEqual(canvas.shortcutWrites(), [], "nothing stored");
|
|
579
|
+
assert.equal(rowChange(canvas, "navigate").textContent, "Change", "the wait is over");
|
|
580
|
+
changeKey(canvas, "panel", "?", { shiftKey: true });
|
|
581
|
+
assert.equal(keysMessage(canvas), "? is already used by “Show keyboard shortcuts”. Nothing changed.");
|
|
582
|
+
assert.equal(shortcutsOpen(canvas), true, "? did not close the list while it waited");
|
|
583
|
+
// A custom key is taken too.
|
|
584
|
+
changeKey(canvas, "fit", "g");
|
|
585
|
+
assert.ok(!$(canvas, "gd-keys-message").classes.has("gd-error"));
|
|
586
|
+
changeKey(canvas, "panel", "g");
|
|
587
|
+
assert.equal(keysMessage(canvas), "G is already used by “Overview (fit all directions)”. Nothing changed.");
|
|
588
|
+
assert.deepEqual(canvas.stored(), { fit: "g" });
|
|
589
|
+
closeList(canvas);
|
|
590
|
+
press(canvas, "]");
|
|
591
|
+
assert.equal($(canvas, "gd-panel").hidden, true, "] still toggles the panel");
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
test("fixed keys and keys that are not one printable key are refused; Esc cancels the wait; nothing fires while it waits", async () => {
|
|
595
|
+
const canvas = await loadRail();
|
|
596
|
+
const fixed: Array<[string, Record<string, unknown>, string]> = [
|
|
597
|
+
["Escape", { shiftKey: true }, "Shift+Esc"], ["Enter", {}, "Enter"], [" ", {}, "Space"], ["ArrowLeft", {}, "←"], ["ArrowDown", {}, "↓"], ["0", {}, "0"], ["+", { shiftKey: true }, "+"], ["-", {}, "-"], ["=", {}, "="],
|
|
598
|
+
];
|
|
599
|
+
for (const [key, init, name] of fixed) {
|
|
600
|
+
assert.equal(changeKey(canvas, "navigate", key, init).defaultPrevented, true, key);
|
|
601
|
+
assert.equal(keysMessage(canvas), `${name} is a fixed key and can’t be assigned. Nothing changed.`);
|
|
602
|
+
assert.equal(rowKey(canvas, "navigate"), "V");
|
|
603
|
+
}
|
|
604
|
+
// Tab is fixed too, but it moves focus on as usual: it ends the wait, and is neither taken nor reported.
|
|
605
|
+
for (const init of [{}, { shiftKey: true }]) {
|
|
606
|
+
assert.equal(changeKey(canvas, "navigate", "Tab", init).defaultPrevented, false, `Tab ${JSON.stringify(init)} still moves focus`);
|
|
607
|
+
assert.equal(rowChange(canvas, "navigate").textContent, "Change", "and ends the wait");
|
|
608
|
+
assert.equal(keysMessage(canvas), "");
|
|
609
|
+
assert.equal(rowKey(canvas, "navigate"), "V");
|
|
610
|
+
}
|
|
611
|
+
for (const [key, init] of [["F5", {}], ["k", { ctrlKey: true }], ["k", { altKey: true }], ["k", { metaKey: true }], ["Dead", {}]] as const) {
|
|
612
|
+
changeKey(canvas, "navigate", key, init);
|
|
613
|
+
assert.equal(keysMessage(canvas), "Use a single letter, digit or punctuation key, without Ctrl, Alt or Cmd. Nothing changed.", `${key} ${JSON.stringify(init)}`);
|
|
614
|
+
}
|
|
615
|
+
assert.equal(rowKey(canvas, "navigate"), "V");
|
|
616
|
+
assert.deepEqual(canvas.shortcutWrites(), []);
|
|
617
|
+
|
|
618
|
+
// Waiting: the button says so; a modifier alone keeps it waiting; Esc cancels and keeps the list open.
|
|
619
|
+
rowChange(canvas, "navigate").dispatch("click");
|
|
620
|
+
assert.equal(rowChange(canvas, "navigate").textContent, "Press a key…");
|
|
621
|
+
assert.equal(rowChange(canvas, "navigate").getAttribute("aria-label"), null, "while it waits, its visible text is its name");
|
|
622
|
+
assert.equal(canvas.document.activeElement, rowChange(canvas, "navigate"));
|
|
623
|
+
assert.ok(keyRow(canvas, "navigate").classes.has("gd-key-waiting"));
|
|
624
|
+
assert.equal(keysMessage(canvas), "Press the new key for “Move around the canvas”, or Esc to cancel.");
|
|
625
|
+
assert.equal(press(canvas, "Shift", { shiftKey: true }).defaultPrevented, false);
|
|
626
|
+
assert.equal(rowChange(canvas, "navigate").textContent, "Press a key…", "still waiting");
|
|
627
|
+
assert.equal(press(canvas, "Escape").defaultPrevented, true, "the list does not close on this Esc");
|
|
628
|
+
assert.equal(shortcutsOpen(canvas), true);
|
|
629
|
+
assert.equal(rowChange(canvas, "navigate").textContent, "Change");
|
|
630
|
+
assert.ok(!keyRow(canvas, "navigate").classes.has("gd-key-waiting"));
|
|
631
|
+
assert.equal(keysMessage(canvas), "“Move around the canvas” keeps V.");
|
|
632
|
+
assert.deepEqual(canvas.shortcutWrites(), []);
|
|
633
|
+
press(canvas, "x");
|
|
634
|
+
assert.equal(rowKey(canvas, "navigate"), "V", "after the wait a key changes nothing");
|
|
635
|
+
|
|
636
|
+
// Change again on the waiting row cancels it; Change on another row moves the wait there.
|
|
637
|
+
rowChange(canvas, "fit").dispatch("click");
|
|
638
|
+
rowChange(canvas, "fit").dispatch("click");
|
|
639
|
+
assert.equal(rowChange(canvas, "fit").textContent, "Change");
|
|
640
|
+
assert.equal(keysMessage(canvas), "“Overview (fit all directions)” keeps F.");
|
|
641
|
+
rowChange(canvas, "fit").dispatch("click");
|
|
642
|
+
rowChange(canvas, "panel").dispatch("click");
|
|
643
|
+
assert.equal(rowChange(canvas, "fit").textContent, "Change");
|
|
644
|
+
press(canvas, "b");
|
|
645
|
+
assert.deepEqual([rowKey(canvas, "panel"), rowKey(canvas, "fit")], ["B", "F"]);
|
|
646
|
+
|
|
647
|
+
// Nothing fires while it waits: the next key is the new one, even the comment mode Esc.
|
|
648
|
+
closeList(canvas);
|
|
649
|
+
press(canvas, "c");
|
|
650
|
+
assert.equal(pressed(canvas, "gd-comment"), "true");
|
|
651
|
+
openSettings(canvas)[1].dispatch("click");
|
|
652
|
+
rowChange(canvas, "fit").dispatch("click");
|
|
653
|
+
press(canvas, "Escape", {}, canvas.document.body);
|
|
654
|
+
assert.equal(pressed(canvas, "gd-comment"), "true", "the Esc that cancels a wait does not leave Comment mode");
|
|
655
|
+
rowChange(canvas, "fit").dispatch("click");
|
|
656
|
+
assert.equal(press(canvas, "v").defaultPrevented, true);
|
|
657
|
+
assert.equal(pressed(canvas, "gd-comment"), "true", "V did not switch to Move");
|
|
658
|
+
assert.equal(keysMessage(canvas), "V is already used by “Move around the canvas”. Nothing changed.");
|
|
659
|
+
// Closing the list ends a wait.
|
|
660
|
+
changeKey(canvas, "navigate", "Shift", { shiftKey: true });
|
|
661
|
+
closeList(canvas);
|
|
662
|
+
press(canvas, "x");
|
|
663
|
+
assert.equal(rowKey(canvas, "navigate"), "V");
|
|
664
|
+
// So does the browser closing it (Esc on the modal), and leaving the Change button.
|
|
665
|
+
openSettings(canvas)[1].dispatch("click");
|
|
666
|
+
rowChange(canvas, "navigate").dispatch("click");
|
|
667
|
+
$(canvas, "gd-shortcuts").close();
|
|
668
|
+
assert.equal(rowChange(canvas, "navigate").textContent, "Change");
|
|
669
|
+
openSettings(canvas)[1].dispatch("click");
|
|
670
|
+
assert.equal(keysMessage(canvas), "", "opening the list clears the last message");
|
|
671
|
+
rowChange(canvas, "navigate").dispatch("click");
|
|
672
|
+
rowChange(canvas, "navigate").dispatch("blur");
|
|
673
|
+
assert.equal(rowChange(canvas, "navigate").textContent, "Change");
|
|
674
|
+
assert.equal(keysMessage(canvas), "");
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
test("Reset puts one action back on its default key and Restore defaults puts them all back", async () => {
|
|
678
|
+
const canvas = await loadRail({ stored: { navigate: "x", comment: "k", help: "/" } });
|
|
679
|
+
rowReset(canvas, "comment").dispatch("click");
|
|
680
|
+
assert.equal(rowKey(canvas, "comment"), "C");
|
|
681
|
+
assert.equal(keysMessage(canvas), "“Comment on an element” is back to C.");
|
|
682
|
+
assert.deepEqual(canvas.stored(), { navigate: "x", help: "/" });
|
|
683
|
+
assert.equal($(canvas, "gd-comment").title, "Comment on an element (C)");
|
|
684
|
+
press(canvas, "c");
|
|
685
|
+
assert.equal(pressed(canvas, "gd-comment"), "true");
|
|
686
|
+
$(canvas, "gd-keys-restore").dispatch("click");
|
|
687
|
+
assert.deepEqual(rowKeys(canvas), DEFAULT_KEYS);
|
|
688
|
+
assert.equal(keysMessage(canvas), "All shortcuts are back to their defaults.");
|
|
689
|
+
assert.deepEqual(canvas.stored(), {});
|
|
690
|
+
assert.equal($(canvas, "gd-tool-navigate").title, "Move around the canvas (V)");
|
|
691
|
+
press(canvas, "v");
|
|
692
|
+
assert.equal(pressed(canvas, "gd-comment"), "false");
|
|
693
|
+
// A Reset taken by another action's custom key is refused like a change.
|
|
694
|
+
changeKey(canvas, "navigate", "q");
|
|
695
|
+
changeKey(canvas, "comment", "v");
|
|
696
|
+
rowReset(canvas, "navigate").dispatch("click");
|
|
697
|
+
assert.equal(keysMessage(canvas), "V is already used by “Comment on an element”. Nothing changed.");
|
|
698
|
+
assert.equal(rowKey(canvas, "navigate"), "Q");
|
|
699
|
+
assert.deepEqual(canvas.stored(), { navigate: "q", comment: "v" });
|
|
700
|
+
});
|
|
701
|
+
|
|
702
|
+
// ---- markup, styles, docs
|
|
703
|
+
|
|
704
|
+
test("index.html: a labeled rail with Move, Comment, Overview and Settings, one sprite, the menu and the shortcuts dialog, in English keyed for the language", () => {
|
|
705
|
+
const html = read("index.html");
|
|
706
|
+
const railStart = html.indexOf('<nav id="gd-rail" class="gd-rail" aria-label="Tools" data-i18n-aria-label="tools">');
|
|
707
|
+
assert.ok(railStart > 0, "a labeled rail");
|
|
708
|
+
const rail = html.slice(railStart, html.indexOf("</nav>", railStart));
|
|
709
|
+
const buttons = [...rail.matchAll(/<button type="button" id="([^"]+)"([^>]*)>([^]*?)<\/button>/g)];
|
|
710
|
+
assert.deepEqual(buttons.map((match) => match[1]), ["gd-tool-navigate", "gd-comment", "gd-rail-fit", "gd-rail-settings"], "four tools, in this order");
|
|
711
|
+
const labels = { "gd-tool-navigate": ["hand", "Move", "move"], "gd-comment": ["comment", "Comment", "comment"], "gd-rail-fit": ["fit", "Overview", "overview"], "gd-rail-settings": ["gear", "Settings", "settings"] } as const;
|
|
712
|
+
for (const [, id, attributes, inner] of buttons) {
|
|
713
|
+
const [iconName, label, key] = labels[id as keyof typeof labels];
|
|
714
|
+
assert.equal(inner, `<svg class="gd-i" aria-hidden="true"><use href="#i-${iconName}"/></svg><span class="gd-tool-label" data-i18n="${key}">${label}</span>`, id);
|
|
715
|
+
assert.ok(!/aria-label=/.test(attributes), `${id}: the visible label is its name`);
|
|
716
|
+
assert.match(attributes, /title="[^"]+"/, `${id}: a tooltip`);
|
|
717
|
+
}
|
|
718
|
+
for (const [id, key] of [["gd-tool-navigate", "V"], ["gd-comment", "C"], ["gd-rail-fit", "F"]]) {
|
|
719
|
+
assert.match(rail, new RegExp(`id="${id}"[^>]*aria-keyshortcuts="${key}"[^>]*title="[^"]*\\(${key}\\)"`), `${id} names ${key}`);
|
|
720
|
+
}
|
|
721
|
+
assert.match(rail, /id="gd-rail-settings" class="gd-tool gd-bottom" aria-haspopup="menu" aria-expanded="false" aria-controls="gd-menu" title="Settings: design system, keyboard shortcuts and technical details"/);
|
|
722
|
+
assert.match(html, /id="gd-panel-toggle"[^>]*aria-keyshortcuts="\]" title="Comments panel \(\]\)"/);
|
|
723
|
+
|
|
724
|
+
// Comment moved from the top bar into the rail, and the rail sits beside the viewport.
|
|
725
|
+
const bar = html.slice(html.indexOf('<header class="gd-bar"'), html.indexOf("</header>"));
|
|
726
|
+
assert.ok(!bar.includes('id="gd-comment"'), "Comment is no longer in the top bar");
|
|
727
|
+
assert.equal(html.split('id="gd-comment"').length - 1, 1);
|
|
728
|
+
assert.ok(html.indexOf('<div class="gd-main">') < railStart && railStart < html.indexOf('<main id="gd-viewport"'), "the rail is the first column of the main area");
|
|
729
|
+
|
|
730
|
+
// One sprite, with each used icon in it, and only icons something uses.
|
|
731
|
+
const sprite = /<svg id="gd-sprite" class="gd-sprite" width="0" height="0" aria-hidden="true" focusable="false">([^]*?)<\/svg>/.exec(html);
|
|
732
|
+
assert.ok(sprite, "a hidden sprite");
|
|
733
|
+
const symbols = [...sprite![1].matchAll(/<symbol id="([^"]+)" viewBox="0 0 24 24">/g)].map((match) => match[1]);
|
|
734
|
+
assert.equal(new Set(symbols).size, symbols.length, "sprite ids are unique");
|
|
735
|
+
// The screen sizes' icons are used by canvas-sizes.js (tests/design-canvas-sizes.test.ts), the ⋯ menu's
|
|
736
|
+
// by canvas-export.js (tests/design-canvas-export.test.ts), Technical details' by canvas-rail.js (tests/design-canvas-tokens.test.ts).
|
|
737
|
+
assert.deepEqual(symbols.sort(), ["i-check", "i-code", "i-column", "i-comment", "i-devices", "i-download", "i-file", "i-fit", "i-gear", "i-grid", "i-hand", "i-image", "i-keys", "i-monitor", "i-more", "i-palette", "i-phone", "i-row", "i-tablet", "i-target", "i-width"]);
|
|
738
|
+
for (const match of html.matchAll(/<use href="#([^"]+)"/g)) assert.ok(symbols.includes(match[1]), `${match[1]} exists in the sprite`);
|
|
739
|
+
|
|
740
|
+
assert.match(html, /<div id="gd-menu" class="gd-menu" role="menu" hidden><\/div>/);
|
|
741
|
+
const dialog = html.slice(html.indexOf('<dialog id="gd-shortcuts"'), html.indexOf("</dialog>"));
|
|
742
|
+
assert.match(dialog, /^<dialog id="gd-shortcuts" class="gd-dialog" aria-labelledby="gd-shortcuts-title">/);
|
|
743
|
+
assert.match(dialog, /<h2 id="gd-shortcuts-title" class="gd-dialog-title" data-i18n="shortcutsTitle">Keyboard shortcuts<\/h2>/);
|
|
744
|
+
assert.match(dialog, /<ul id="gd-keys-custom" class="gd-keys-custom" aria-label="Shortcuts you can change" data-i18n-aria-label="changeable"><\/ul>/);
|
|
745
|
+
assert.match(dialog, /<p id="gd-keys-message" class="gd-keys-message" role="status" aria-live="polite"><\/p>/);
|
|
746
|
+
assert.match(dialog, /<button type="button" id="gd-keys-restore" class="gd-keys-restore" data-i18n="restore">Restore defaults<\/button><button type="button" id="gd-shortcuts-close" class="gd-primary" data-i18n="close">Close<\/button>/);
|
|
747
|
+
// The fixed keys of this canvas are listed (Space + drag with the layout, in tests/design-canvas-layout.test.ts).
|
|
748
|
+
for (const fixed of [/<dt><kbd>0<\/kbd><\/dt><dd data-i18n="fitAll">Fit all directions<\/dd>/, /<dt><kbd>\+<\/kbd> <kbd>-<\/kbd><\/dt><dd data-i18n="zoomInOut">Zoom in and out<\/dd>/, /<kbd>←<\/kbd>/, /<dt><kbd>Esc<\/kbd><\/dt>/, /<dt><kbd data-i18n="shift">Shift<\/kbd> \+ <kbd>Esc<\/kbd><\/dt>/]) assert.match(dialog, fixed);
|
|
749
|
+
|
|
750
|
+
// The words are keyed for the language (ES.html, tests/design-canvas-i18n.test.ts); the English stays in the markup.
|
|
751
|
+
for (const cut of ["gd-appearance", "gd-theme", "i-help", "gd-variant", "gd-mark", "data-theme"]) assert.ok(!html.includes(cut), `${cut} stays out`);
|
|
752
|
+
assert.ok(!/[\u{1F300}-\u{1FAFF}☀-➿]/u.test(html), "no emoji icons");
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
test("canvas-rail.js and canvas-menu.js keep their English strings grouped at the top, with no theme or help", () => {
|
|
756
|
+
for (const name of ["canvas-rail.js", "canvas-menu.js"]) {
|
|
757
|
+
const source = read(name);
|
|
758
|
+
assert.ok(!/theme|appearance|renderGuide|guideBlocked|variant/i.test(source), `${name}: no cut feature`);
|
|
759
|
+
}
|
|
760
|
+
const rail = read("canvas-rail.js");
|
|
761
|
+
assert.ok(rail.indexOf("const TEXT = Object.freeze({") >= 0 && rail.indexOf("const TEXT = Object.freeze({") < rail.indexOf("export function init"), "the rail's strings sit in one TEXT block before init");
|
|
762
|
+
assert.ok(rail.includes('"gentle-design:shortcuts"'));
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
/** The body of the first `selector {` rule in canvas.css. */
|
|
766
|
+
function rule(css: string, selector: string) {
|
|
767
|
+
const start = css.indexOf(`${selector} {`);
|
|
768
|
+
assert.ok(start >= 0, `${selector} is styled`);
|
|
769
|
+
return css.slice(start, css.indexOf("}", start) + 1);
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
test("canvas.css styles the rail, the menu and the shortcuts list on main's --gd-* tokens, in their own sections", () => {
|
|
773
|
+
const css = read("canvas.css");
|
|
774
|
+
for (const heading of ["/* Tool rail", "/* The shared menu", "/* Keyboard shortcuts"]) assert.equal(css.split(heading).length - 1, 1, `one ${heading} section`);
|
|
775
|
+
const selectors = [".gd-rail", ".gd-rail .gd-tool", ".gd-tool-label", ".gd-i", ".gd-menu", ".gd-menu-item", ".gd-menu-kbd", ".gd-dialog", ".gd-keys", ".gd-keys-custom", ".gd-key-row", ".gd-key-waiting", ".gd-keys-message"];
|
|
776
|
+
for (const selector of selectors) {
|
|
777
|
+
const text = rule(css, selector);
|
|
778
|
+
assert.ok(!/#[0-9a-fA-F]{3,8}\b/.test(text), `${selector}: no raw hex`);
|
|
779
|
+
assert.ok(!/transition|animation/.test(text), `${selector}: no motion`);
|
|
780
|
+
}
|
|
781
|
+
for (const selector of [".gd-rail", ".gd-menu", ".gd-dialog"]) assert.match(rule(css, selector), /var\(--gd-panel\)/, `${selector} sits on the panel color`);
|
|
782
|
+
// Only main's tokens: none of the other branch's token names come along.
|
|
783
|
+
const tokens = new Set([...css.matchAll(/var\((--[\w-]+)/g)].map((match) => match[1]));
|
|
784
|
+
for (const token of tokens) assert.ok(token.startsWith("--gd-"), `${token} is a --gd-* token`);
|
|
785
|
+
assert.match(rule(css, ".gd-menu-item[aria-disabled=\"true\"]"), /cursor: not-allowed/);
|
|
786
|
+
assert.match(css, /\.gd-menu\[hidden\] { display: none; }/);
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
test("the docs describe the rail, the Settings menu and the changeable keys saved in this browser", () => {
|
|
790
|
+
const docs = readFileSync(fileURLToPath(new URL("../docs/gentle-shell.md", import.meta.url)), "utf8");
|
|
791
|
+
const section = docs.slice(docs.indexOf("### Gentle Design"));
|
|
792
|
+
const start = section.indexOf("- **Tool rail**");
|
|
793
|
+
assert.ok(start >= 0, "a Tool rail entry");
|
|
794
|
+
const rail = section.slice(start, section.indexOf("\n", start));
|
|
795
|
+
for (const part of ["**Move** (`V`", "**Comment** (`C`)", "**Overview**", "(`F`)", "**Settings**", "**Design system board**", "**Keyboard shortcuts** (`?`)", "**Change**", "**Reset**", "**Restore defaults**", "`gentle-design:shortcuts`", "saved in this browser", "a new port", "`Tab` moves on and ends it", "holds for this page only", "AltGr", "Compare covers the rail", "`]`", "`Esc`, `Shift+Esc`, the arrows, `Space`, `Enter`, `Tab`"]) {
|
|
796
|
+
assert.ok(rail.includes(part), `the rail entry mentions ${part}`);
|
|
797
|
+
}
|
|
798
|
+
assert.ok(!/Appearance|theme|Step-by-step/i.test(rail), "nothing that does not ship here");
|
|
799
|
+
});
|