A3: derive the pinned command and catalog key lists in tests

Each command module keeps its own COMMAND_IDS next to its commands; the
engine listing test checks their union against the registry, so a missing
or extra command still fails without one shared list. The menu and palette
tests derive their expectation from the listing and check grouping and
ordering rules; the catalog's runtime keys are scanned from the sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-30 18:38:41 +01:00
parent da58c83158
commit 95fd9b926f
28 changed files with 329 additions and 262 deletions

View file

@ -255,49 +255,32 @@ describe("AppMenu", () => {
expect(menu.find("[data-test=menu-button]").attributes("aria-expanded")).toBe("true");
const headings = [...document.querySelectorAll("[data-test=menu-group]")].map((g) => g.querySelector(".app-menu__heading")?.textContent.trim());
expect(headings).toEqual(["File", "Edit", "View", "Go", "Git", "Help"]);
expect(itemIds()).toEqual([
const listed = listing() as { id: string; menuPath: string | null }[];
const withPath = listed.filter((c) => c.menuPath !== null);
expect([...itemIds()].sort()).toEqual(withPath.map((c) => c.id).sort());
const groups = [...document.querySelectorAll("[data-test=menu-group]")].map((g) => ({
heading: g.querySelector(".app-menu__heading")?.textContent.trim() ?? "",
ids: [...g.querySelectorAll<HTMLElement>("[data-test=menu-item]")].map((el) => el.dataset.command ?? ""),
labels: [...g.querySelectorAll<HTMLElement>("[data-test=menu-item]")].map((el) => el.querySelector(".app-menu__label")?.textContent.trim() ?? ""),
}));
for (const group of groups) {
for (const id of group.ids) {
expect(withPath.find((c) => c.id === id)?.menuPath?.split("/")[0], id).toBe(group.heading);
}
}
expect(groups.find((g) => g.heading === "File")?.ids).toEqual([
"project.openDialog",
"file.save",
"file.saveAll",
"buffer.close",
"project.close",
"app.quit",
"editor.complete",
"editor.parameterInfo",
"editor.quickDocumentation",
"palette.open",
"view.toggleProjectTree",
"view.toggleStructure",
"find.open",
"terminal.open",
"problems.open",
"settings.open",
"goto.fileOpen",
"goto.classOpen",
"goto.symbolOpen",
"vcs.abortMerge",
"vcs.toggleBlame",
"vcs.branches",
"vcs.openChanges",
"vcs.clone",
"vcs.commit",
"vcs.fetch",
"vcs.showLog",
"vcs.manageRemotes",
"vcs.merge",
"vcs.newBranch",
"vcs.nextChange",
"vcs.previousChange",
"vcs.pull",
"vcs.push",
"vcs.refresh",
"vcs.resolveConflicts",
"vcs.showDiff",
"vcs.showHistory",
"vcs.stash",
"vcs.showStashes",
"app.about",
]);
expect(groups.find((g) => g.heading === "Go")?.ids).toEqual(["goto.fileOpen", "goto.classOpen", "goto.symbolOpen"]);
const git = groups.find((g) => g.heading === "Git")?.labels ?? [];
expect(git.length).toBeGreaterThan(1);
expect(git).toEqual([...git].sort((x, y) => x.localeCompare(y)));
expect(itemIds().at(-1)).toBe("app.about");
const close = document.querySelector("[data-command='buffer.close']");
expect(close?.textContent).toContain("Close Tab");
expect(close?.querySelector("[data-test=menu-shortcut]")?.textContent).toBe("Ctrl+W");