Files
dev/third_party/pi/packages/coding-agent/test/mcp-manager-view.test.ts
alexion 6081e3e325 chore(vendor): import pi 1.3.0
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree.

git-subtree-dir: third_party/pi

git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
2026-10-15 17:58:48 -04:00

41 lines
1.4 KiB
TypeScript

import { setKeybindings, type TUI } from "@earendil-works/pi-tui";
import { beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import { KeybindingsManager } from "../src/core/keybindings.ts";
import { McpManagerView } from "../src/extensions/mcp/ui.ts";
import { initTheme, theme } from "../src/modes/interactive/theme/theme.ts";
import { stripAnsi } from "../src/utils/ansi.ts";
const ESCAPE = "\x1b";
const tui = { requestRender: vi.fn() } as unknown as TUI;
function rendered(view: McpManagerView): string {
return stripAnsi(view.render(80).join("\n"));
}
describe("MCP manager status screen", () => {
beforeAll(() => {
initTheme("dark");
});
beforeEach(() => {
setKeybindings(new KeybindingsManager());
});
// #10565
test("cancels the running operation with the cancel key", () => {
const view = new McpManagerView(tui, theme, new KeybindingsManager());
const onCancel = vi.fn();
view.status("Sign in to issues", "Contacting the authorization server…", onCancel);
expect(rendered(view)).toContain("cancel");
view.handleInput(ESCAPE);
expect(onCancel).toHaveBeenCalledOnce();
});
test("ignores the cancel key for operations that cannot be cancelled", () => {
const view = new McpManagerView(tui, theme, new KeybindingsManager());
view.status("Sign in to issues", "Connecting…");
expect(rendered(view)).not.toContain("cancel");
view.handleInput(ESCAPE);
});
});