restore remote mode tests
This commit is contained in:
parent
dc82fc8e36
commit
90bb223e20
5 changed files with 172 additions and 56 deletions
|
|
@ -17,9 +17,9 @@ describe("TUIChat - @ File Search Tests", () => {
|
|||
context.cleanup();
|
||||
});
|
||||
|
||||
it("shows @ character when user types @", async () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("shows @ character when user types @ in local mode", async () => {
|
||||
// Test local mode - file search should work
|
||||
const { lastFrame, stdin } = render(<TUIChat />);
|
||||
|
||||
// Wait a bit for initial render
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
|
|
@ -37,13 +37,16 @@ describe("TUIChat - @ File Search Tests", () => {
|
|||
const hasAtSymbol = frame.includes("@") || frame.includes("◉ @");
|
||||
expect(hasAtSymbol).toBe(true);
|
||||
|
||||
// Should still show the interface
|
||||
expect(frame).toContain("Remote Mode");
|
||||
// Should NOT show remote mode
|
||||
expect(frame).not.toContain("Remote Mode");
|
||||
|
||||
// Should show local mode UI elements
|
||||
expect(frame).toContain("Continue CLI");
|
||||
});
|
||||
|
||||
it("shows search text when user types after @", async () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("shows search text when user types after @ in local mode", async () => {
|
||||
// Test local mode
|
||||
const { lastFrame, stdin } = render(<TUIChat />);
|
||||
|
||||
// Type @ followed by text to filter files
|
||||
stdin.write("@READ");
|
||||
|
|
@ -56,13 +59,17 @@ describe("TUIChat - @ File Search Tests", () => {
|
|||
// Should show the typed text
|
||||
expect(frame).toContain("@READ");
|
||||
|
||||
// Should still be in remote mode
|
||||
expect(frame).toContain("Remote Mode");
|
||||
// Should be in local mode
|
||||
expect(frame).not.toContain("Remote Mode");
|
||||
|
||||
// When typing after @, we're in file search mode
|
||||
// Should show file navigation hints
|
||||
expect(frame).toContain("Use ↑/↓ to navigate");
|
||||
});
|
||||
|
||||
it("handles multiple @ characters", async () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("handles multiple @ characters in local mode", async () => {
|
||||
// Test local mode
|
||||
const { lastFrame, stdin } = render(<TUIChat />);
|
||||
|
||||
// Type multiple @ characters
|
||||
stdin.write("@@test");
|
||||
|
|
@ -75,11 +82,14 @@ describe("TUIChat - @ File Search Tests", () => {
|
|||
// Should handle multiple @ without crashing
|
||||
expect(frame).toBeDefined();
|
||||
expect(frame).toContain("@@test");
|
||||
|
||||
// Should be in local mode with all features
|
||||
expect(frame).toContain("Continue CLI");
|
||||
});
|
||||
|
||||
it("handles @ character input without crashing", async () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("handles @ character input without crashing in local mode", async () => {
|
||||
// Test local mode
|
||||
const { lastFrame, stdin } = render(<TUIChat />);
|
||||
|
||||
// Type @ to trigger file search
|
||||
stdin.write("@");
|
||||
|
|
@ -92,5 +102,26 @@ describe("TUIChat - @ File Search Tests", () => {
|
|||
// Should not crash and show something
|
||||
expect(frame).toBeDefined();
|
||||
expect(frame.length).toBeGreaterThan(0);
|
||||
|
||||
// When @ is typed, we're in file search mode
|
||||
// Should show file search UI with navigation hints
|
||||
expect(frame).toContain("Use ↑/↓ to navigate");
|
||||
});
|
||||
|
||||
it("@ file search still works in remote mode", async () => {
|
||||
// Remote mode should still support file search
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
|
||||
stdin.write("@test");
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
|
||||
const frame = lastFrame();
|
||||
|
||||
// Should show remote mode
|
||||
expect(frame).toContain("Remote Mode");
|
||||
|
||||
// Should show the @ input
|
||||
expect(frame).toContain("@test");
|
||||
});
|
||||
});
|
||||
|
|
@ -17,25 +17,29 @@ describe("TUIChat - User Input Tests", () => {
|
|||
context.cleanup();
|
||||
});
|
||||
|
||||
it("shows typed text in input field", () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("shows typed text in input field in local mode", () => {
|
||||
// Test local mode - services are mocked to be ready
|
||||
const { lastFrame, stdin } = render(<TUIChat />);
|
||||
|
||||
stdin.write("Testing 123");
|
||||
|
||||
const frame = lastFrame();
|
||||
// The input might be in a different format, let's be more flexible
|
||||
// The input should be visible in local mode
|
||||
expect(frame ? frame.toLowerCase() : "").toMatch(
|
||||
/testing|123|ask anything/
|
||||
);
|
||||
|
||||
// Should not show remote mode indicator
|
||||
expect(frame).not.toContain("Remote Mode");
|
||||
});
|
||||
|
||||
it("handles Enter key to submit", async () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("handles Enter key to submit in local mode", async () => {
|
||||
// Test local mode
|
||||
const { lastFrame, stdin } = render(<TUIChat />);
|
||||
|
||||
const beforeEnter = lastFrame();
|
||||
expect(beforeEnter).toContain("Ask anything");
|
||||
expect(beforeEnter).toContain("@ for context");
|
||||
|
||||
stdin.write("\r");
|
||||
|
||||
|
|
@ -47,11 +51,14 @@ describe("TUIChat - User Input Tests", () => {
|
|||
// The UI should remain stable after Enter (no crash)
|
||||
expect(afterEnter).toBeDefined();
|
||||
expect(afterEnter).toContain("Ask anything");
|
||||
|
||||
// Local mode features should still be available
|
||||
expect(afterEnter).toContain("/ for slash commands");
|
||||
});
|
||||
|
||||
it("handles special characters in input without crashing", () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("handles special characters in input without crashing in local mode", () => {
|
||||
// Test local mode
|
||||
const { lastFrame, stdin } = render(<TUIChat />);
|
||||
|
||||
// Try typing various special characters
|
||||
stdin.write("!@#$%^&*()");
|
||||
|
|
@ -64,5 +71,23 @@ describe("TUIChat - User Input Tests", () => {
|
|||
|
||||
// UI should still be functional
|
||||
expect(frame).toContain("Ask anything");
|
||||
|
||||
// Should show all local mode features
|
||||
expect(frame).toContain("Continue CLI");
|
||||
});
|
||||
|
||||
it("input still works in remote mode when needed", () => {
|
||||
// Remote mode should still function for remote testing
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
|
||||
stdin.write("Remote test");
|
||||
|
||||
const frame = lastFrame();
|
||||
|
||||
// Should show remote mode
|
||||
expect(frame).toContain("Remote Mode");
|
||||
|
||||
// Input should still work
|
||||
expect(frame).toBeDefined();
|
||||
});
|
||||
});
|
||||
6
src/ui/__tests__/TUIChat.messages.local.test.tsx
Normal file
6
src/ui/__tests__/TUIChat.messages.local.test.tsx
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// This file has been removed - tests migrated to TUIChat.messages.test.tsx
|
||||
describe('placeholder', () => {
|
||||
it('exists', () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
@ -4,6 +4,10 @@ import type { ChatCompletionMessageParam } from "openai/resources/index.js";
|
|||
import { createUITestContext } from "../../test-helpers/ui-test-context.js";
|
||||
import TUIChat from "../TUIChat.js";
|
||||
|
||||
// Import our new test utilities (they will work with mocked modules)
|
||||
import { renderWithServices } from "../../test-helpers/renderWithServices.js";
|
||||
import { createTestServiceContainer } from "../../test-helpers/testServiceContainer.js";
|
||||
|
||||
describe("TUIChat - Message Display Tests", () => {
|
||||
let context: any;
|
||||
|
||||
|
|
@ -18,9 +22,9 @@ describe("TUIChat - Message Display Tests", () => {
|
|||
context.cleanup();
|
||||
});
|
||||
|
||||
it("displays empty chat correctly", () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("displays empty chat correctly in local mode", () => {
|
||||
// Test local mode - services are mocked to be ready
|
||||
const { lastFrame } = render(<TUIChat />);
|
||||
|
||||
const frame = lastFrame();
|
||||
|
||||
|
|
@ -30,11 +34,14 @@ describe("TUIChat - Message Display Tests", () => {
|
|||
// Should have box borders (using the actual characters)
|
||||
expect(frame).toContain("│");
|
||||
|
||||
// Should show remote mode indicator
|
||||
expect(frame).toContain("Remote Mode");
|
||||
// Should NOT show remote mode indicator in local mode
|
||||
expect(frame).not.toContain("Remote Mode");
|
||||
|
||||
// Should show Continue CLI branding
|
||||
expect(frame).toContain("Continue CLI");
|
||||
});
|
||||
|
||||
it("displays messages in correct order", () => {
|
||||
it("displays messages in correct order in local mode", () => {
|
||||
// Set up chat history in context
|
||||
context = createUITestContext({
|
||||
allServicesReady: true,
|
||||
|
|
@ -47,30 +54,48 @@ describe("TUIChat - Message Display Tests", () => {
|
|||
],
|
||||
});
|
||||
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
// Test local mode
|
||||
const { lastFrame } = render(<TUIChat />);
|
||||
|
||||
// For now, just verify the component renders
|
||||
// Verify the component renders
|
||||
const frame = lastFrame();
|
||||
expect(frame).toContain("Ask anything");
|
||||
|
||||
// The messages should be displayed if the component renders them
|
||||
// Note: The exact rendering of messages depends on the component implementation
|
||||
// In local mode, we have access to more UI elements
|
||||
expect(frame).toContain("@ for context");
|
||||
expect(frame).toContain("/ for slash commands");
|
||||
});
|
||||
|
||||
it("shows input prompt in remote mode", () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("shows input prompt in local mode", () => {
|
||||
// Test local mode
|
||||
const { lastFrame } = render(<TUIChat />);
|
||||
|
||||
const frame = lastFrame();
|
||||
|
||||
// Should show the default prompt
|
||||
expect(frame).toContain("Ask anything");
|
||||
|
||||
// Should show context hint
|
||||
expect(frame).toContain("@ for context");
|
||||
|
||||
// Should show slash commands hint
|
||||
expect(frame).toContain("/ for slash commands");
|
||||
|
||||
// Should indicate remote mode
|
||||
// Should NOT indicate remote mode
|
||||
expect(frame).not.toContain("Remote Mode");
|
||||
});
|
||||
|
||||
// Additional test to demonstrate remote mode still works
|
||||
it("still supports remote mode for remote server testing", () => {
|
||||
// Remote mode should still work for testing remote connections
|
||||
const { lastFrame } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
|
||||
const frame = lastFrame();
|
||||
|
||||
// Should show remote mode indicator
|
||||
expect(frame).toContain("Remote Mode");
|
||||
|
||||
// Should still have the UI
|
||||
expect(frame).toContain("Ask anything");
|
||||
});
|
||||
});
|
||||
|
|
@ -18,9 +18,9 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
context.cleanup();
|
||||
});
|
||||
|
||||
it("shows slash when user types /", async () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("shows slash when user types / in local mode", async () => {
|
||||
// Test local mode - slash commands should work
|
||||
const { lastFrame, stdin } = render(<TUIChat />);
|
||||
|
||||
// Type / to trigger slash command
|
||||
stdin.write("/");
|
||||
|
|
@ -32,11 +32,14 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
|
||||
// Should show the slash character
|
||||
expect(frame).toContain("/");
|
||||
|
||||
// Should NOT show remote mode
|
||||
expect(frame).not.toContain("Remote Mode");
|
||||
});
|
||||
|
||||
it("filters slash commands when typing /log", async () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("filters slash commands when typing /log in local mode", async () => {
|
||||
// Test local mode
|
||||
const { lastFrame, stdin } = render(<TUIChat />);
|
||||
|
||||
// Type /log to trigger slash command filtering
|
||||
stdin.write("/log");
|
||||
|
|
@ -49,13 +52,16 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
// Should show the typed command
|
||||
expect(frame).toContain("/log");
|
||||
|
||||
// UI should remain stable
|
||||
expect(frame).toContain("Remote Mode");
|
||||
// UI should remain stable in local mode
|
||||
expect(frame).not.toContain("Remote Mode");
|
||||
|
||||
// Should show Continue CLI branding
|
||||
expect(frame).toContain("Continue CLI");
|
||||
});
|
||||
|
||||
it("handles tab key after slash command", async () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("handles tab key after slash command in local mode", async () => {
|
||||
// Test local mode
|
||||
const { lastFrame, stdin } = render(<TUIChat />);
|
||||
|
||||
// Type /log and then tab
|
||||
stdin.write("/log");
|
||||
|
|
@ -72,12 +78,14 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
expect(frameAfterTab).toBeDefined();
|
||||
if (frameAfterTab) {
|
||||
expect(frameAfterTab.length).toBeGreaterThan(0);
|
||||
// Should be in local mode
|
||||
expect(frameAfterTab).not.toContain("Remote Mode");
|
||||
}
|
||||
});
|
||||
|
||||
it("shows slash command menu when typing /", async () => {
|
||||
// Use remote mode to bypass service loading
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
it("shows slash command menu when typing / in local mode", async () => {
|
||||
// Test local mode - should have more slash commands available
|
||||
const { lastFrame, stdin } = render(<TUIChat />);
|
||||
|
||||
// Type just /
|
||||
stdin.write("/");
|
||||
|
|
@ -89,8 +97,29 @@ describe("TUIChat - Slash Commands Tests", () => {
|
|||
// Should show the slash
|
||||
expect(frame).toContain("/");
|
||||
|
||||
// In local mode, slash command might be in input
|
||||
// The / should be visible in the UI
|
||||
const hasSlashCommand = frame ? (frame.includes("/") && !frame.includes("Remote Mode")) : false;
|
||||
expect(hasSlashCommand).toBe(true);
|
||||
|
||||
// Should show Continue CLI branding
|
||||
expect(frame).toContain("Continue CLI");
|
||||
});
|
||||
|
||||
it("slash commands still work in remote mode", async () => {
|
||||
// Remote mode should still support basic slash commands
|
||||
const { lastFrame, stdin } = render(<TUIChat remoteUrl="http://localhost:3000" />);
|
||||
|
||||
stdin.write("/");
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
|
||||
const frame = lastFrame();
|
||||
|
||||
// Should show remote mode
|
||||
expect(frame).toContain("Remote Mode");
|
||||
|
||||
// Should show slash command menu
|
||||
expect(frame).toContain("/exit");
|
||||
expect(frame).toContain("Use ↑/↓ to navigate, Enter to select, Tab to complete");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue