Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
66 lines
2.4 KiB
TypeScript
66 lines
2.4 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { getCompletions } from "./autocomplete/completionEngine";
|
|
import { DEFAULT_AUTOCOMPLETE_SETTINGS } from "./autocomplete/useTerminalAutocomplete";
|
|
import type { Snippet } from "../../domain/models";
|
|
|
|
const deploySnippet: Snippet = { id: "d", label: "deploy", command: "kubectl apply -f ." };
|
|
|
|
test("getCompletions includes snippet suggestions at the command position", async () => {
|
|
const out = await getCompletions("dep", { snippets: [deploySnippet] });
|
|
const snip = out.find((s) => s.source === "snippet");
|
|
assert.ok(snip, "expected a snippet suggestion");
|
|
assert.equal(snip?.displayText, "deploy");
|
|
});
|
|
|
|
test("getCompletions does not surface snippets past the command position", async () => {
|
|
const out = await getCompletions("git dep", { snippets: [deploySnippet] });
|
|
assert.equal(out.find((s) => s.source === "snippet"), undefined);
|
|
});
|
|
|
|
test("getCompletions applies dynamic group targets to the current host", async () => {
|
|
const groupedSnippet: Snippet = {
|
|
...deploySnippet,
|
|
targetGroups: ["Production"],
|
|
};
|
|
|
|
const matching = await getCompletions("dep", {
|
|
hostId: "host-prod",
|
|
hostGroup: "Production/Web",
|
|
snippets: [groupedSnippet],
|
|
});
|
|
const outside = await getCompletions("dep", {
|
|
hostId: "host-dev",
|
|
hostGroup: "Development",
|
|
snippets: [groupedSnippet],
|
|
});
|
|
|
|
assert.ok(matching.some((suggestion) => suggestion.source === "snippet"));
|
|
assert.equal(outside.some((suggestion) => suggestion.source === "snippet"), false);
|
|
});
|
|
|
|
test("getCompletions returns more than 8 snippet matches when default maxSuggestions allows it", async () => {
|
|
const snippets: Snippet[] = Array.from({ length: 20 }, (_, i) => ({
|
|
id: `s${i}`,
|
|
label: `deploy-${String(i).padStart(2, "0")}`,
|
|
command: `echo deploy-${i}`,
|
|
}));
|
|
|
|
assert.ok(
|
|
DEFAULT_AUTOCOMPLETE_SETTINGS.maxSuggestions > 8,
|
|
`expected raised default maxSuggestions (>8), got ${DEFAULT_AUTOCOMPLETE_SETTINGS.maxSuggestions}`,
|
|
);
|
|
|
|
const out = await getCompletions("dep", {
|
|
snippets,
|
|
maxResults: DEFAULT_AUTOCOMPLETE_SETTINGS.maxSuggestions,
|
|
});
|
|
const snippetMatches = out.filter((s) => s.source === "snippet");
|
|
assert.ok(
|
|
snippetMatches.length > 8,
|
|
`expected more than 8 snippet matches for scrolling popup, got ${snippetMatches.length}`,
|
|
);
|
|
assert.equal(snippetMatches.length, 20);
|
|
});
|