@selesai/code 0.8.5 → 0.8.7
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/CHANGELOG.md +28 -0
- package/dist/core/agent-session.js +13 -1
- package/dist/core/extensions/types.d.ts +2 -0
- package/dist/core/provider-composer.js +17 -4
- package/dist/core/settings-manager.d.ts +2 -0
- package/dist/core/settings-manager.js +3 -0
- package/dist/core/system-prompt.js +2 -8
- package/dist/core/system-prompt.test.js +6 -0
- package/dist/core/tools/index.d.ts +1 -0
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/schema-prune.d.ts +16 -0
- package/dist/core/tools/schema-prune.js +39 -0
- package/dist/core/tools/schema-prune.test.d.ts +1 -0
- package/dist/core/tools/schema-prune.test.js +111 -0
- package/dist/defaults/models.json +5 -0
- package/dist/defaults/settings.json +1 -0
- package/dist/extensions/agent-browser.test.ts +178 -2
- package/dist/extensions/agent-browser.ts +2 -0
- package/dist/extensions/copy-turn.test.ts +229 -0
- package/dist/extensions/copy-turn.ts +11 -0
- package/dist/extensions/grep-app/index.test.ts +356 -1
- package/dist/extensions/grep-app/index.ts +6 -1
- package/dist/extensions/handoff-new.test.ts +351 -161
- package/dist/extensions/handoff-new.ts +3 -0
- package/dist/extensions/inline-skills.test.ts +93 -0
- package/dist/extensions/inline-skills.ts +3 -0
- package/dist/extensions/model-prompt-injector/config.json +10 -0
- package/dist/extensions/model-prompt-injector/index.test.ts +112 -0
- package/dist/extensions/model-prompt-injector/index.ts +151 -0
- package/dist/extensions/package.json +1 -0
- package/dist/extensions/pi-subagents/CHANGELOG.md +158 -90
- package/dist/extensions/pi-subagents/UPSTREAM-V0.50-MAPPING.md +172 -0
- package/dist/extensions/pi-subagents/agents/builder.md +5 -2
- package/dist/extensions/pi-subagents/agents/commentator.md +1 -1
- package/dist/extensions/pi-subagents/agents/oracle.md +7 -5
- package/dist/extensions/pi-subagents/agents/reviewer.md +2 -2
- package/dist/extensions/pi-subagents/agents/scout.md +1 -1
- package/dist/extensions/pi-subagents/agents/worker.md +1 -1
- package/dist/extensions/pi-subagents/docs/configuration.md +78 -11
- package/dist/extensions/pi-subagents/docs/extension-api.md +36 -0
- package/dist/extensions/pi-subagents/docs/missions.md +5 -3
- package/dist/extensions/pi-subagents/docs/models.md +1 -1
- package/dist/extensions/pi-subagents/docs/observability.md +42 -2
- package/dist/extensions/pi-subagents/docs/tool-reference.md +20 -3
- package/dist/extensions/pi-subagents/docs/workflows.md +4 -4
- package/dist/extensions/pi-subagents/install.mjs +2 -2
- package/dist/extensions/pi-subagents/package-lock.json +1470 -1472
- package/dist/extensions/pi-subagents/package.json +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +5 -4
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +16 -15
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +5 -5
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +46 -26
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +2 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +37 -12
- package/dist/extensions/pi-subagents/src/api/external-runs.ts +174 -84
- package/dist/extensions/pi-subagents/src/api/preflight.ts +13 -7
- package/dist/extensions/pi-subagents/src/extension/config.ts +59 -0
- package/dist/extensions/pi-subagents/src/extension/index.ts +146 -23
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +34 -6
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +5 -1
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +31 -30
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +10 -9
- package/dist/extensions/pi-subagents/src/inspectors/herdr/actions.ts +13 -8
- package/dist/extensions/pi-subagents/src/inspectors/herdr/inspector-runner.ts +16 -3
- package/dist/extensions/pi-subagents/src/inspectors/herdr/project-panes.ts +2 -6
- package/dist/extensions/pi-subagents/src/inspectors/herdr/shell-command.ts +16 -0
- package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +5 -4
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +19 -42
- package/dist/extensions/pi-subagents/src/missions/goal-driver.ts +3 -1
- package/dist/extensions/pi-subagents/src/missions/store.ts +8 -3
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +82 -25
- package/dist/extensions/pi-subagents/src/runs/background/active-run-index.ts +71 -1
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +73 -43
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +17 -6
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +14 -6
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +277 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +11 -3
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +2 -2
- package/dist/extensions/pi-subagents/src/runs/background/completion-replay.ts +11 -1
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +21 -6
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +5 -2
- package/dist/extensions/pi-subagents/src/runs/background/result-files.ts +437 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +224 -42
- package/dist/extensions/pi-subagents/src/runs/background/resume-guidance.ts +27 -7
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +76 -19
- package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +35 -26
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +108 -9
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +54 -28
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +27 -13
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +298 -33
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +5 -2
- package/dist/extensions/pi-subagents/src/runs/background/wait-subscriptions.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/async-dismiss-action.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +16 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +219 -15
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +7 -4
- package/dist/extensions/pi-subagents/src/runs/foreground/prompt-audit.ts +4 -3
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +368 -50
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +107 -1
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-runner.ts +4 -0
- package/dist/extensions/pi-subagents/src/runs/shared/llm-intent-arbiter.ts +39 -23
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +16 -2
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +66 -62
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +376 -0
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +15 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +1 -9
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +12 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-timeout.ts +95 -0
- package/dist/extensions/pi-subagents/src/shared/agent-stream-options.ts +5 -0
- package/dist/extensions/pi-subagents/src/shared/artifacts.ts +0 -4
- package/dist/extensions/pi-subagents/src/shared/display-text.ts +50 -0
- package/dist/extensions/pi-subagents/src/shared/node-executable.ts +21 -0
- package/dist/extensions/pi-subagents/src/shared/session-lineage.ts +71 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +66 -4
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +34 -25
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +4 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +160 -45
- package/dist/extensions/pi-subagents/src/tui/fleet-transcript.ts +1 -48
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +129 -17
- package/dist/extensions/pi-subagents/src/tui/render.ts +122 -44
- package/dist/extensions/pi-subagents/src/watchdog/permission-arbiter.ts +2 -1
- package/dist/extensions/pi-subagents/src/watchdog/review.ts +4 -3
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +10 -2
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +272 -76
- package/dist/extensions/pi-subagents/src/workflows/workflow-auto-relaunch.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/types.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +68 -9
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +27 -1
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +49 -0
- package/dist/extensions/pi-subagents/test/integration/external-cli-runner.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +26 -1
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +144 -0
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +26 -0
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +369 -98
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +111 -78
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +49 -1
- package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +12 -0
- package/dist/extensions/pi-subagents/test/support/node-command.ts +15 -0
- package/dist/extensions/pi-subagents/test/unit/active-async-capacity.test.ts +50 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +28 -0
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +61 -0
- package/dist/extensions/pi-subagents/test/unit/agent-stream-options.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +76 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +2 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-snapshot.test.ts +162 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +209 -10
- package/dist/extensions/pi-subagents/test/unit/completion-replay.test.ts +41 -1
- package/dist/extensions/pi-subagents/test/unit/external-runs.test.ts +135 -42
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +252 -1
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +192 -6
- package/dist/extensions/pi-subagents/test/unit/handoff-adoption.test.ts +103 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector-bootstrap.test.ts +32 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-shell-command.test.ts +59 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +91 -0
- package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +23 -4
- package/dist/extensions/pi-subagents/test/unit/llm-intent-arbiter.test.ts +56 -1
- package/dist/extensions/pi-subagents/test/unit/mission-goal-driver.test.ts +67 -3
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +18 -0
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +25 -2
- package/dist/extensions/pi-subagents/test/unit/node-executable.test.ts +26 -0
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +8 -0
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +348 -0
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +5 -2
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +6 -1
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +92 -0
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +175 -0
- package/dist/extensions/pi-subagents/test/unit/retained-children.test.ts +127 -17
- package/dist/extensions/pi-subagents/test/unit/run-id-resolver.test.ts +44 -0
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +247 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +107 -2
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +5 -8
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +456 -4
- package/dist/extensions/pi-subagents/test/unit/session-lineage.test.ts +73 -0
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +128 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +28 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +16 -7
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +15 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +79 -15
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +12 -12
- package/dist/extensions/pi-subagents/test/unit/tool-timeout.test.ts +109 -0
- package/dist/extensions/pi-subagents/test/unit/wait-subscriptions.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-auto-relaunch.test.ts +45 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +94 -1
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +42 -2
- package/dist/extensions/ponytail/index.js +11 -0
- package/dist/extensions/ponytail/ponytail-config.cjs +2 -0
- package/dist/extensions/ponytail/ponytail-instructions.cjs +6 -0
- package/dist/extensions/ponytail/test/extension.test.js +274 -140
- package/dist/extensions/ponytail/test/helpers.test.js +280 -92
- package/dist/extensions/question/index.ts +33 -0
- package/dist/extensions/question/question-list.ts +28 -0
- package/dist/extensions/question/row-layout.ts +3 -0
- package/dist/extensions/question/tests/batch.test.ts +103 -65
- package/dist/extensions/question/tests/exp.test.ts +70 -0
- package/dist/extensions/question/tests/exp2.test.ts +59 -0
- package/dist/extensions/question/tests/exp3.test.ts +47 -0
- package/dist/extensions/question/tests/helpers.test.ts +75 -35
- package/dist/extensions/question/tests/question-list.test.ts +640 -198
- package/dist/extensions/question/tests/row-layout.test.ts +193 -114
- package/dist/extensions/question/tests/schemas.test.ts +42 -19
- package/dist/extensions/question/tests/selection-mode.test.ts +54 -0
- package/dist/extensions/question/tests/shortcuts.test.ts +106 -84
- package/dist/extensions/question/tests/wizard.test.ts +771 -50
- package/dist/extensions/question/tests/zz-ig3.test.ts +20 -0
- package/dist/extensions/question/tests/zz-probe.test.ts +29 -0
- package/dist/extensions/rtk.test.ts +180 -1
- package/dist/extensions/tokenin-onboarding.ts +3 -0
- package/dist/extensions/undo.test.ts +720 -0
- package/dist/extensions/undo.ts +6 -0
- package/dist/extensions/web-agent-onboarding.test.ts +415 -0
- package/dist/extensions/workflow/extension.ts +3 -3
- package/dist/extensions/workflow/modes.ts +41 -19
- package/dist/skills/pi-subagents/SKILL.md +1 -1
- package/dist/skills/pi-subagents/references/constraints-and-recipes.md +5 -4
- package/dist/skills/pi-subagents/references/execution-controls.md +16 -15
- package/dist/skills/pi-subagents/references/management-authoring-rpc.md +5 -5
- package/dist/skills/pi-subagents/references/prompting-and-roles.md +46 -26
- package/docs/plans/workflow-autoloop-reference.md +1 -2
- package/docs/plans/workflow-handoff-carryover.md +108 -0
- package/docs/settings.md +6 -0
- package/package.json +4 -1
|
@@ -1,136 +1,215 @@
|
|
|
1
|
-
import
|
|
2
|
-
import assert from "node:assert/strict";
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
3
2
|
|
|
4
3
|
import { wrapPlain, buildItemBlocks, flattenBlocks, renderSingleSelectRows } from "../row-layout.ts";
|
|
5
4
|
import type { ItemBlock, QuestionOption } from "../types.ts";
|
|
6
5
|
|
|
7
6
|
const opts = (labels: string[]): QuestionOption[] => labels.map((label) => ({ value: label, label }));
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
describe("row-layout", () => {
|
|
9
|
+
it("wrapPlain: empty → ['']", () => {
|
|
10
|
+
expect(wrapPlain("", 20)).toEqual([""]);
|
|
11
|
+
expect(wrapPlain(" ", 20)).toEqual([""]);
|
|
12
|
+
});
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
14
|
+
it("wrapPlain: single word fits", () => {
|
|
15
|
+
expect(wrapPlain("hello", 20)).toEqual(["hello"]);
|
|
16
|
+
});
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
18
|
+
it("wrapPlain: word longer than width → chunked", () => {
|
|
19
|
+
expect(wrapPlain("abcdefgh", 3)).toEqual(["abc", "def", "gh"]);
|
|
20
|
+
});
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
22
|
+
it("wrapPlain: multiple words wrapping", () => {
|
|
23
|
+
expect(wrapPlain("hello world foo", 7)).toEqual(["hello", "world", "foo"]);
|
|
24
|
+
expect(wrapPlain("hello world foo", 11)).toEqual(["hello world", "foo"]);
|
|
25
|
+
});
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
27
|
+
it("wrapPlain: width=1 → char-by-char", () => {
|
|
28
|
+
expect(wrapPlain("abc", 1)).toEqual(["a", "b", "c"]);
|
|
29
|
+
});
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
assert.equal(blocks[0]!.itemIndex, 0);
|
|
35
|
-
assert.ok(blocks[0]!.lines[0]!.startsWith("→"));
|
|
36
|
-
assert.ok(blocks[0]!.lines[0]!.includes("1. a"));
|
|
37
|
-
assert.ok(blocks[1]!.lines[0]!.startsWith(" "));
|
|
38
|
-
});
|
|
31
|
+
it("wrapPlain: long word mid-sentence chunks and continues", () => {
|
|
32
|
+
expect(wrapPlain("a verylongwordhere b", 5)).toEqual(["a", "veryl", "ongwo", "rdher", "e b"]);
|
|
33
|
+
});
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
it("buildItemBlocks: 3 options, selected=0 → arrow on block 0", () => {
|
|
36
|
+
const blocks = buildItemBlocks(opts(["a", "b", "c"]), 80, false, false, false, 0);
|
|
37
|
+
expect(blocks).toHaveLength(3);
|
|
38
|
+
expect(blocks[0]!.itemIndex).toBe(0);
|
|
39
|
+
expect(blocks[0]!.lines[0]!.startsWith("→")).toBe(true);
|
|
40
|
+
expect(blocks[0]!.lines[0]!).toContain("1. a");
|
|
41
|
+
expect(blocks[1]!.lines[0]!.startsWith(" ")).toBe(true);
|
|
42
|
+
});
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
[
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
false,
|
|
52
|
-
false,
|
|
53
|
-
0,
|
|
54
|
-
);
|
|
55
|
-
assert.ok(blocks[0]!.lines.length > 1);
|
|
56
|
-
assert.ok(blocks[0]!.lines.some((l) => l.includes("some desc")));
|
|
57
|
-
});
|
|
44
|
+
it("buildItemBlocks: selected=1 → arrow pointer on block 1", () => {
|
|
45
|
+
const blocks = buildItemBlocks(opts(["a", "b", "c"]), 80, false, false, false, 1);
|
|
46
|
+
expect(blocks[1]!.lines[0]!.startsWith("→")).toBe(true);
|
|
47
|
+
expect(blocks[0]!.lines[0]!.startsWith(" ")).toBe(true);
|
|
48
|
+
});
|
|
58
49
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
50
|
+
it("buildItemBlocks: with description → description lines included", () => {
|
|
51
|
+
const blocks = buildItemBlocks(
|
|
52
|
+
[{ value: "a", label: "a", description: "some desc" }],
|
|
53
|
+
80,
|
|
54
|
+
false,
|
|
55
|
+
false,
|
|
56
|
+
false,
|
|
57
|
+
0,
|
|
58
|
+
);
|
|
59
|
+
expect(blocks[0]!.lines.length).toBeGreaterThan(1);
|
|
60
|
+
expect(blocks[0]!.lines.some((l) => l.includes("some desc"))).toBe(true);
|
|
61
|
+
});
|
|
72
62
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
it("buildItemBlocks: hideDescriptions=true → no description lines", () => {
|
|
64
|
+
const blocks = buildItemBlocks(
|
|
65
|
+
[{ value: "a", label: "a", description: "some desc" }],
|
|
66
|
+
80,
|
|
67
|
+
false,
|
|
68
|
+
false,
|
|
69
|
+
false,
|
|
70
|
+
0,
|
|
71
|
+
true,
|
|
72
|
+
);
|
|
73
|
+
// Only the title line, no description
|
|
74
|
+
expect(blocks[0]!.lines).toHaveLength(1);
|
|
75
|
+
});
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
77
|
+
it("buildItemBlocks: allowFreeform → freeform block appended", () => {
|
|
78
|
+
const blocks = buildItemBlocks(opts(["a"]), 80, true, false, false, 0);
|
|
79
|
+
expect(blocks).toHaveLength(2);
|
|
80
|
+
expect(blocks[1]!.lines[0]!).toContain("Type custom answer");
|
|
81
|
+
});
|
|
85
82
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
it("buildItemBlocks: allowComment → comment-toggle block appended", () => {
|
|
84
|
+
const blocks = buildItemBlocks(opts(["a"]), 80, false, true, false, 0);
|
|
85
|
+
expect(blocks).toHaveLength(2);
|
|
86
|
+
expect(blocks[1]!.lines[0]!).toContain("[ ]");
|
|
87
|
+
expect(blocks[1]!.lines[0]!).toContain("Add extra context");
|
|
88
|
+
});
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
];
|
|
96
|
-
const rows = flattenBlocks(blocks, 1);
|
|
97
|
-
assert.equal(rows.length, 3);
|
|
98
|
-
assert.equal(rows[0]!.selected, false);
|
|
99
|
-
assert.equal(rows[1]!.selected, false);
|
|
100
|
-
assert.equal(rows[2]!.selected, true);
|
|
101
|
-
});
|
|
90
|
+
it("buildItemBlocks: allowComment + commentEnabled → [✓]", () => {
|
|
91
|
+
const blocks = buildItemBlocks(opts(["a"]), 80, false, true, true, 0);
|
|
92
|
+
expect(blocks[1]!.lines[0]!).toContain("[✓]");
|
|
93
|
+
});
|
|
102
94
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
selectedIndex: 0,
|
|
107
|
-
width: 80,
|
|
108
|
-
allowFreeform: false,
|
|
95
|
+
it("buildItemBlocks: narrow width wraps labels", () => {
|
|
96
|
+
const blocks = buildItemBlocks(opts(["a very long label"]), 12, false, false, false, 0);
|
|
97
|
+
expect(blocks[0]!.lines.length).toBeGreaterThan(1);
|
|
109
98
|
});
|
|
110
|
-
assert.equal(rows.length, 2);
|
|
111
|
-
});
|
|
112
99
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
100
|
+
it("flattenBlocks: correct selected flags", () => {
|
|
101
|
+
const blocks: ItemBlock[] = [
|
|
102
|
+
{ itemIndex: 0, lines: ["a", "b"] },
|
|
103
|
+
{ itemIndex: 1, lines: ["c"] },
|
|
104
|
+
];
|
|
105
|
+
const rows = flattenBlocks(blocks, 1);
|
|
106
|
+
expect(rows).toHaveLength(3);
|
|
107
|
+
expect(rows[0]!.selected).toBe(false);
|
|
108
|
+
expect(rows[1]!.selected).toBe(false);
|
|
109
|
+
expect(rows[2]!.selected).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("renderSingleSelectRows: few rows, all visible", () => {
|
|
113
|
+
const rows = renderSingleSelectRows({
|
|
114
|
+
options: opts(["a", "b"]),
|
|
115
|
+
selectedIndex: 0,
|
|
116
|
+
width: 80,
|
|
117
|
+
allowFreeform: false,
|
|
118
|
+
});
|
|
119
|
+
expect(rows).toHaveLength(2);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("renderSingleSelectRows: maxRows truncation with indicator", () => {
|
|
123
|
+
const rows = renderSingleSelectRows({
|
|
124
|
+
options: opts(["a", "b", "c", "c", "e", "f", "g", "h"]),
|
|
125
|
+
selectedIndex: 0,
|
|
126
|
+
width: 80,
|
|
127
|
+
allowFreeform: false,
|
|
128
|
+
maxRows: 3,
|
|
129
|
+
});
|
|
130
|
+
expect(rows.length).toBeLessThanOrEqual(3);
|
|
131
|
+
// Last row should be the indicator
|
|
132
|
+
expect(rows[rows.length - 1]!.line).toContain("(");
|
|
133
|
+
});
|
|
125
134
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
135
|
+
it("renderSingleSelectRows: selected block larger than available → only selected + indicator", () => {
|
|
136
|
+
const rows = renderSingleSelectRows({
|
|
137
|
+
options: [{ value: "a", label: "a".repeat(100) }],
|
|
138
|
+
selectedIndex: 0,
|
|
139
|
+
width: 10,
|
|
140
|
+
allowFreeform: false,
|
|
141
|
+
maxRows: 3,
|
|
142
|
+
});
|
|
143
|
+
expect(rows.length).toBeLessThanOrEqual(3);
|
|
144
|
+
expect(rows.every((r) => r.selected || r.line.includes("("))).toBe(true);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("renderSingleSelectRows: maxRows=1 shows only the selected line", () => {
|
|
148
|
+
const rows = renderSingleSelectRows({
|
|
149
|
+
options: opts(["a", "b"]),
|
|
150
|
+
selectedIndex: 0,
|
|
151
|
+
width: 80,
|
|
152
|
+
allowFreeform: false,
|
|
153
|
+
maxRows: 1,
|
|
154
|
+
});
|
|
155
|
+
expect(rows.length).toBeLessThanOrEqual(1);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("renderSingleSelectRows: empty options with freeform still renders", () => {
|
|
159
|
+
const rows = renderSingleSelectRows({
|
|
160
|
+
options: [],
|
|
161
|
+
selectedIndex: 0,
|
|
162
|
+
width: 80,
|
|
163
|
+
allowFreeform: true,
|
|
164
|
+
maxRows: 5,
|
|
165
|
+
});
|
|
166
|
+
expect(rows.length).toBeGreaterThan(0);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("renderSingleSelectRows: empty options without freeform returns empty", () => {
|
|
170
|
+
const rows = renderSingleSelectRows({
|
|
171
|
+
options: [],
|
|
172
|
+
selectedIndex: 0,
|
|
173
|
+
width: 80,
|
|
174
|
+
allowFreeform: false,
|
|
175
|
+
maxRows: 5,
|
|
176
|
+
});
|
|
177
|
+
expect(rows).toEqual([]);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("renderSingleSelectRows: previous block fits when next does not", () => {
|
|
181
|
+
// Selected block is small; the next block is too large but the previous fits.
|
|
182
|
+
const rows = renderSingleSelectRows({
|
|
183
|
+
options: [
|
|
184
|
+
{ value: "a", label: "A" },
|
|
185
|
+
{ value: "b", label: "B" },
|
|
186
|
+
{ value: "c", label: "C".repeat(100) },
|
|
187
|
+
],
|
|
188
|
+
selectedIndex: 1,
|
|
189
|
+
width: 10,
|
|
190
|
+
allowFreeform: false,
|
|
191
|
+
maxRows: 3,
|
|
192
|
+
});
|
|
193
|
+
expect(rows.length).toBeLessThanOrEqual(3);
|
|
194
|
+
expect(rows.some((r) => r.line.includes("A"))).toBe(true);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("buildItemBlocks: wrapped freeform label uses continuation prefix", () => {
|
|
198
|
+
const blocks = buildItemBlocks(opts(["a"]), 12, true, false, false, 1);
|
|
199
|
+
expect(blocks[1]!.lines.length).toBeGreaterThan(1);
|
|
200
|
+
expect(blocks[1]!.lines[1]!.startsWith(" ")).toBe(true);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("renderSingleSelectRows: out-of-range selectedIndex falls back to the first block", () => {
|
|
204
|
+
const rows = renderSingleSelectRows({
|
|
205
|
+
options: opts(["a", "b"]),
|
|
206
|
+
selectedIndex: 7,
|
|
207
|
+
width: 40,
|
|
208
|
+
allowFreeform: false,
|
|
209
|
+
maxRows: 1,
|
|
210
|
+
});
|
|
211
|
+
expect(rows.length).toBeGreaterThan(0);
|
|
212
|
+
expect(rows[0]!.selected).toBe(true);
|
|
213
|
+
expect(rows[0]!.line).toContain("a");
|
|
214
|
+
});
|
|
215
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import assert from "node:assert/strict";
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
3
2
|
|
|
4
3
|
import { Value } from "typebox/value";
|
|
5
4
|
|
|
@@ -9,22 +8,46 @@ const valid = {
|
|
|
9
8
|
questions: [{ type: "select", question: "Pick", options: [{ value: "yes", label: "Yes" }] }],
|
|
10
9
|
};
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
describe("QuestionParamsSchema", () => {
|
|
12
|
+
it("accepts typed batch requests", () => {
|
|
13
|
+
expect(Value.Check(QuestionParamsSchema, valid)).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("accepts multiselect, text, ids, labels, context, allowOther, descriptions", () => {
|
|
17
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
18
|
+
questions: [
|
|
19
|
+
{ type: "multiselect", id: "m", label: "M", question: "Pick many", context: "ctx", options: [{ value: "a", label: "A", description: "d" }], allowOther: true },
|
|
20
|
+
{ type: "text", question: "Explain" },
|
|
21
|
+
],
|
|
22
|
+
})).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("rejects legacy and mistyped fields", () => {
|
|
26
|
+
expect(Value.Check(QuestionParamsSchema, { ...valid, timeout: 1000 })).toBe(false);
|
|
27
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
28
|
+
questions: [{ ...valid.questions[0], allowMultiple: true }],
|
|
29
|
+
})).toBe(false);
|
|
30
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
31
|
+
questions: [{ ...valid.questions[0], allowComment: true }],
|
|
32
|
+
})).toBe(false);
|
|
33
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
34
|
+
questions: [{ type: "text", question: "Explain", options: [] }],
|
|
35
|
+
})).toBe(false);
|
|
36
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
37
|
+
questions: [{ ...valid.questions[0], options: [{ value: "yes", label: "Yes", extra: true }] }],
|
|
38
|
+
})).toBe(false);
|
|
39
|
+
});
|
|
15
40
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
questions: [{ ...valid.questions[0], options: [{ value: "yes", label: "Yes", extra: true }] }],
|
|
29
|
-
}), false);
|
|
41
|
+
it("rejects empty questions and bad option shapes", () => {
|
|
42
|
+
expect(Value.Check(QuestionParamsSchema, { questions: [] })).toBe(false);
|
|
43
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
44
|
+
questions: [{ type: "select", question: "Pick", options: [] }],
|
|
45
|
+
})).toBe(false);
|
|
46
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
47
|
+
questions: [{ type: "select", question: "Pick", options: [{ value: "yes" }] }],
|
|
48
|
+
})).toBe(false);
|
|
49
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
50
|
+
questions: [{ type: "select", question: "Pick", options: [{ label: "Yes" }] }],
|
|
51
|
+
})).toBe(false);
|
|
52
|
+
});
|
|
30
53
|
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { MultiSelect, SingleSelect } from "../selection-mode.ts";
|
|
4
|
+
|
|
5
|
+
describe("selection-mode", () => {
|
|
6
|
+
it("SingleSelect reports single mode and no-op toggle", () => {
|
|
7
|
+
expect(SingleSelect.multi).toBe(false);
|
|
8
|
+
const checked = new Set<number>([1]);
|
|
9
|
+
SingleSelect.toggle(checked, 0);
|
|
10
|
+
expect([...checked]).toEqual([1]);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("SingleSelect buildResult returns the selected value", () => {
|
|
14
|
+
const options = [{ value: "a", label: "A" }];
|
|
15
|
+
expect(SingleSelect.buildResult({ selectedIndex: 0, checked: new Set(), options })).toEqual(["a"]);
|
|
16
|
+
// Out-of-range index (or empty options) → no value → empty result.
|
|
17
|
+
expect(SingleSelect.buildResult({ selectedIndex: 2, checked: new Set(), options })).toEqual([]);
|
|
18
|
+
expect(SingleSelect.buildResult({ selectedIndex: 0, checked: new Set(), options: [] })).toEqual([]);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("SingleSelect handleNumberKey clamps to the last option", () => {
|
|
22
|
+
expect(SingleSelect.handleNumberKey(5, 3)).toEqual({ toggle: false, selectIndex: 2 });
|
|
23
|
+
expect(SingleSelect.handleNumberKey(1, 3)).toEqual({ toggle: false, selectIndex: 1 });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("MultiSelect toggle adds, removes, and ignores negative indexes", () => {
|
|
27
|
+
expect(MultiSelect.multi).toBe(true);
|
|
28
|
+
const checked = new Set<number>();
|
|
29
|
+
MultiSelect.toggle(checked, 0);
|
|
30
|
+
expect(checked.has(0)).toBe(true);
|
|
31
|
+
MultiSelect.toggle(checked, 0);
|
|
32
|
+
expect(checked.has(0)).toBe(false);
|
|
33
|
+
MultiSelect.toggle(checked, -1);
|
|
34
|
+
expect(checked.size).toBe(0);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("MultiSelect buildResult sorts and filters missing options", () => {
|
|
38
|
+
const options = [
|
|
39
|
+
{ value: "a", label: "A" },
|
|
40
|
+
{ value: "b", label: "B" },
|
|
41
|
+
];
|
|
42
|
+
const checked = new Set([1, 0]);
|
|
43
|
+
expect(MultiSelect.buildResult({ selectedIndex: 0, checked, options })).toEqual(["a", "b"]);
|
|
44
|
+
// Indexes pointing past the options array are filtered out.
|
|
45
|
+
const sparse = new Set([0, 1, 2]);
|
|
46
|
+
expect(MultiSelect.buildResult({ selectedIndex: 0, checked: sparse, options })).toEqual(["a", "b"]);
|
|
47
|
+
expect(MultiSelect.buildResult({ selectedIndex: 0, checked: new Set(), options })).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("MultiSelect handleNumberKey clamps to the last option", () => {
|
|
51
|
+
expect(MultiSelect.handleNumberKey(5, 3)).toEqual({ toggle: true, selectIndex: 2 });
|
|
52
|
+
expect(MultiSelect.handleNumberKey(0, 3)).toEqual({ toggle: true, selectIndex: 0 });
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -1,85 +1,107 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { normalizeShortcutSpec, isValidShortcutSpec, resolveShortcut, resolveShortcuts, buildShortcut } from "../shortcuts.ts";
|
|
4
|
+
import { DISABLED_SHORTCUT, DEFAULT_COMMENT_TOGGLE_KEY } from "../constants.ts";
|
|
5
|
+
|
|
6
|
+
describe("shortcut resolution", () => {
|
|
7
|
+
it("normalizeShortcutSpec: undefined → undefined", () => {
|
|
8
|
+
expect(normalizeShortcutSpec(undefined)).toBeUndefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("normalizeShortcutSpec: null → null", () => {
|
|
12
|
+
expect(normalizeShortcutSpec(null)).toBeNull();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("normalizeShortcutSpec: disable values → null", () => {
|
|
16
|
+
expect(normalizeShortcutSpec("off")).toBeNull();
|
|
17
|
+
expect(normalizeShortcutSpec("none")).toBeNull();
|
|
18
|
+
expect(normalizeShortcutSpec("disabled")).toBeNull();
|
|
19
|
+
expect(normalizeShortcutSpec("")).toBeNull();
|
|
20
|
+
expect(normalizeShortcutSpec(" off ")).toBeNull();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("normalizeShortcutSpec: normalizes case and trims", () => {
|
|
24
|
+
expect(normalizeShortcutSpec("Alt+O")).toBe("alt+o");
|
|
25
|
+
expect(normalizeShortcutSpec(" Ctrl+G ")).toBe("ctrl+g");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("isValidShortcutSpec: empty → false", () => {
|
|
29
|
+
expect(isValidShortcutSpec("")).toBe(false);
|
|
30
|
+
expect(isValidShortcutSpec(" ")).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("isValidShortcutSpec: valid specs", () => {
|
|
34
|
+
expect(isValidShortcutSpec("alt+o")).toBe(true);
|
|
35
|
+
expect(isValidShortcutSpec("ctrl+g")).toBe(true);
|
|
36
|
+
expect(isValidShortcutSpec("shift+f1")).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("isValidShortcutSpec: leading/trailing + → false", () => {
|
|
40
|
+
expect(isValidShortcutSpec("+o")).toBe(false);
|
|
41
|
+
expect(isValidShortcutSpec("o+")).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("isValidShortcutSpec: double + → false", () => {
|
|
45
|
+
expect(isValidShortcutSpec("alt++o")).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("isValidShortcutSpec: illegal characters → false", () => {
|
|
49
|
+
expect(isValidShortcutSpec("alt o")).toBe(false);
|
|
50
|
+
expect(isValidShortcutSpec("alt\n")).toBe(false);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("buildShortcut returns a matching shortcut", () => {
|
|
54
|
+
const shortcut = buildShortcut("ctrl+g");
|
|
55
|
+
expect(shortcut.disabled).toBe(false);
|
|
56
|
+
expect(shortcut.spec).toBe("ctrl+g");
|
|
57
|
+
expect(shortcut.matches("\x07")).toBe(true);
|
|
58
|
+
expect(shortcut.matches("x")).toBe(false);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("resolveShortcut: uses param when valid", () => {
|
|
62
|
+
const result = resolveShortcut("alt+o", undefined, "alt+o");
|
|
63
|
+
expect(result.disabled).toBe(false);
|
|
64
|
+
expect(result.spec).toBe("alt+o");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("resolveShortcut: param undefined, uses env", () => {
|
|
68
|
+
const result = resolveShortcut(undefined, "ctrl+x", "alt+o");
|
|
69
|
+
expect(result.disabled).toBe(false);
|
|
70
|
+
expect(result.spec).toBe("ctrl+x");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("resolveShortcut: param null → disabled", () => {
|
|
74
|
+
expect(resolveShortcut(null, "ctrl+x", "alt+o")).toBe(DISABLED_SHORTCUT);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("resolveShortcut: param undefined, env undefined, uses default", () => {
|
|
78
|
+
const result = resolveShortcut(undefined, undefined, "alt+o");
|
|
79
|
+
expect(result.disabled).toBe(false);
|
|
80
|
+
expect(result.spec).toBe("alt+o");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("resolveShortcut: param 'off' → disabled", () => {
|
|
84
|
+
expect(resolveShortcut("off", "ctrl+x", "alt+o")).toBe(DISABLED_SHORTCUT);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("resolveShortcut: invalid param falls through to env", () => {
|
|
88
|
+
const result = resolveShortcut("invalid++", "ctrl+x", "alt+o");
|
|
89
|
+
expect(result.disabled).toBe(false);
|
|
90
|
+
expect(result.spec).toBe("ctrl+x");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("resolveShortcut: all invalid → disabled", () => {
|
|
94
|
+
expect(resolveShortcut("invalid++", "also++", "default++")).toBe(DISABLED_SHORTCUT);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("resolveShortcuts builds the commentToggle map with the default key", () => {
|
|
98
|
+
const shortcuts = resolveShortcuts(undefined, undefined);
|
|
99
|
+
expect(shortcuts.commentToggle.disabled).toBe(false);
|
|
100
|
+
expect(shortcuts.commentToggle.spec).toBe(DEFAULT_COMMENT_TOGGLE_KEY);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("DISABLED_SHORTCUT matches nothing", () => {
|
|
104
|
+
expect(DISABLED_SHORTCUT.matches("anything")).toBe(false);
|
|
105
|
+
expect(DISABLED_SHORTCUT.disabled).toBe(true);
|
|
106
|
+
});
|
|
26
107
|
});
|
|
27
|
-
|
|
28
|
-
test("isValidShortcutSpec: empty → false", () => {
|
|
29
|
-
assert.equal(isValidShortcutSpec(""), false);
|
|
30
|
-
assert.equal(isValidShortcutSpec(" "), false);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test("isValidShortcutSpec: valid specs", () => {
|
|
34
|
-
assert.equal(isValidShortcutSpec("alt+o"), true);
|
|
35
|
-
assert.equal(isValidShortcutSpec("ctrl+g"), true);
|
|
36
|
-
assert.equal(isValidShortcutSpec("shift+f1"), true);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("isValidShortcutSpec: leading/trailing + → false", () => {
|
|
40
|
-
assert.equal(isValidShortcutSpec("+o"), false);
|
|
41
|
-
assert.equal(isValidShortcutSpec("o+"), false);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test("isValidShortcutSpec: double + → false", () => {
|
|
45
|
-
assert.equal(isValidShortcutSpec("alt++o"), false);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("resolveShortcut: uses param when valid", () => {
|
|
49
|
-
const result = resolveShortcut("alt+o", undefined, "alt+o");
|
|
50
|
-
assert.equal(result.disabled, false);
|
|
51
|
-
assert.equal(result.spec, "alt+o");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("resolveShortcut: param undefined, uses env", () => {
|
|
55
|
-
const result = resolveShortcut(undefined, "ctrl+x", "alt+o");
|
|
56
|
-
assert.equal(result.disabled, false);
|
|
57
|
-
assert.equal(result.spec, "ctrl+x");
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("resolveShortcut: param null → disabled", () => {
|
|
61
|
-
const result = resolveShortcut(null, "ctrl+x", "alt+o");
|
|
62
|
-
assert.equal(result, DISABLED_SHORTCUT);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test("resolveShortcut: param undefined, env undefined, uses default", () => {
|
|
66
|
-
const result = resolveShortcut(undefined, undefined, "alt+o");
|
|
67
|
-
assert.equal(result.disabled, false);
|
|
68
|
-
assert.equal(result.spec, "alt+o");
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test("resolveShortcut: param 'off' → disabled", () => {
|
|
72
|
-
const result = resolveShortcut("off", "ctrl+x", "alt+o");
|
|
73
|
-
assert.equal(result, DISABLED_SHORTCUT);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test("resolveShortcut: invalid param falls through to env", () => {
|
|
77
|
-
const result = resolveShortcut("invalid++", "ctrl+x", "alt+o");
|
|
78
|
-
assert.equal(result.disabled, false);
|
|
79
|
-
assert.equal(result.spec, "ctrl+x");
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test("resolveShortcut: all invalid → disabled", () => {
|
|
83
|
-
const result = resolveShortcut("invalid++", "also++", "default++");
|
|
84
|
-
assert.equal(result, DISABLED_SHORTCUT);
|
|
85
|
-
});
|