Elffuss BraidHub

kikocis/continue public

main · 2.4 KiBRawPermalink
1import { render } from "ink-testing-library";
2import React from "react";
3
4import { createUITestContext } from "../../test-helpers/ui-test-context.js";
5import { AppRoot } from "../AppRoot.js";
6
7describe("TUIChat - Tool Display Tests", () => {
8 let context: any;
9
10 beforeEach(() => {
11 context = createUITestContext({
12 allServicesReady: true,
13 serviceState: "ready",
14 });
15 });
16
17 afterEach(() => {
18 context.cleanup();
19 });
20
21 it("renders without crashing when tools are available", () => {
22 const { lastFrame } = render(<AppRoot remoteUrl="http://localhost:3000" />);
23 const frame = lastFrame();
24
25 expect(frame).toBeDefined();
26 expect(frame).toContain("Ask anything");
27 });
28
29 it("handles UI with no tools configured", () => {
30 const { lastFrame } = render(<AppRoot remoteUrl="http://localhost:3000" />);
31 const frame = lastFrame();
32
33 // Should render normally even without tools
34 expect(frame).toBeDefined();
35 expect(frame).toContain("Remote Mode");
36 });
37
38 it("maintains UI stability during tool operations", async () => {
39 const { lastFrame, stdin } = render(
40 <AppRoot remoteUrl="http://localhost:3000" />,
41 );
42
43 // Type a message that might trigger tool use
44 stdin.write("Use a tool to help me");
45
46 await new Promise((resolve) => setTimeout(resolve, 50));
47
48 const frame = lastFrame();
49
50 // UI should remain stable
51 expect(frame).toBeDefined();
52 if (frame) {
53 expect(frame.length).toBeGreaterThan(0);
54 }
55 });
56
57 it("shows tool-related slash commands", async () => {
58 const { lastFrame, stdin } = render(
59 <AppRoot remoteUrl="http://localhost:3000" />,
60 );
61
62 // Wait for initial render
63 await new Promise((resolve) => setTimeout(resolve, 50));
64
65 // Type / to see commands
66 stdin.write("/");
67
68 // Wait longer for slash command menu
69 await new Promise((resolve) => setTimeout(resolve, 200));
70
71 const frame = lastFrame();
72
73 // Should show slash command character
74 expect(frame).toContain("/");
75
76 // The slash command menu might show different UI states
77 // On Windows, the timing might be different
78 const hasSlashCommandIndicator = frame
79 ? frame.includes("↑/↓ to navigate") ||
80 frame.includes("/exit") ||
81 frame.includes("◉ /") ||
82 frame.includes("/ for slash commands")
83 : false;
84
85 expect(hasSlashCommandIndicator).toBe(true);
86 });
87});