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
This commit is contained in:
40
third_party/pi/packages/coding-agent/test/mcp-manager-view.test.ts
vendored
Normal file
40
third_party/pi/packages/coding-agent/test/mcp-manager-view.test.ts
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user