From dedc3b5134f0e3c28388cc687dd9d8a36d7df06a Mon Sep 17 00:00:00 2001 From: Blomios Date: Wed, 5 Aug 2026 13:48:27 +0200 Subject: [PATCH] =?UTF-8?q?test(chat):=20couvre=20le=20fallback=20TUI=20si?= =?UTF-8?q?=20le=20catalogue=20invalide=20le=20profil=20pinn=C3=A9=20(#149?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- .../features/layout/LayoutGrid.chat.test.tsx | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/frontend/src/features/layout/LayoutGrid.chat.test.tsx b/frontend/src/features/layout/LayoutGrid.chat.test.tsx index 8424779..0948baa 100644 --- a/frontend/src/features/layout/LayoutGrid.chat.test.tsx +++ b/frontend/src/features/layout/LayoutGrid.chat.test.tsx @@ -253,4 +253,58 @@ describe("LayoutGrid custom agent CLI (#147)", () => { ); expect(window.localStorage.getItem(`idea.agent-cell-mode.p1.${leafId}`)).toBe("custom"); }); + + it("falls back to native TUI once the catalog confirms the pinned profile is incompatible", async () => { + const layout = new MockLayoutGateway(); + const agent = new MockAgentGateway(); + const profileGateway = new MockProfileGateway(); + const terminal = new MockTerminalGateway(); + const system = new MockSystemGateway(); + await profileGateway.configureProfiles([ptyProfile]); + const created = await agent.createAgent("p1", { + name: "Worker", + profileId: ptyProfile.id, + }); + const tree = await layout.loadLayout("p1"); + const leafId = leaves(tree)[0].id; + await layout.mutateLayout("p1", { + type: "setCellAgent", + target: leafId, + agent: created.id, + }); + window.localStorage.setItem(`idea.agent-cell-mode.p1.${leafId}`, "custom"); + + const agentsLoaded = deferred(); + const profilesLoaded = deferred(); + const originalListAgents = agent.listAgents.bind(agent); + const originalListProfiles = profileGateway.listProfiles.bind(profileGateway); + vi.spyOn(agent, "listAgents").mockImplementation(async (projectId) => { + await agentsLoaded.promise; + return originalListAgents(projectId); + }); + vi.spyOn(profileGateway, "listProfiles").mockImplementation(async () => { + await profilesLoaded.promise; + return originalListProfiles(); + }); + + renderGrid({ + layout, + agent, + profile: profileGateway, + terminal, + system, + } as unknown as Gateways); + + await waitFor(() => expect(screen.getByTestId("layout-leaf")).toBeTruthy()); + expect(window.localStorage.getItem(`idea.agent-cell-mode.p1.${leafId}`)).toBe("custom"); + + agentsLoaded.resolve(); + profilesLoaded.resolve(); + + await waitFor(() => + expect(window.localStorage.getItem(`idea.agent-cell-mode.p1.${leafId}`)).toBe("tui"), + ); + expect(screen.getByTestId("terminal-view")).toBeTruthy(); + expect(screen.queryByTestId("custom-agent-chat-view")).toBeNull(); + }); });