From e77562e03980fa7863121d011ebef8add06878fc Mon Sep 17 00:00:00 2001 From: Ting-Wai To <40179554+tingwai@users.noreply.github.com> Date: Thu, 14 Aug 2025 13:39:19 -0700 Subject: [PATCH] fix tests --- src/ui/__tests__/TUIChat.fileSearch.test.tsx | 14 ++++++------ src/ui/__tests__/TUIChat.remote.test.tsx | 20 ++++++++--------- src/ui/__tests__/TUIChat.toolDisplay.test.tsx | 22 +++++++++---------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/ui/__tests__/TUIChat.fileSearch.test.tsx b/src/ui/__tests__/TUIChat.fileSearch.test.tsx index 5ab4672e1..ce8e7ca20 100644 --- a/src/ui/__tests__/TUIChat.fileSearch.test.tsx +++ b/src/ui/__tests__/TUIChat.fileSearch.test.tsx @@ -19,7 +19,7 @@ describe("TUIChat - @ File Search Tests", () => { // The @ might be in the input line or in a file search UI const hasAtSymbol = frame.includes("@") || frame.includes("◉ @"); expect(hasAtSymbol).toBe(true); - + // Mode-specific UI if (mode === 'remote') { expect(frame).toContain("Remote Mode"); @@ -42,12 +42,12 @@ describe("TUIChat - @ File Search Tests", () => { // Should show the typed text expect(frame).toContain("@READ"); - + // Navigation hints only show in local mode if (mode === 'local') { - expect(frame).toContain("Use ↑/↓ to navigate"); + expect(frame).toContain("↑/↓ to navigate"); } - + // Mode-specific checks if (mode === 'remote') { expect(frame).toContain("Remote Mode"); @@ -70,7 +70,7 @@ describe("TUIChat - @ File Search Tests", () => { // Should handle multiple @ without crashing expect(frame).toBeDefined(); expect(frame).toContain("@@test"); - + // Mode-specific UI elements if (mode === 'remote') { expect(frame).toContain("Remote Mode"); @@ -93,10 +93,10 @@ describe("TUIChat - @ File Search Tests", () => { // Should not crash and show something expect(frame).toBeDefined(); expect(frame.length).toBeGreaterThan(0); - + // Navigation hints only show in local mode if (mode === 'local') { - expect(frame).toContain("Use ↑/↓ to navigate"); + expect(frame).toContain("↑/↓ to navigate"); } }); }); \ No newline at end of file diff --git a/src/ui/__tests__/TUIChat.remote.test.tsx b/src/ui/__tests__/TUIChat.remote.test.tsx index a279c084b..887baa2c6 100644 --- a/src/ui/__tests__/TUIChat.remote.test.tsx +++ b/src/ui/__tests__/TUIChat.remote.test.tsx @@ -23,7 +23,7 @@ describe("TUIChat - Remote Server Tests", () => { ); const frame = lastFrame(); - + expect(frame).toBeDefined(); expect(frame).toContain("Remote Mode"); expect(frame).toContain("Ask anything"); @@ -34,7 +34,7 @@ describe("TUIChat - Remote Server Tests", () => { ); const frame = lastFrame(); - + // Should show remote mode in the UI expect(frame).toContain("◉ Remote Mode"); }); @@ -44,10 +44,10 @@ describe("TUIChat - Remote Server Tests", () => { ); const frame = lastFrame(); - + // Should not show loading services message expect(frame).not.toContain("Loading services"); - + // Should go directly to chat UI expect(frame).toContain("Ask anything"); }); @@ -57,7 +57,7 @@ describe("TUIChat - Remote Server Tests", () => { ); const frame = lastFrame(); - + // Should still work with different URLs expect(frame).toBeDefined(); expect(frame).toContain("Remote Mode"); @@ -78,19 +78,19 @@ describe("TUIChat - Remote Server Tests", () => { await new Promise((resolve) => setTimeout(resolve, 200)); const frame = lastFrame(); - + // Should show slash character at minimum expect(frame).toContain("/"); - + // The slash command menu might show /exit or navigation instructions // Different timing might show different states const hasSlashCommandUI = frame ? ( - frame.includes("/exit") || - frame.includes("Use ↑/↓ to navigate") || + frame.includes("/exit") || + frame.includes("↑/↓ to navigate") || frame.includes("◉ /") || frame.includes("/ for slash commands") // Placeholder text is also valid ) : false; - + expect(hasSlashCommandUI).toBe(true); }); }); \ No newline at end of file diff --git a/src/ui/__tests__/TUIChat.toolDisplay.test.tsx b/src/ui/__tests__/TUIChat.toolDisplay.test.tsx index d4e691939..5ed176eca 100644 --- a/src/ui/__tests__/TUIChat.toolDisplay.test.tsx +++ b/src/ui/__tests__/TUIChat.toolDisplay.test.tsx @@ -23,7 +23,7 @@ describe("TUIChat - Tool Display Tests", () => { ); const frame = lastFrame(); - + expect(frame).toBeDefined(); expect(frame).toContain("Ask anything"); }); @@ -33,7 +33,7 @@ describe("TUIChat - Tool Display Tests", () => { ); const frame = lastFrame(); - + // Should render normally even without tools expect(frame).toBeDefined(); expect(frame).toContain("Remote Mode"); @@ -46,11 +46,11 @@ describe("TUIChat - Tool Display Tests", () => { // Type a message that might trigger tool use stdin.write("Use a tool to help me"); - + await new Promise((resolve) => setTimeout(resolve, 50)); - + const frame = lastFrame(); - + // UI should remain stable expect(frame).toBeDefined(); if (frame) { @@ -68,24 +68,24 @@ describe("TUIChat - Tool Display Tests", () => { // Type / to see commands stdin.write("/"); - + // Wait longer for slash command menu await new Promise((resolve) => setTimeout(resolve, 200)); - + const frame = lastFrame(); - + // Should show slash command character expect(frame).toContain("/"); - + // The slash command menu might show different UI states // On Windows, the timing might be different const hasSlashCommandIndicator = frame ? ( - frame.includes("Use ↑/↓ to navigate") || + frame.includes("↑/↓ to navigate") || frame.includes("/exit") || frame.includes("◉ /") || frame.includes("/ for slash commands") ) : false; - + expect(hasSlashCommandIndicator).toBe(true); }); }); \ No newline at end of file