diff --git a/extensions/cli/src/ui/__tests__/TUIChat.fileSearch.test.tsx b/extensions/cli/src/ui/__tests__/TUIChat.fileSearch.test.tsx index b38a90cb6..fbed0423a 100644 --- a/extensions/cli/src/ui/__tests__/TUIChat.fileSearch.test.tsx +++ b/extensions/cli/src/ui/__tests__/TUIChat.fileSearch.test.tsx @@ -1,5 +1,5 @@ import { renderInMode, testSingleMode } from "./TUIChat.dualModeHelper.js"; -import { waitForNextRender } from "./TUIChat.testHelper.js"; +import { waitForCondition } from "./TUIChat.testHelper.js"; describe("TUIChat - @ File Search Tests", () => { testSingleMode("shows @ character when user types @", "local", async () => { @@ -34,11 +34,10 @@ describe("TUIChat - @ File Search Tests", () => { // Type @ followed by text to filter files stdin.write("@READ"); - // Wait for file search to filter and display results - await new Promise((resolve) => setTimeout(resolve, 500)); - const frame = lastFrame()!; + waitForCondition(() => lastFrame()!.includes("@READ")); + // Should show the typed text expect(frame).toContain("@READ"); @@ -58,10 +57,11 @@ describe("TUIChat - @ File Search Tests", () => { // Type multiple @ characters stdin.write("@@test"); // Wait for UI update - await waitForNextRender(); const frame = lastFrame(); + await waitForCondition(() => lastFrame()?.includes("@@test") ?? false); + // Should handle multiple @ without crashing expect(frame).toBeDefined(); expect(frame).toContain("@@test"); diff --git a/extensions/cli/src/ui/__tests__/TUIChat.slashCommands.test.tsx b/extensions/cli/src/ui/__tests__/TUIChat.slashCommands.test.tsx index 1f63f3814..b3630d2b6 100644 --- a/extensions/cli/src/ui/__tests__/TUIChat.slashCommands.test.tsx +++ b/extensions/cli/src/ui/__tests__/TUIChat.slashCommands.test.tsx @@ -1,5 +1,5 @@ import { renderInMode, testBothModes } from "./TUIChat.dualModeHelper.js"; -import { waitForNextRender } from "./TUIChat.testHelper.js"; +import { waitForCondition, waitForNextRender } from "./TUIChat.testHelper.js"; describe("TUIChat - Slash Commands Tests", () => { testBothModes("shows slash when user types /", async (mode) => { @@ -28,10 +28,11 @@ describe("TUIChat - Slash Commands Tests", () => { // Type /exi to trigger slash command filtering stdin.write("/exi"); - await waitForNextRender(); const frame = lastFrame(); + waitForCondition(() => lastFrame()?.includes("/exi") ?? false); + // Should show the typed command expect(frame).toContain("/exi");