Skip to content

Commit d92e3d3

Browse files
committed
Add tests for the MCP auth-marker clearing and retry-copy transitions
1 parent 5963041 commit d92e3d3

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

src/tui/command-surfaces.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,31 @@ describe("mcp surface", () => {
19751975
});
19761976
});
19771977

1978+
test("a timed-out authorization failure still offers Enter-retry copy", async () => {
1979+
await withWiredShell(async (shell, harness) => {
1980+
openCommandSurface(shell, "mcp", {
1981+
notify: () => undefined,
1982+
mcp: {
1983+
// Short timeout wording so the two-line describe zone has room
1984+
// left for the impact line — a `what` that wraps to both lines
1985+
// crowds `impact` out by design (see describeZoneLines).
1986+
list: () => [
1987+
{
1988+
name: "granola",
1989+
state: "failed",
1990+
error: "timed out waiting for the browser",
1991+
},
1992+
],
1993+
openAuthURL: () => undefined,
1994+
},
1995+
});
1996+
await harness.renderOnce();
1997+
const frame = harness.captureCharFrame();
1998+
expect(frame).toContain("granola — failed");
1999+
expect(frame).toContain("Enter retries");
2000+
});
2001+
});
2002+
19782003
test("Alt+R confirms before removing a custom server", async () => {
19792004
await withWiredShell(async (shell, harness) => {
19802005
const removed: string[] = [];

src/tui/runtime-channels.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,30 @@ describe("mcp.status channel", () => {
169169
}
170170
});
171171

172+
test("an ordinary failure after needs-auth clears the standing auth mark", async () => {
173+
const { host, emitter, frame, cleanup } = await mountHeadless();
174+
try {
175+
emitter.emit("mcp.status", {
176+
name: "granola",
177+
state: "needs-auth",
178+
url: "https://mcp.test/auth",
179+
});
180+
expect(await frame()).toContain("mcp !");
181+
182+
emitter.emit("mcp.status", {
183+
name: "granola",
184+
state: "failed",
185+
error: "ECONNREFUSED",
186+
});
187+
const painted = await frame();
188+
expect(host.shell.mcpNeedsAuth).toEqual([]);
189+
expect(painted).not.toContain("mcp !");
190+
expect(host.shell.statusFlash).toContain("mcp granola did not connect");
191+
} finally {
192+
cleanup();
193+
}
194+
});
195+
172196
test("a failed connect keeps the landing mountain and rides the notice strip (CL-5600)", async () => {
173197
// Full product-host path: mcp.status → mcpNotice → surfaceSystemNotice.
174198
// The unit landing suite covers surfaceSystemNotice alone; this locks the

0 commit comments

Comments
 (0)