gentle-pi 4.7.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 +55 -44
- package/assets/agents/gentle-ai-explore.md +3 -3
- package/assets/agents/gentle-ai-verify.md +20 -6
- package/assets/agents/gentle-ai-worker.md +6 -6
- package/assets/agents/jd-judge-a.md +1 -3
- package/assets/agents/jd-judge-b.md +1 -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 +746 -15
- package/assets/design-canvas/canvas.js +2 -1506
- package/assets/design-canvas/index.html +117 -36
- package/assets/design-canvas/inspector.js +546 -16
- package/assets/install-wizard/wizard.js +5 -1
- package/assets/migrations/agent-body-history.json +24 -0
- package/assets/orchestrator-delegation-reference.md +8 -14
- package/assets/orchestrator-delegation.md +4 -4
- package/assets/orchestrator-full-delegation-card.md +4 -5
- package/assets/orchestrator-full-delegation.md +8 -8
- package/assets/orchestrator-memory.md +2 -2
- package/assets/orchestrator-prompts.md +1 -1
- package/assets/orchestrator-quota-recovery.md +5 -0
- package/assets/orchestrator-skills.md +13 -12
- package/assets/orchestrator-tracking.md +10 -14
- package/assets/orchestrator-verification.md +10 -8
- package/assets/orchestrator-writer.md +4 -4
- package/assets/orchestrator.md +18 -22
- package/bin/gentle-shell.mjs +128 -9
- 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/assets/brand/sponsor-banner.svg +60 -0
- package/docs/bundled-install.md +14 -6
- package/docs/delegated-verification.md +18 -2
- package/docs/desktop-rpc.md +1253 -0
- package/docs/gentle-agents-activity.md +26 -0
- package/docs/gentle-shell.md +39 -16
- package/docs/install-wizard.md +30 -21
- package/docs/odd-preparation-continuity.md +24 -0
- package/docs/permission-modes.md +9 -1
- package/docs/prompt-budget.md +12 -0
- package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
- package/docs/readme-reference.md +76 -24
- package/docs/review-coordinator.md +29 -9
- package/docs/review-delivery-preflight.md +22 -0
- package/docs/work-continuity.md +11 -1
- package/extensions/ask-user-question.ts +2 -2
- package/extensions/child-context.ts +21 -7
- package/extensions/gentle-agents.ts +234 -33
- package/extensions/gentle-ai.ts +576 -135
- 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 +105 -52
- package/extensions/gentle-todo.ts +48 -25
- package/extensions/skill-registry.ts +248 -223
- package/lib/agent-assets.ts +30 -6
- package/lib/agent-tool-overlay.ts +117 -0
- package/lib/agents-config.ts +47 -6
- package/lib/agents-message-delivery.ts +17 -0
- package/lib/agents-messaging.ts +8 -2
- package/lib/agents-protocol.ts +15 -0
- package/lib/agents-report-cap.ts +115 -0
- package/lib/agents-runner.ts +91 -6
- package/lib/agents-session-transport.ts +17 -1
- package/lib/background-jobs-tools.ts +9 -4
- package/lib/bounded-writer-admission.ts +184 -31
- package/lib/child-context-files.ts +21 -6
- package/lib/codemode-renderer.ts +1 -0
- 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 +188 -13
- package/lib/gentle-ai-renderer.ts +13 -1
- package/lib/gentle-design.ts +201 -14
- package/lib/gentle-shell-bundled.ts +100 -9
- package/lib/hidden-tools.ts +35 -0
- package/lib/inprocess-reviewer.ts +96 -12
- package/lib/model-fallback-policy.ts +9 -0
- package/lib/model-routing-authority.ts +9 -0
- package/lib/nan-provider.ts +42 -28
- package/lib/native-review-cli.ts +79 -4
- package/lib/orchestrator-discovery.ts +39 -2
- package/lib/reply-language-anchor.ts +27 -2
- package/lib/request-context-placement.ts +53 -0
- package/lib/review-candidate-view.ts +11 -1
- package/lib/review-continuation-registry.ts +17 -0
- package/lib/review-coordinator.ts +252 -8
- package/lib/review-delivery-preflight.ts +85 -0
- package/lib/review-host-relay.ts +5 -1
- package/lib/review-integration-v2.ts +56 -3
- package/lib/reviewer-stream.ts +87 -0
- package/lib/shell-prompt.ts +16 -3
- package/lib/shell-usage.ts +10 -0
- package/lib/vim-editor-adapter.ts +9 -2
- package/lib/writer-batch-admission.ts +55 -0
- package/lib/yolo-session-policy.ts +6 -1
- package/package.json +2 -2
- package/prompts/skill-creation.md +1 -10
- package/runtime/design-canvas-assets.mjs +37 -0
- package/runtime/gentle-shell-bundled.mjs +100 -9
- package/runtime/native-review-cli.mjs +79 -4
- package/runtime/review-integration-v2.mjs +56 -3
- package/scripts/bootstrap.cmd +2 -2
- package/scripts/bootstrap.sh +41 -4
- package/scripts/build-full-delegation-card.mjs +4 -0
- package/scripts/build-runtime-modules.mjs +1 -0
- package/scripts/gentle-ai-installer.mjs +10 -10
- package/scripts/gentle-ai-proxy.mjs +1 -1
- package/scripts/installer-downloads.mjs +34 -8
- package/scripts/installer-preflight.mjs +28 -17
- package/scripts/installer-probes.mjs +25 -5
- package/scripts/installer-server.mjs +38 -9
- package/scripts/installer-windows.mjs +2 -2
- package/scripts/pi-update.mjs +166 -27
- package/scripts/prepare-verifier.mjs +107 -0
- package/scripts/update-agent-body-history.mjs +55 -8
- package/scripts/verify-package-files.mjs +40 -19
- package/skills/branch-pr/SKILL.md +16 -16
- package/skills/comment-writer/SKILL.md +1 -1
- package/skills/design/SKILL.md +6 -6
- package/skills/gentle-ai/SKILL.md +5 -5
- 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 -13
- package/skills/tui-design/SKILL.md +1 -1
- package/skills/work-unit-commits/SKILL.md +5 -5
- package/tests/agent-prompt-diet-contract.test.ts +101 -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 +10 -1
- package/tests/agents-message-delivery.test.ts +36 -0
- package/tests/agents-queries.test.ts +144 -4
- package/tests/agents-report-cap.test.ts +126 -0
- package/tests/agents-runner.test.ts +37 -1
- 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 +10 -2
- package/tests/approved-text-leftovers-contract.test.ts +136 -0
- package/tests/artifact-language.test.ts +1 -1
- package/tests/ask-user-question.test.ts +2 -1
- package/tests/audit-leftovers-contract.test.ts +51 -0
- package/tests/bounded-stop-contract.test.ts +9 -1
- package/tests/branch-pr-skill.test.ts +10 -1
- package/tests/bundled-install.test.ts +1 -1
- package/tests/child-context-files.test.ts +64 -8
- package/tests/child-skills-catalog.test.ts +56 -0
- package/tests/codemode-rendering.test.ts +4 -1
- package/tests/delegate-for-reason-contract.test.ts +30 -8
- 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 -878
- 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/devbinary/pi-host-relay.devtest.ts +149 -80
- package/tests/devbinary/review-session-consent.devtest.ts +84 -0
- package/tests/engram-safety.test.ts +111 -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 +20 -29
- package/tests/fixtures/refusal-identity.probe.mjs +139 -0
- package/tests/full-delegation-closure.test.ts +29 -0
- package/tests/gentle-agents.test.ts +329 -4
- package/tests/gentle-ai-binary.test.ts +1 -1
- package/tests/gentle-ai-child-guards.test.ts +1 -0
- package/tests/gentle-ai-installer.test.ts +52 -51
- package/tests/gentle-ai-renderer.test.ts +36 -2
- package/tests/gentle-ai.test.ts +121 -6
- package/tests/gentle-design.test.ts +365 -1
- package/tests/gentle-shell-bundled.test.ts +91 -5
- package/tests/gentle-shell-launcher.test.ts +1 -1
- package/tests/gentle-shell.test.ts +118 -87
- package/tests/gentle-todo.test.ts +32 -9
- package/tests/hidden-tools.test.ts +188 -0
- package/tests/independent-recovery-delivery.test.ts +19 -5
- package/tests/inprocess-reviewer.test.ts +73 -0
- package/tests/install-wizard.test.ts +27 -1
- package/tests/installer-downloads.test.ts +30 -1
- package/tests/installer-posix-bootstrap.test.ts +114 -13
- package/tests/installer-preflight.test.ts +49 -1
- package/tests/installer-probes.test.ts +146 -0
- package/tests/installer-server.test.ts +203 -4
- package/tests/installer-windows-bootstrap.test.ts +19 -1
- 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/model-fallback-policy.test.ts +26 -7
- package/tests/nan-provider-runtime.test.ts +17 -3
- package/tests/nan-provider.test.ts +111 -56
- package/tests/native-review-capability-contract.test.ts +11 -1
- package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
- 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 +11 -3
- package/tests/odd-integration.test.ts +11 -3
- package/tests/odd-routing-contract.test.ts +80 -28
- package/tests/orchestrator-budget.test.ts +30 -5
- package/tests/orchestrator-consultation-sdk.test.ts +32 -6
- package/tests/orchestrator-delegation-mode.test.ts +2 -1
- package/tests/orchestrator-discovery.test.ts +28 -0
- package/tests/orchestrator-prompt-budget.test.ts +11 -2
- package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
- package/tests/orchestrator-rdd-ownership.test.ts +2 -1
- package/tests/orchestrator-work-search.test.ts +4 -2
- package/tests/package-files.test.ts +25 -1
- package/tests/package-manifest.test.ts +11 -10
- package/tests/parallel-reason-contract.test.ts +6 -3
- package/tests/permission-allowlist.test.ts +200 -30
- 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 +17 -7
- package/tests/pi-update-source.test.ts +113 -6
- package/tests/pi-update.test.ts +294 -19
- 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/provider-defect-handoff.test.ts +9 -2
- package/tests/rdd-aware-verification-contract.test.ts +1 -1
- package/tests/rdd-status-line.test.ts +94 -1
- package/tests/reply-language-anchor-placement.test.ts +184 -0
- package/tests/reply-language-anchor.test.ts +17 -1
- 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 +79 -1
- package/tests/review-candidate-view.test.ts +65 -0
- package/tests/review-continuation-registry.test.ts +31 -0
- package/tests/review-contract-prompt.test.ts +1 -1
- package/tests/review-controller.test.ts +2 -1
- 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.test.ts +271 -4
- 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-integration-nonblocking-findings.test.ts +108 -0
- package/tests/review-json-arguments.test.ts +41 -2
- package/tests/review-ledger-contract.test.ts +19 -40
- package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
- 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-relay-transport-agent.test.ts +28 -1
- package/tests/review-reviewer-evidence.test.ts +41 -1
- package/tests/review-risk-assessment.test.ts +52 -5
- package/tests/review-run-statement-guidance-independent.test.ts +54 -0
- package/tests/review-session-standing-permission-controller.test.ts +32 -2
- package/tests/review-tool-prose-budget.test.ts +1 -0
- package/tests/reviewer-stream.test.ts +149 -0
- package/tests/session-profile-extension.test.ts +2 -2
- package/tests/shell-prompt.test.ts +17 -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 +929 -306
- package/tests/support/design-canvas-dom.ts +369 -0
- package/tests/support/review-coordinator-runtime.ts +212 -17
- package/tests/task-size-routing-contract.test.ts +42 -11
- 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-preparation.test.ts +229 -0
- package/tests/verify-agent-contract.test.ts +20 -2
- package/tests/verify-first-launch-contract.test.ts +87 -11
- package/tests/vim-editor-adapter.test.ts +2 -2
- package/tests/work-continuity-contract.test.ts +54 -11
- 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 +184 -0
- package/tests/yolo-mode.test.ts +39 -0
- 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,631 @@
|
|
|
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 { DESIGN_VIEWPORT_LIMITS } from "../lib/design-comments.ts";
|
|
6
|
+
import { findAll, flush, inspectorPick, loadCanvas, read, texts, withClass, type FakeElement } from "./support/design-canvas-dom.ts";
|
|
7
|
+
|
|
8
|
+
// All sizes (canvas-sizes.js): the focused artboard at Phone, Tablet and as designed at once, each a
|
|
9
|
+
// real iframe ("size frame") that takes picks and shows pins like the artboard's own frame; the
|
|
10
|
+
// Overflows chip a frame shows while its page is wider than it (inspector.js gd:overflow); and the
|
|
11
|
+
// size a comment was made at (its viewport), sent with the comment and shown on its card.
|
|
12
|
+
// Every assertion compares strings, numbers or booleans, never fake elements, which node:assert
|
|
13
|
+
// would walk whole on a failure.
|
|
14
|
+
|
|
15
|
+
/** First artboard 1200 x 800 so Desktop is the artboard's own width in the 1000 px test viewport. */
|
|
16
|
+
const WIDE_ALPHA = { "/t/api/designs/alpha": { slug: "alpha", title: "Alpha", brief: "", artboards: [
|
|
17
|
+
{ file: "01-a.html", title: "First", tradeoff: "", width: 1200, height: 800 },
|
|
18
|
+
{ file: "02-b.html", title: "Second", tradeoff: "", width: 400, height: 300 },
|
|
19
|
+
] } };
|
|
20
|
+
|
|
21
|
+
async function loadSizes(replies: Record<string, unknown> = {}, firstHeight = 300) {
|
|
22
|
+
const canvas = await loadCanvas(firstHeight, replies);
|
|
23
|
+
// The fake DOM starts every element visible; index.html starts these hidden.
|
|
24
|
+
for (const id of ["gd-popover", "gd-menu", "gd-device-menu"]) canvas.document.getElementById(id).hidden = true;
|
|
25
|
+
return canvas;
|
|
26
|
+
}
|
|
27
|
+
type Canvas = Awaited<ReturnType<typeof loadSizes>>;
|
|
28
|
+
|
|
29
|
+
const $ = (canvas: Canvas, id: string) => canvas.document.getElementById(id);
|
|
30
|
+
// Enter on the shield opens the artboard in Comment mode too (a click there is a pick).
|
|
31
|
+
const focusOn = (canvas: Canvas, index = 0) => canvas.boards[index].shield!.dispatch("keydown", { key: "Enter" });
|
|
32
|
+
const back = (canvas: Canvas) => $(canvas, "gd-back").dispatch("click");
|
|
33
|
+
const commentMode = (canvas: Canvas) => $(canvas, "gd-comment").dispatch("click");
|
|
34
|
+
const tallViewport = (canvas: Canvas) => { canvas.viewport.rect = { left: 0, top: 50, width: 1000, height: 1400 }; };
|
|
35
|
+
|
|
36
|
+
const deviceButton = (canvas: Canvas) => $(canvas, "gd-device");
|
|
37
|
+
const deviceMenu = (canvas: Canvas) => $(canvas, "gd-device-menu");
|
|
38
|
+
const deviceItems = (canvas: Canvas) => findAll(deviceMenu(canvas), (element) => element.getAttribute("role") === "menuitemradio");
|
|
39
|
+
const openDevices = (canvas: Canvas) => { if (deviceMenu(canvas).hidden) deviceButton(canvas).dispatch("click"); };
|
|
40
|
+
const chooseSize = (canvas: Canvas, size: string) => {
|
|
41
|
+
openDevices(canvas);
|
|
42
|
+
deviceItems(canvas).find((item) => item.dataset.size === size)!.dispatch("click");
|
|
43
|
+
};
|
|
44
|
+
const pressedSizes = (canvas: Canvas) => {
|
|
45
|
+
const closed = deviceMenu(canvas).hidden;
|
|
46
|
+
openDevices(canvas);
|
|
47
|
+
const sizes = deviceItems(canvas).filter((item) => item.getAttribute("aria-checked") === "true").map((item) => item.dataset.size);
|
|
48
|
+
if (closed) deviceButton(canvas).dispatch("click");
|
|
49
|
+
return sizes;
|
|
50
|
+
};
|
|
51
|
+
const readout = (canvas: Canvas) => [$(canvas, "gd-device-name").textContent, $(canvas, "gd-device-size").textContent].filter(Boolean).join(" ");
|
|
52
|
+
const setCustom = (canvas: Canvas, value: string) => {
|
|
53
|
+
openDevices(canvas);
|
|
54
|
+
const input = withClass(deviceMenu(canvas), "gd-device-input")[0];
|
|
55
|
+
input.value = value;
|
|
56
|
+
// A custom width applies on Enter only (leaving the field applies nothing).
|
|
57
|
+
input.dispatch("keydown", { key: "Enter" });
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const sizeSections = (canvas: Canvas) => withClass(canvas.viewport, "gd-size-frame");
|
|
61
|
+
const iframeOf = (root: FakeElement) => findAll(root, (element) => element.localName === "iframe")[0];
|
|
62
|
+
const overflowChip = (root: FakeElement) => withClass(root, "gd-overflow-flag")[0];
|
|
63
|
+
const report = (width: number, scrollWidth: number) => ({ type: "gd:overflow", overflow: scrollWidth > width, width, scrollWidth });
|
|
64
|
+
const scaleOf = (section: FakeElement) => Number(/^scale\(([\d.]+)\)$/.exec(withClass(section, "gd-size-stage")[0].style.transform)?.[1]);
|
|
65
|
+
|
|
66
|
+
function comment(id: string, file: string, status = "open", extra: Record<string, unknown> = {}) {
|
|
67
|
+
return { id, file, selector: `main > .${id}`, excerpt: "", comment: `Text of ${id}`, status, sentAt: null, ...extra };
|
|
68
|
+
}
|
|
69
|
+
const commentsDoc = (...comments: unknown[]) => ({ "/t/api/designs/alpha/comments": { comments } });
|
|
70
|
+
async function setComments(canvas: Canvas, ...comments: unknown[]) {
|
|
71
|
+
canvas.replies["/t/api/designs/alpha/comments"] = { comments };
|
|
72
|
+
await canvas.serverEvent("change", { slug: "alpha", file: "comments.json" });
|
|
73
|
+
}
|
|
74
|
+
const lastOf = (frame: FakeElement, type: string) => frame.contentWindow!.posted.filter((message) => message.type === type).at(-1);
|
|
75
|
+
const commentPosts = (canvas: Canvas) => canvas.posts.filter((post) => post.url === "/t/api/comments").map((post) => post.body as Record<string, any>);
|
|
76
|
+
|
|
77
|
+
// ---- the frames (S3)
|
|
78
|
+
|
|
79
|
+
test("All sizes shows Phone, Tablet and the artboard as designed as real iframes at their true widths, scaled to fit together and labeled", async () => {
|
|
80
|
+
const canvas = await loadSizes(WIDE_ALPHA);
|
|
81
|
+
const [first] = canvas.boards;
|
|
82
|
+
focusOn(canvas);
|
|
83
|
+
const src = first.frame.src;
|
|
84
|
+
openDevices(canvas);
|
|
85
|
+
const all = deviceItems(canvas).find((item) => item.dataset.size === "all")!;
|
|
86
|
+
assert.deepEqual(deviceItems(canvas).map((item) => item.dataset.size), ["phone", "tablet", "desktop", "all"], "All sizes comes after the presets");
|
|
87
|
+
assert.equal(all.title, "All sizes: Phone, Tablet and the artboard as designed, side by side");
|
|
88
|
+
assert.deepEqual(texts(all, "gd-menu-label"), ["All sizes"]);
|
|
89
|
+
assert.deepEqual(texts(all, "gd-device-dim"), [], "no single size to show");
|
|
90
|
+
assert.equal(withClass(all, "gd-i")[0].children[0].getAttribute("href"), "#i-devices");
|
|
91
|
+
all.dispatch("click");
|
|
92
|
+
assert.deepEqual(pressedSizes(canvas), ["all"]);
|
|
93
|
+
assert.equal(readout(canvas), "All sizes");
|
|
94
|
+
assert.equal($(canvas, "gd-device-icon").getAttribute("href"), "#i-devices");
|
|
95
|
+
assert.equal(deviceButton(canvas).getAttribute("aria-label"), "Preview size: All sizes");
|
|
96
|
+
assert.ok(first.wrapper.classes.has("gd-all-sizes"));
|
|
97
|
+
|
|
98
|
+
const views = withClass(canvas.viewport, "gd-sizes-all");
|
|
99
|
+
assert.equal(views.length, 1);
|
|
100
|
+
assert.equal(canvas.viewport.children.filter((child) => child.classes.has("gd-sizes-all")).length, 1, "outside the transformed world");
|
|
101
|
+
assert.equal(views[0].getAttribute("role"), "group");
|
|
102
|
+
assert.equal(views[0].getAttribute("aria-label"), "All sizes");
|
|
103
|
+
const sections = sizeSections(canvas);
|
|
104
|
+
assert.deepEqual(sections.map((section) => section.getAttribute("aria-label")), ["Phone 390 by 844", "Tablet 820 by 1180", "As designed 1200 by 800"]);
|
|
105
|
+
const frames = sections.map(iframeOf);
|
|
106
|
+
assert.deepEqual(frames.map((frame) => [frame.style.width, frame.style.height]), [["390px", "844px"], ["820px", "1180px"], ["1200px", "800px"]]);
|
|
107
|
+
for (const frame of frames) {
|
|
108
|
+
assert.equal(frame.getAttribute("sandbox"), "allow-scripts");
|
|
109
|
+
assert.equal(frame.getAttribute("referrerpolicy"), "no-referrer");
|
|
110
|
+
assert.equal(frame.src, "/t/files/alpha/01-a.html");
|
|
111
|
+
}
|
|
112
|
+
assert.deepEqual(frames.map((frame) => frame.title), ["First artboard at Phone 390 × 844", "First artboard at Tablet 820 × 1180", "First artboard as designed, 1200 × 800"]);
|
|
113
|
+
|
|
114
|
+
// One scale for the three, small enough that they fit the viewport together.
|
|
115
|
+
const scales = sections.map(scaleOf);
|
|
116
|
+
assert.ok(scales.every((scale) => scale === scales[0] && scale > 0 && scale < 1));
|
|
117
|
+
const boxes = sections.map((section) => withClass(section, "gd-size-scaled")[0]);
|
|
118
|
+
const widths = boxes.map((box) => Number.parseInt(box.style.width, 10));
|
|
119
|
+
const heights = boxes.map((box) => Number.parseInt(box.style.height, 10));
|
|
120
|
+
assert.deepEqual(widths, [390, 820, 1200].map((width) => Math.round(width * scales[0])));
|
|
121
|
+
assert.deepEqual(heights, [844, 1180, 800].map((height) => Math.round(height * scales[0])));
|
|
122
|
+
assert.ok(widths.reduce((sum, width) => sum + width, 0) <= 1000 - 16 - 40, "side by side within the viewport width, less the margins and gaps");
|
|
123
|
+
// Below the 8 px margin and 8 px more, a 28 px band per label, and above the 48 px Back to canvas band.
|
|
124
|
+
assert.ok(Math.max(...heights) <= 700 - 8 - 8 - 28 - 48, "and above the Back to canvas band");
|
|
125
|
+
assert.deepEqual([views[0].style.left, views[0].style.right, views[0].style.top, views[0].style.bottom], ["8px", "8px", "16px", "48px"]);
|
|
126
|
+
const percent = Math.round(scales[0] * 100);
|
|
127
|
+
assert.deepEqual(sections.map((section) => texts(section, "gd-size-name")[0]), ["Phone", "Tablet", "As designed"], "L12: the third frame is the artboard as designed, never Desktop");
|
|
128
|
+
assert.deepEqual(sections.map((section) => texts(section, "gd-size-dim")[0]), ["390 × 844", "820 × 1180", "1200 × 800"]);
|
|
129
|
+
assert.deepEqual(sections.map((section) => texts(section, "gd-size-scale")[0]), [`· ${percent}%`, `· ${percent}%`, `· ${percent}%`]);
|
|
130
|
+
assert.equal(withClass(sections[0], "gd-i").length, 1, "each label carries its icon");
|
|
131
|
+
assert.deepEqual(sections.map((section) => withClass(section, "gd-i")[0].children[0].getAttribute("href")), ["#i-phone", "#i-tablet", "#i-fit"], "the artboard's own size, not a monitor");
|
|
132
|
+
assert.equal(canvas.zoomLevel.textContent, "100%", "the label stays at 100% above the frames");
|
|
133
|
+
|
|
134
|
+
assert.equal(first.frame.src, src, "the artboard's own iframe is not reloaded");
|
|
135
|
+
chooseSize(canvas, "desktop");
|
|
136
|
+
assert.equal(sizeSections(canvas).length, 0, "leaving All sizes removes the extra frames");
|
|
137
|
+
assert.equal(withClass(canvas.viewport, "gd-sizes-all").length, 0);
|
|
138
|
+
assert.ok(!first.wrapper.classes.has("gd-all-sizes"));
|
|
139
|
+
assert.equal(first.frame.style.width, "1200px");
|
|
140
|
+
assert.equal(first.frame.src, src);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("Back to canvas and focusing another artboard leave All sizes and restore the manifest size", async () => {
|
|
144
|
+
const canvas = await loadSizes({ ...WIDE_ALPHA, "/t/api/system": { exists: true, file: "system.html", width: 800, height: 600 } });
|
|
145
|
+
// The system board comes first.
|
|
146
|
+
const first = canvas.boards[1];
|
|
147
|
+
focusOn(canvas, 1);
|
|
148
|
+
chooseSize(canvas, "all");
|
|
149
|
+
assert.equal(sizeSections(canvas).length, 3);
|
|
150
|
+
back(canvas);
|
|
151
|
+
assert.equal(sizeSections(canvas).length, 0);
|
|
152
|
+
assert.equal(first.frame.style.width, "1200px");
|
|
153
|
+
assert.ok(!first.wrapper.classes.has("gd-all-sizes"));
|
|
154
|
+
assert.equal(readout(canvas), "Desktop");
|
|
155
|
+
|
|
156
|
+
focusOn(canvas, 1);
|
|
157
|
+
chooseSize(canvas, "all");
|
|
158
|
+
// Settings > Design system board focuses another artboard.
|
|
159
|
+
$(canvas, "gd-rail-settings").dispatch("click");
|
|
160
|
+
findAll($(canvas, "gd-menu"), (element) => element.getAttribute("role") === "menuitem" && texts(element, "gd-menu-label")[0] === "Design system board")[0].dispatch("click");
|
|
161
|
+
assert.equal(sizeSections(canvas).length, 0, "another artboard starts at Desktop");
|
|
162
|
+
assert.ok(!first.wrapper.classes.has("gd-all-sizes"));
|
|
163
|
+
assert.deepEqual(pressedSizes(canvas), ["desktop"]);
|
|
164
|
+
// The system board shows at every size too, and takes no comments there.
|
|
165
|
+
chooseSize(canvas, "all");
|
|
166
|
+
assert.deepEqual(sizeSections(canvas).map((section) => section.getAttribute("aria-label")), ["Phone 390 by 844", "Tablet 820 by 1180", "As designed 800 by 600"]);
|
|
167
|
+
assert.equal(iframeOf(sizeSections(canvas)[0]).src, "/t/system.html");
|
|
168
|
+
commentMode(canvas);
|
|
169
|
+
const phone = iframeOf(sizeSections(canvas)[0]);
|
|
170
|
+
phone.dispatch("load");
|
|
171
|
+
assert.deepEqual(lastOf(phone, "gd:mode"), { type: "gd:mode", enabled: false, inspect: false });
|
|
172
|
+
assert.equal(phone.contentWindow!.posted.filter((message) => message.type === "gd:pins").length, 0, "no pins either");
|
|
173
|
+
canvas.message(phone.contentWindow, inspectorPick(phone, { type: "gd:pick", selector: "#x", excerpt: "", rect: { x: 0, y: 0, width: 1, height: 1 } }));
|
|
174
|
+
assert.equal($(canvas, "gd-popover").hidden, true);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("All sizes follows the viewport and a manifest refresh, and live reload reloads the size frames", async () => {
|
|
178
|
+
const canvas = await loadSizes(WIDE_ALPHA);
|
|
179
|
+
focusOn(canvas);
|
|
180
|
+
chooseSize(canvas, "all");
|
|
181
|
+
const before = scaleOf(sizeSections(canvas)[0]);
|
|
182
|
+
canvas.viewport.rect = { left: 0, top: 50, width: 700, height: 700 };
|
|
183
|
+
canvas.windowEvent("resize");
|
|
184
|
+
assert.ok(scaleOf(sizeSections(canvas)[0]) < before, "a narrower viewport scales the sizes down");
|
|
185
|
+
assert.equal(sizeSections(canvas).length, 3, "the same frames, laid out again");
|
|
186
|
+
|
|
187
|
+
await canvas.serverEvent("change", { slug: "alpha", file: "01-a.html" });
|
|
188
|
+
assert.ok(sizeSections(canvas).map(iframeOf).every((frame) => /^\/t\/files\/alpha\/01-a\.html\?v=\d+$/.test(frame.src)), "every size frame reloads");
|
|
189
|
+
assert.match(canvas.boards[0].frame.src, /^\/t\/files\/alpha\/01-a\.html\?v=\d+$/, "and the artboard's own frame");
|
|
190
|
+
assert.equal(sizeSections(canvas).length, 3);
|
|
191
|
+
|
|
192
|
+
await canvas.serverEvent("show", { slug: "alpha" });
|
|
193
|
+
assert.equal(sizeSections(canvas).length, 3, "a refresh keeps All sizes, with no orphaned frames");
|
|
194
|
+
assert.equal(canvas.viewport.children.filter((child) => child.classes.has("gd-sizes-all")).length, 1);
|
|
195
|
+
assert.deepEqual(pressedSizes(canvas), ["all"]);
|
|
196
|
+
assert.ok(canvas.world.children[0].classes.has("gd-all-sizes"), "the refreshed artboard wears it");
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test("E5: the server switching to the system-only view leaves no All sizes frames behind", async () => {
|
|
200
|
+
const canvas = await loadSizes({ ...WIDE_ALPHA, "/t/api/system": { exists: true, file: "system.html", width: 800, height: 600 } });
|
|
201
|
+
focusOn(canvas, 1);
|
|
202
|
+
chooseSize(canvas, "all");
|
|
203
|
+
assert.equal(withClass(canvas.viewport, "gd-sizes-all").length, 1);
|
|
204
|
+
await canvas.serverEvent("show", { slug: null });
|
|
205
|
+
assert.equal(withClass(canvas.viewport, "gd-sizes-all").length, 0, "no size frames left in the viewport");
|
|
206
|
+
assert.equal(sizeSections(canvas).length, 0);
|
|
207
|
+
assert.equal(canvas.navMode.textContent, "Navigating");
|
|
208
|
+
assert.equal(canvas.world.children.length, 1, "only the system board is shown");
|
|
209
|
+
assert.equal(canvas.world.children.filter((child) => child.classes.has("gd-all-sizes")).length, 0);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test("size frames are registered like the artboard's frame: they get focus, mode and pins when they load", async () => {
|
|
213
|
+
const canvas = await loadSizes({ ...WIDE_ALPHA, ...commentsDoc(comment("a1", "01-a.html")) });
|
|
214
|
+
focusOn(canvas);
|
|
215
|
+
chooseSize(canvas, "all");
|
|
216
|
+
const frames = sizeSections(canvas).map(iframeOf);
|
|
217
|
+
for (const frame of frames) {
|
|
218
|
+
frame.dispatch("load");
|
|
219
|
+
assert.deepEqual(lastOf(frame, "gd:focus"), { type: "gd:focus", enabled: true });
|
|
220
|
+
assert.deepEqual(lastOf(frame, "gd:mode"), { type: "gd:mode", enabled: false, inspect: false });
|
|
221
|
+
assert.deepEqual(lastOf(frame, "gd:pins"), { type: "gd:pins", pins: [{ id: "a1", selector: "main > .a1" }] });
|
|
222
|
+
}
|
|
223
|
+
commentMode(canvas);
|
|
224
|
+
for (const frame of frames) assert.deepEqual(frame.contentWindow!.posted.at(-1), { type: "gd:mode", enabled: true, inspect: false });
|
|
225
|
+
assert.ok(withClass(canvas.viewport, "gd-sizes-all")[0].classes.has("gd-commenting"), "the frames wear the comment-mode outline");
|
|
226
|
+
$(canvas, "gd-tool-navigate").dispatch("click");
|
|
227
|
+
for (const frame of frames) assert.deepEqual(frame.contentWindow!.posted.at(-1), { type: "gd:mode", enabled: false, inspect: false });
|
|
228
|
+
assert.ok(!withClass(canvas.viewport, "gd-sizes-all")[0].classes.has("gd-commenting"));
|
|
229
|
+
// Frames made while Comment mode is on start with the outline.
|
|
230
|
+
commentMode(canvas);
|
|
231
|
+
chooseSize(canvas, "phone");
|
|
232
|
+
chooseSize(canvas, "all");
|
|
233
|
+
assert.ok(withClass(canvas.viewport, "gd-sizes-all")[0].classes.has("gd-commenting"));
|
|
234
|
+
back(canvas);
|
|
235
|
+
for (const frame of frames) assert.deepEqual(lastOf(frame, "gd:focus"), { type: "gd:focus", enabled: true }, "removed frames hear nothing more");
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// ---- picks and pins (S4)
|
|
239
|
+
|
|
240
|
+
const PICK = { type: "gd:pick", selector: "#cta", excerpt: "Buy", rect: { x: 30, y: 40, width: 60, height: 20 } };
|
|
241
|
+
|
|
242
|
+
test("in All sizes every size frame takes picks; the popover opens beside the picked element in that frame", async () => {
|
|
243
|
+
const canvas = await loadSizes(WIDE_ALPHA);
|
|
244
|
+
focusOn(canvas);
|
|
245
|
+
chooseSize(canvas, "all");
|
|
246
|
+
const [phone, tablet, designed] = sizeSections(canvas).map(iframeOf);
|
|
247
|
+
const popover = $(canvas, "gd-popover");
|
|
248
|
+
|
|
249
|
+
canvas.message(phone.contentWindow, inspectorPick(phone, PICK));
|
|
250
|
+
assert.equal(popover.hidden, true, "a pick needs Comment mode");
|
|
251
|
+
commentMode(canvas);
|
|
252
|
+
canvas.message({}, PICK);
|
|
253
|
+
assert.equal(popover.hidden, true, "a stranger window is ignored");
|
|
254
|
+
|
|
255
|
+
phone.rect = { left: 100, top: 200, width: 150, height: 325 };
|
|
256
|
+
canvas.message(phone.contentWindow, inspectorPick(phone, PICK));
|
|
257
|
+
assert.equal(popover.hidden, false);
|
|
258
|
+
assert.equal($(canvas, "gd-popover-target").textContent, "01-a.html · #cta");
|
|
259
|
+
// The frame is shown at 150/390 of its width.
|
|
260
|
+
assert.equal(popover.style.left, `${100 + 30 * (150 / 390)}px`);
|
|
261
|
+
assert.equal(popover.style.top, `${200 + (40 + 20) * (150 / 390) + 8}px`);
|
|
262
|
+
|
|
263
|
+
$(canvas, "gd-popover-text").value = "Tighter";
|
|
264
|
+
$(canvas, "gd-popover-form").dispatch("submit");
|
|
265
|
+
await flush();
|
|
266
|
+
assert.deepEqual(commentPosts(canvas).map((body) => [body.slug, body.file, body.selector]), [["alpha", "01-a.html", "#cta"]]);
|
|
267
|
+
|
|
268
|
+
$(canvas, "gd-popover-cancel").dispatch("click");
|
|
269
|
+
assert.deepEqual(phone.contentWindow!.posted.at(-1), { type: "gd:clear" }, "the frame that was picked clears its outline");
|
|
270
|
+
designed.rect = { left: 300, top: 100, width: 400, height: 267 };
|
|
271
|
+
canvas.message(designed.contentWindow, inspectorPick(designed, PICK));
|
|
272
|
+
assert.equal(popover.hidden, false, "the as designed frame takes picks too");
|
|
273
|
+
assert.equal(popover.style.left, `${300 + 30 * (400 / 1200)}px`);
|
|
274
|
+
assert.match(canvas.navMode.textContent, /^Using:/);
|
|
275
|
+
canvas.message(tablet.contentWindow, { type: "gd:exit-focus" });
|
|
276
|
+
assert.doesNotMatch(canvas.navMode.textContent, /^Using:/, "Shift+Esc from a size frame leaves focus mode");
|
|
277
|
+
assert.equal(sizeSections(canvas).length, 0);
|
|
278
|
+
assert.equal(popover.hidden, true);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test("a pick from another artboard is refused while one is focused, also with its size frames shown", async () => {
|
|
282
|
+
const canvas = await loadSizes(WIDE_ALPHA);
|
|
283
|
+
focusOn(canvas);
|
|
284
|
+
chooseSize(canvas, "all");
|
|
285
|
+
commentMode(canvas);
|
|
286
|
+
canvas.message(canvas.boards[1].frame.contentWindow, inspectorPick(canvas.boards[1].frame, { type: "gd:pick", selector: "#x", excerpt: "", rect: { x: 0, y: 0, width: 1, height: 1 } }));
|
|
287
|
+
assert.equal($(canvas, "gd-popover").hidden, true);
|
|
288
|
+
// A frame that was removed is a stranger.
|
|
289
|
+
const [phone] = sizeSections(canvas).map(iframeOf);
|
|
290
|
+
chooseSize(canvas, "tablet");
|
|
291
|
+
canvas.message(phone.contentWindow, inspectorPick(phone, PICK));
|
|
292
|
+
assert.equal($(canvas, "gd-popover").hidden, true);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test("a wheel from a size frame lands where it is under the pointer, at that frame's scale", async () => {
|
|
296
|
+
const canvas = await loadSizes(WIDE_ALPHA);
|
|
297
|
+
focusOn(canvas);
|
|
298
|
+
chooseSize(canvas, "all");
|
|
299
|
+
const [phone] = sizeSections(canvas).map(iframeOf);
|
|
300
|
+
phone.rect = { left: 100, top: 200, width: 195, height: 422 };
|
|
301
|
+
const before = canvas.world.style.transform;
|
|
302
|
+
// Focus mode keeps the canvas still: the forwarded wheel is accepted and changes nothing.
|
|
303
|
+
canvas.message(phone.contentWindow, { type: "gd:wheel", deltaX: 0, deltaY: 40, deltaMode: 0, zoom: false, shift: false, x: 10, y: 10 });
|
|
304
|
+
assert.equal(canvas.world.style.transform, before);
|
|
305
|
+
assert.match(read("canvas-messages.js"), /frameRect\.width \/ surface\.viewWidth/, "the scale is the frame's own width");
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
test("the pins of the artboard show on every size frame at their element's position in that frame", async () => {
|
|
309
|
+
const canvas = await loadSizes({ ...WIDE_ALPHA, ...commentsDoc(comment("a1", "01-a.html"), comment("b1", "02-b.html")) });
|
|
310
|
+
focusOn(canvas);
|
|
311
|
+
chooseSize(canvas, "all");
|
|
312
|
+
const sections = sizeSections(canvas);
|
|
313
|
+
const [phone, tablet, desktop] = sections.map(iframeOf);
|
|
314
|
+
const pinsOf = (section: FakeElement) => withClass(section, "gd-pin");
|
|
315
|
+
assert.deepEqual(sections.map((section) => pinsOf(section).length), [0, 0, 0], "none until a frame reports where the element is");
|
|
316
|
+
|
|
317
|
+
canvas.message(phone.contentWindow, { type: "gd:pin-rects", rects: [{ id: "a1", rect: { x: 30, y: 40, width: 60, height: 20 } }] });
|
|
318
|
+
canvas.message(desktop.contentWindow, { type: "gd:pin-rects", rects: [{ id: "a1", rect: { x: 300, y: 10, width: 60, height: 20 } }] });
|
|
319
|
+
assert.deepEqual(pinsOf(sections[0]).map((pin) => [pin.style.left, pin.style.top, pin.textContent]), [["30px", "40px", "1"]]);
|
|
320
|
+
assert.equal(pinsOf(sections[1]).length, 0, "the Tablet frame has not reported yet");
|
|
321
|
+
assert.deepEqual(pinsOf(sections[2]).map((pin) => [pin.style.left, pin.style.top]), [["300px", "10px"]]);
|
|
322
|
+
assert.equal(pinsOf(sections[0])[0].getAttribute("aria-label"), "Comment 1 (open): Text of a1");
|
|
323
|
+
assert.equal(withClass(canvas.boards[0].wrapper, "gd-pin").length, 0, "a size frame's report never pins the artboard's own frame");
|
|
324
|
+
|
|
325
|
+
// An element outside the frame at that size has no pin there; the other artboard's comments never show.
|
|
326
|
+
canvas.message(tablet.contentWindow, { type: "gd:pin-rects", rects: [{ id: "a1", rect: { x: 900, y: 10, width: 60, height: 20 } }, { id: "b1", rect: { x: 5, y: 5, width: 5, height: 5 } }] });
|
|
327
|
+
assert.equal(pinsOf(sections[1]).length, 0);
|
|
328
|
+
canvas.message(phone.contentWindow, { type: "gd:pin-rects", rects: [{ id: "a1", rect: { x: 500, y: 40, width: 60, height: 20 } }] });
|
|
329
|
+
assert.equal(pinsOf(sections[0]).length, 0, "x 500 is outside the 390 px frame");
|
|
330
|
+
canvas.message(phone.contentWindow, { type: "gd:pin-rects", rects: [{ id: "a1", rect: { x: 30, y: 40, width: 60, height: 20 } }] });
|
|
331
|
+
|
|
332
|
+
// Only the artboard's own frame says whether a comment is detached.
|
|
333
|
+
canvas.message(phone.contentWindow, { type: "gd:pin-rects", rects: [{ id: "a1", rect: null }] });
|
|
334
|
+
assert.equal(texts($(canvas, "gd-comment-list"), "gd-badge-detached").length, 0);
|
|
335
|
+
canvas.message(phone.contentWindow, { type: "gd:pin-rects", rects: [{ id: "a1", rect: { x: 30, y: 40, width: 60, height: 20 } }] });
|
|
336
|
+
|
|
337
|
+
// Selecting a pin highlights the element in every frame.
|
|
338
|
+
pinsOf(sections[0])[0].dispatch("click");
|
|
339
|
+
for (const frame of [phone, tablet, desktop, canvas.boards[0].frame]) assert.deepEqual(frame.contentWindow!.posted.at(-1), { type: "gd:highlight", id: "a1" });
|
|
340
|
+
|
|
341
|
+
// New comments reach every frame.
|
|
342
|
+
await setComments(canvas, comment("a1", "01-a.html"), comment("a2", "01-a.html"));
|
|
343
|
+
for (const frame of [phone, tablet, desktop]) assert.equal(lastOf(frame, "gd:pins").pins.length, 2);
|
|
344
|
+
assert.equal(pinsOf(sizeSections(canvas)[0]).length, 1, "the pins are drawn again with the new list");
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
// ---- the Overflows chip (S5)
|
|
348
|
+
|
|
349
|
+
test("a size whose page is wider than its frame shows an Overflows chip titled with the width; none when it fits", async () => {
|
|
350
|
+
const canvas = await loadSizes();
|
|
351
|
+
tallViewport(canvas);
|
|
352
|
+
const [first] = canvas.boards;
|
|
353
|
+
const chip = overflowChip(first.wrapper);
|
|
354
|
+
assert.equal(chip.hidden, true);
|
|
355
|
+
assert.equal(chip.parentElement === first.frame.parentElement, true, "it sits on the artboard's frame");
|
|
356
|
+
focusOn(canvas);
|
|
357
|
+
chooseSize(canvas, "phone");
|
|
358
|
+
assert.equal(chip.hidden, true, "no chip before the page reports");
|
|
359
|
+
|
|
360
|
+
canvas.message(first.frame.contentWindow, report(390, 520));
|
|
361
|
+
assert.equal(chip.hidden, false);
|
|
362
|
+
assert.deepEqual(texts(chip, "gd-overflow-text"), ["Overflows"]);
|
|
363
|
+
assert.equal(chip.title, "Content is wider than 390 px, so part of it is cut off or needs sideways scrolling at this size.");
|
|
364
|
+
assert.deepEqual(texts(chip, "gd-visually-hidden"), [chip.title], "the explanation reaches assistive technology too");
|
|
365
|
+
|
|
366
|
+
canvas.message(first.frame.contentWindow, report(390, 390));
|
|
367
|
+
assert.equal(chip.hidden, true, "no chip when it fits");
|
|
368
|
+
canvas.message(first.frame.contentWindow, report(390, 520));
|
|
369
|
+
assert.equal(chip.hidden, false);
|
|
370
|
+
|
|
371
|
+
// Reports for another width are stale; strangers and malformed reports are ignored.
|
|
372
|
+
chooseSize(canvas, "tablet");
|
|
373
|
+
assert.equal(chip.hidden, true, "a new size clears the chip until the page reports again");
|
|
374
|
+
canvas.message(first.frame.contentWindow, report(390, 520));
|
|
375
|
+
assert.equal(chip.hidden, true, "a late report for the previous width is ignored");
|
|
376
|
+
canvas.message({}, report(820, 900));
|
|
377
|
+
assert.equal(chip.hidden, true);
|
|
378
|
+
canvas.message(first.frame.contentWindow, { type: "gd:overflow", overflow: true, width: "820", scrollWidth: 900 });
|
|
379
|
+
canvas.message(first.frame.contentWindow, { type: "gd:overflow", overflow: "yes", width: 820, scrollWidth: 900 });
|
|
380
|
+
canvas.message(first.frame.contentWindow, { type: "gd:overflow", overflow: true, width: 820, scrollWidth: null });
|
|
381
|
+
assert.equal(chip.hidden, true);
|
|
382
|
+
canvas.message(first.frame.contentWindow, report(820, 900));
|
|
383
|
+
assert.match(chip.title, /wider than 820 px/);
|
|
384
|
+
assert.equal(chip.hidden, false);
|
|
385
|
+
first.frame.dispatch("load");
|
|
386
|
+
assert.equal(chip.hidden, true, "a reloaded artboard reports again");
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
test("in All sizes each size frame has its own chip", async () => {
|
|
390
|
+
const canvas = await loadSizes(WIDE_ALPHA);
|
|
391
|
+
focusOn(canvas);
|
|
392
|
+
chooseSize(canvas, "all");
|
|
393
|
+
const sections = sizeSections(canvas);
|
|
394
|
+
const [phone, tablet, desktop] = sections.map(iframeOf);
|
|
395
|
+
assert.deepEqual(sections.map((section) => overflowChip(section).hidden), [true, true, true]);
|
|
396
|
+
canvas.message(tablet.contentWindow, report(820, 1010));
|
|
397
|
+
assert.deepEqual(sections.map((section) => overflowChip(section).hidden), [true, false, true]);
|
|
398
|
+
assert.match(overflowChip(sections[1]).title, /wider than 820 px/);
|
|
399
|
+
canvas.message(phone.contentWindow, report(390, 390));
|
|
400
|
+
canvas.message(desktop.contentWindow, report(1200, 1200));
|
|
401
|
+
assert.deepEqual(sections.map((section) => overflowChip(section).hidden), [true, false, true]);
|
|
402
|
+
canvas.message(tablet.contentWindow, report(820, 820));
|
|
403
|
+
assert.deepEqual(sections.map((section) => overflowChip(section).hidden), [true, true, true]);
|
|
404
|
+
canvas.message(tablet.contentWindow, report(820, 1010));
|
|
405
|
+
tablet.dispatch("load");
|
|
406
|
+
assert.equal(overflowChip(sections[1]).hidden, true, "a reloaded frame reports again");
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
test("the artboard's own chip shows only while focused at a single size, and a report made earlier shows on focus", async () => {
|
|
410
|
+
// canvas-layout S8: Desktop is the artboard's own width only when it is wider than the viewport, so a 1200 px one here.
|
|
411
|
+
const canvas = await loadSizes(WIDE_ALPHA);
|
|
412
|
+
const [first] = canvas.boards;
|
|
413
|
+
const chip = overflowChip(first.wrapper);
|
|
414
|
+
canvas.message(first.frame.contentWindow, report(1200, 1250));
|
|
415
|
+
assert.equal(chip.hidden, true, "not on the canvas overview");
|
|
416
|
+
focusOn(canvas);
|
|
417
|
+
assert.equal(chip.hidden, false, "Desktop is 1200 px wide: the earlier report applies");
|
|
418
|
+
chooseSize(canvas, "all");
|
|
419
|
+
assert.equal(chip.hidden, true, "All sizes has a chip per frame instead");
|
|
420
|
+
back(canvas);
|
|
421
|
+
assert.equal(chip.hidden, true);
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
test("the system board never shows the chip", async () => {
|
|
425
|
+
const canvas = await loadSizes({ "/t/api/system": { exists: true, file: "system.html", width: 800, height: 600 } });
|
|
426
|
+
const [system] = canvas.boards;
|
|
427
|
+
focusOn(canvas, 0);
|
|
428
|
+
tallViewport(canvas);
|
|
429
|
+
chooseSize(canvas, "phone");
|
|
430
|
+
canvas.message(system.frame.contentWindow, report(390, 520));
|
|
431
|
+
assert.equal(overflowChip(system.wrapper).hidden, true);
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
// ---- the size a comment was made at (S7)
|
|
435
|
+
|
|
436
|
+
const submitComment = async (canvas: Canvas, text = "Tighter") => {
|
|
437
|
+
$(canvas, "gd-popover-text").value = text;
|
|
438
|
+
$(canvas, "gd-popover-form").dispatch("submit");
|
|
439
|
+
await flush();
|
|
440
|
+
return commentPosts(canvas).at(-1)!;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
test("L12: a comment made at the manifest size or at Desktop carries no viewport: Desktop is the window's width, not a size of the design", async () => {
|
|
444
|
+
const canvas = await loadSizes();
|
|
445
|
+
tallViewport(canvas);
|
|
446
|
+
const [first] = canvas.boards;
|
|
447
|
+
commentMode(canvas);
|
|
448
|
+
first.frame.rect = { left: 0, top: 0, width: 400, height: 300 };
|
|
449
|
+
canvas.message(first.frame.contentWindow, inspectorPick(first.frame, PICK));
|
|
450
|
+
assert.equal("viewport" in await submitComment(canvas), false, "not focused");
|
|
451
|
+
focusOn(canvas);
|
|
452
|
+
first.frame.rect = { left: 0, top: 0, width: 984, height: 300 };
|
|
453
|
+
canvas.message(first.frame.contentWindow, inspectorPick(first.frame, PICK));
|
|
454
|
+
assert.equal($(canvas, "gd-device-size").textContent, "984 × 300", "Desktop fills the window here (canvas-layout S8)");
|
|
455
|
+
assert.equal("viewport" in await submitComment(canvas), false, "Desktop records no size");
|
|
456
|
+
// A custom width equal to the manifest width is the manifest size too.
|
|
457
|
+
setCustom(canvas, "400");
|
|
458
|
+
canvas.message(first.frame.contentWindow, inspectorPick(first.frame, PICK));
|
|
459
|
+
assert.equal("viewport" in await submitComment(canvas), false);
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
test("a comment at a preset or custom width carries the viewport of that size, with the manifest height for a custom width", async () => {
|
|
463
|
+
const canvas = await loadSizes();
|
|
464
|
+
tallViewport(canvas);
|
|
465
|
+
const [first] = canvas.boards;
|
|
466
|
+
focusOn(canvas);
|
|
467
|
+
commentMode(canvas);
|
|
468
|
+
first.frame.rect = { left: 0, top: 0, width: 390, height: 844 };
|
|
469
|
+
const sizes: Array<Array<string | number>> = [];
|
|
470
|
+
const viewportOf = async () => {
|
|
471
|
+
canvas.message(first.frame.contentWindow, inspectorPick(first.frame, PICK));
|
|
472
|
+
const { viewport } = await submitComment(canvas);
|
|
473
|
+
return viewport ? [viewport.width, viewport.height] : ["none"];
|
|
474
|
+
};
|
|
475
|
+
chooseSize(canvas, "phone");
|
|
476
|
+
sizes.push(["phone", ...(await viewportOf())]);
|
|
477
|
+
chooseSize(canvas, "tablet");
|
|
478
|
+
sizes.push(["tablet", ...(await viewportOf())]);
|
|
479
|
+
setCustom(canvas, "720");
|
|
480
|
+
sizes.push(["custom", ...(await viewportOf())]);
|
|
481
|
+
// The size is the one at the pick: back at Desktop the next comment records none (L12).
|
|
482
|
+
chooseSize(canvas, "desktop");
|
|
483
|
+
sizes.push(["desktop", ...(await viewportOf())]);
|
|
484
|
+
assert.deepEqual(sizes, [["phone", 390, 844], ["tablet", 820, 1180], ["custom", 720, 300], ["desktop", "none"]]);
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
test("S27: a pick made at Phone whose reply arrives after the switch to Tablet opens no comment box and posts nothing; a pick made at the current size still posts it", async () => {
|
|
488
|
+
const canvas = await loadSizes();
|
|
489
|
+
tallViewport(canvas);
|
|
490
|
+
const [first] = canvas.boards;
|
|
491
|
+
focusOn(canvas);
|
|
492
|
+
commentMode(canvas);
|
|
493
|
+
first.frame.rect = { left: 0, top: 0, width: 390, height: 844 };
|
|
494
|
+
const sent = (body: Record<string, any> | undefined) => (body?.viewport ? `${body.viewport.width} × ${body.viewport.height}` : "none");
|
|
495
|
+
chooseSize(canvas, "phone");
|
|
496
|
+
canvas.message(first.frame.contentWindow, inspectorPick(first.frame, PICK));
|
|
497
|
+
assert.equal(sent(await submitComment(canvas)), "390 × 844", "a pick made and received at Phone");
|
|
498
|
+
|
|
499
|
+
// The page picks at Phone; the reply is still on its way when Tablet resizes the frame.
|
|
500
|
+
const madeAtPhone = inspectorPick(first.frame, PICK);
|
|
501
|
+
chooseSize(canvas, "tablet");
|
|
502
|
+
canvas.message(first.frame.contentWindow, madeAtPhone);
|
|
503
|
+
assert.equal($(canvas, "gd-popover").hidden, true, "the stale pick opens no comment box");
|
|
504
|
+
const before = commentPosts(canvas).length;
|
|
505
|
+
await submitComment(canvas);
|
|
506
|
+
assert.equal(commentPosts(canvas).length, before, "nothing is posted for it");
|
|
507
|
+
assert.ok(!commentPosts(canvas).some((body) => sent(body) === "820 × 1180"), "no comment made at Phone is sent as Tablet");
|
|
508
|
+
|
|
509
|
+
// A pick the page makes once it heard of the new size is Tablet's.
|
|
510
|
+
canvas.message(first.frame.contentWindow, inspectorPick(first.frame, PICK));
|
|
511
|
+
assert.equal(sent(await submitComment(canvas)), "820 × 1180");
|
|
512
|
+
// A pick with no generation cannot say which size it was made at: it is refused too.
|
|
513
|
+
chooseSize(canvas, "phone");
|
|
514
|
+
canvas.message(first.frame.contentWindow, PICK);
|
|
515
|
+
assert.equal($(canvas, "gd-popover").hidden, true, "a pick without a generation is refused");
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
test("in All sizes the comment carries the size of the frame that was picked; the as designed frame is the manifest size", async () => {
|
|
519
|
+
const canvas = await loadSizes();
|
|
520
|
+
focusOn(canvas);
|
|
521
|
+
chooseSize(canvas, "all");
|
|
522
|
+
commentMode(canvas);
|
|
523
|
+
const frames = sizeSections(canvas).map(iframeOf);
|
|
524
|
+
const sent: Array<string> = [];
|
|
525
|
+
for (const frame of frames) {
|
|
526
|
+
frame.rect = { left: 100, top: 100, width: 100, height: 100 };
|
|
527
|
+
canvas.message(frame.contentWindow, inspectorPick(frame, PICK));
|
|
528
|
+
const body = await submitComment(canvas);
|
|
529
|
+
sent.push(body.viewport ? `${body.viewport.width} × ${body.viewport.height}` : "none");
|
|
530
|
+
}
|
|
531
|
+
assert.deepEqual(sent, ["390 × 844", "820 × 1180", "none"], "as designed = the 400 × 300 manifest size");
|
|
532
|
+
// The artboard's own frame is hidden in All sizes; a pick from it records no size.
|
|
533
|
+
canvas.message(canvas.boards[0].frame.contentWindow, inspectorPick(canvas.boards[0].frame, PICK));
|
|
534
|
+
assert.equal("viewport" in await submitComment(canvas), false);
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
test("a viewport the server would refuse is left out of the request instead of failing the comment", async () => {
|
|
538
|
+
const canvas = await loadSizes({}, 30000);
|
|
539
|
+
tallViewport(canvas);
|
|
540
|
+
const [first] = canvas.boards;
|
|
541
|
+
focusOn(canvas);
|
|
542
|
+
commentMode(canvas);
|
|
543
|
+
setCustom(canvas, "600");
|
|
544
|
+
first.frame.rect = { left: 0, top: 0, width: 600, height: 700 };
|
|
545
|
+
canvas.message(first.frame.contentWindow, inspectorPick(first.frame, PICK));
|
|
546
|
+
assert.equal("viewport" in await submitComment(canvas), false, "30000 px is beyond the 20000 px the file accepts");
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
test("the comment card shows the size it was made at: Phone, Tablet or width × height, and nothing without one", async () => {
|
|
550
|
+
const canvas = await loadSizes(commentsDoc(
|
|
551
|
+
comment("a1", "01-a.html", "open", { viewport: { width: 390, height: 844 } }),
|
|
552
|
+
comment("a2", "01-a.html", "open", { viewport: { width: 820, height: 1180 } }),
|
|
553
|
+
comment("a3", "01-a.html", "open", { viewport: { width: 720, height: 820 } }),
|
|
554
|
+
comment("a4", "01-a.html"),
|
|
555
|
+
comment("a5", "01-a.html", "open", { viewport: { width: "wide", height: 820 } }),
|
|
556
|
+
));
|
|
557
|
+
const list = $(canvas, "gd-comment-list");
|
|
558
|
+
assert.equal(list.children.length, 5);
|
|
559
|
+
assert.deepEqual(list.children.map((item) => texts(item, "gd-comment-viewport")), [["Phone 390 × 844"], ["Tablet 820 × 1180"], ["720 × 820"], [], []]);
|
|
560
|
+
assert.equal(withClass(list.children[0], "gd-comment-viewport")[0].title, "Made at Phone 390 × 844");
|
|
561
|
+
await setComments(canvas, comment("a1", "01-a.html", "resolved", { viewport: { width: 390, height: 844 } }));
|
|
562
|
+
$(canvas, "gd-filter-resolved").dispatch("click");
|
|
563
|
+
assert.deepEqual(list.children.map((item) => texts(item, "gd-comment-viewport")), [["Phone 390 × 844"]]);
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
// ---- source pins, markup and styles
|
|
567
|
+
|
|
568
|
+
test("E4: the client's viewport limits and the Phone and Tablet presets match what comments.json accepts and names (lib/design-comments.ts)", () => {
|
|
569
|
+
const sizes = read("canvas-sizes.js");
|
|
570
|
+
const server = readFileSync(fileURLToPath(new URL("../lib/design-comments.ts", import.meta.url)), "utf8");
|
|
571
|
+
const numbers = (text: string) => Object.fromEntries([...text.matchAll(/(\w+): (\d+)/g)].map((match) => [match[1], Number(match[2])]));
|
|
572
|
+
const limits = /const VIEWPORT_LIMITS = (\{[^}]*\});/.exec(sizes);
|
|
573
|
+
assert.ok(limits, "canvas-sizes.js declares VIEWPORT_LIMITS");
|
|
574
|
+
assert.deepEqual(Object.entries(numbers(limits[1])), Object.entries(DESIGN_VIEWPORT_LIMITS));
|
|
575
|
+
const clientPresets = /const SIZE_PRESETS = \[([^]*?)\];/.exec(sizes);
|
|
576
|
+
const serverPresets = /const VIEWPORT_PRESETS[^=]*= \[([^]*?)\];/.exec(server);
|
|
577
|
+
assert.ok(clientPresets && serverPresets, "both declare their presets");
|
|
578
|
+
const nameOf = (kind: string) => new RegExp(`\\n\\t${kind}: "([^"]+)",`).exec(sizes)?.[1];
|
|
579
|
+
const client = [...clientPresets[1].matchAll(/\{ kind: "(\w+)", width: (\d+), height: (\d+) \}/g)].map((match) => `${nameOf(match[1])} ${match[2]} × ${match[3]}`);
|
|
580
|
+
const named = [...serverPresets[1].matchAll(/\{ name: "(\w+)", width: (\d+), height: (\d+) \}/g)].map((match) => `${match[1]} ${match[2]} × ${match[3]}`);
|
|
581
|
+
assert.deepEqual(client, ["Phone 390 × 844", "Tablet 820 × 1180"]);
|
|
582
|
+
assert.deepEqual(named, client, "the server names the same sizes the card names");
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
// Its strings go through ctx.i18n, checked against canvas-i18n-es.js in tests/design-canvas-i18n.test.ts.
|
|
586
|
+
test("All sizes keeps the module rules: state through the store, board fields documented, English strings in TEXT", () => {
|
|
587
|
+
const sizes = read("canvas-sizes.js");
|
|
588
|
+
assert.ok(sizes.indexOf("const TEXT = Object.freeze({") < sizes.indexOf("export function init"), "the strings sit in one TEXT block before init");
|
|
589
|
+
for (const literal of ["All sizes", "Overflows", "Made at"]) assert.ok(sizes.slice(0, sizes.indexOf("export function init")).includes(literal), `${literal} is in TEXT`);
|
|
590
|
+
assert.ok(!/\bstate\.size\s*=(?!=)/.test(sizes));
|
|
591
|
+
assert.match(sizes, /setAttribute\("sandbox", "allow-scripts"\)/, "size frames keep the scripts-only sandbox");
|
|
592
|
+
assert.ok(!/setAttribute\("style"|\.cssText/.test(sizes), "styles go through the CSSOM");
|
|
593
|
+
const store = read("canvas-store.js");
|
|
594
|
+
for (const field of ["board.sizeFrames", "board.sizesView", "board.overflow"]) assert.ok(store.includes(field), `canvas-store.js documents ${field} as changed in place`);
|
|
595
|
+
assert.match(store, /"all"/, "the size kinds include all");
|
|
596
|
+
const messages = read("canvas-messages.js");
|
|
597
|
+
assert.match(messages, /gd:overflow/);
|
|
598
|
+
assert.match(messages, /candidate\.frame\.contentWindow === event\.source/, "a frame is trusted only by its window");
|
|
599
|
+
// E6: canvas-sizes.js owns a frame's overflow; the other modules change it through setOverflow.
|
|
600
|
+
for (const name of ["canvas-messages.js", "canvas-focus.js", "canvas-boards.js"]) {
|
|
601
|
+
assert.ok(!/\.overflow\s*=(?!=)/.test(read(name)), `${name} never assigns an overflow`);
|
|
602
|
+
}
|
|
603
|
+
assert.equal(sizes.match(/\.overflow\s*=(?!=)/g)?.length, 1, "one assignment, in setOverflow");
|
|
604
|
+
assert.match(messages, /actions\.setOverflow\(surface, /);
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
test("index.html has the All sizes icon, and canvas.css styles the frames, the chip and the comment's size in the Sizes section on --gd-* tokens", () => {
|
|
608
|
+
const html = read("index.html");
|
|
609
|
+
assert.match(html, /<symbol id="i-devices" viewBox="0 0 24 24">/);
|
|
610
|
+
assert.ok(!/data-i18n/.test(html.slice(html.indexOf('<svg id="gd-sprite"'), html.indexOf("</svg>"))));
|
|
611
|
+
const css = read("canvas.css");
|
|
612
|
+
const start = css.indexOf("/* Screen sizes (canvas-sizes.js)");
|
|
613
|
+
assert.ok(start >= 0 && css.split("/* Screen sizes (canvas-sizes.js)").length === 2, "one Sizes section");
|
|
614
|
+
// It runs until the next module's section, Export.
|
|
615
|
+
const section = css.slice(start, css.indexOf("\n/* Export (canvas-export.js)", start));
|
|
616
|
+
const block = (selector: string) => {
|
|
617
|
+
const at = section.indexOf(`\n${selector} {`);
|
|
618
|
+
assert.ok(at >= 0, `${selector} is styled in the Sizes section`);
|
|
619
|
+
return section.slice(at, section.indexOf("}", at) + 1);
|
|
620
|
+
};
|
|
621
|
+
for (const selector of [".gd-sizes-all", ".gd-size-frame", ".gd-size-head", ".gd-size-scaled", ".gd-size-stage", ".gd-size-iframe", ".gd-overflow-flag", ".gd-comment-viewport"]) {
|
|
622
|
+
const text = block(selector);
|
|
623
|
+
assert.ok(!/#[0-9a-fA-F]{3,8}\b|rgba?\(/.test(text), `${selector}: tokens only`);
|
|
624
|
+
assert.ok(!/var\(--(?!gd-)/.test(text), `${selector}: only --gd-* tokens`);
|
|
625
|
+
assert.ok(!/transition|animation/.test(text), `${selector}: no motion`);
|
|
626
|
+
}
|
|
627
|
+
assert.match(section, /\.gd-all-sizes \.gd-frame-box \{ visibility: hidden; \}/, "the artboard's own frame stays loaded but hidden");
|
|
628
|
+
assert.match(section, /\.gd-commenting \.gd-size-scaled[^{]*{[^}]*outline:[^}]*var\(--gd-accent\)/);
|
|
629
|
+
assert.match(section, /\.gd-exporting \.gd-overflow-flag \{ visibility: hidden; \}/);
|
|
630
|
+
assert.ok(!/border-radius:\s*50%/.test(section), "S4: no dots");
|
|
631
|
+
});
|