Elffuss BraidHub

kikocis/continue public

main · 3.0 KiBRawPermalink
1import { renderInMode, testSingleMode } from "./TUIChat.dualModeHelper.js";
2
3describe("TUIChat - @ File Search Tests", () => {
4 testSingleMode("shows @ character when user types @", "local", async () => {
5 const { lastFrame, stdin } = renderInMode("local");
6
7 // Wait a bit for initial render
8 await new Promise((resolve) => setTimeout(resolve, 100));
9
10 // Type the @ character to trigger file search
11 stdin.write("@");
12
13 // Wait longer for file search to initialize and display files
14 await new Promise((resolve) => setTimeout(resolve, 400));
15
16 const frame = lastFrame()!;
17
18 // Should show @ character in input or show file search UI
19 const hasAtSymbol = frame.includes("@") || frame.includes("◉ @");
20 expect(hasAtSymbol).toBe(true);
21
22 // Local mode specific UI expectations
23 expect(frame).not.toContain("Remote Mode");
24 expect(frame).toContain("Continue CLI");
25 });
26
27 testSingleMode(
28 "shows search text when user types after @",
29 "local",
30 async () => {
31 const { lastFrame, stdin } = renderInMode("local");
32
33 // Type @ followed by text to filter files
34 stdin.write("@READ");
35
36 // Wait for file search to filter and display results
37 await new Promise((resolve) => setTimeout(resolve, 500));
38
39 const frame = lastFrame()!;
40
41 // Should show the typed text
42 expect(frame).toContain("@READ");
43
44 // Should show either navigation hints or at least indicate file search is working
45 const hasNavigationHints = frame.includes("↑/↓ to navigate");
46 const hasFileSearch = frame.includes("@READ");
47 expect(hasNavigationHints || hasFileSearch).toBe(true);
48
49 // Local mode specific UI expectations
50 expect(frame).not.toContain("Remote Mode");
51 },
52 );
53
54 testSingleMode("handles multiple @ characters", "local", async () => {
55 const { lastFrame, stdin } = renderInMode("local");
56
57 // Type multiple @ characters
58 stdin.write("@@test");
59
60 // Wait for UI update
61 await new Promise((resolve) => setTimeout(resolve, 500));
62
63 const frame = lastFrame();
64
65 // Should handle multiple @ without crashing
66 expect(frame).toBeDefined();
67 expect(frame).toContain("@@test");
68
69 // Local mode specific UI elements
70 expect(frame).toContain("Continue CLI");
71 });
72
73 testSingleMode(
74 "handles @ character input without crashing",
75 "local",
76 async () => {
77 const { lastFrame, stdin } = renderInMode("local");
78
79 // Type @ to trigger file search
80 stdin.write("@");
81
82 // Wait for potential async operations
83 await new Promise((resolve) => setTimeout(resolve, 200));
84
85 const frame = lastFrame()!;
86
87 // Should not crash and show something
88 expect(frame).toBeDefined();
89 expect(frame.length).toBeGreaterThan(0);
90
91 // Should show either navigation hints or at least the @ character in file search
92 const hasNavigationHints = frame.includes("↑/↓ to navigate");
93 const hasFileSearchUI = frame.includes("@");
94 expect(hasNavigationHints || hasFileSearchUI).toBe(true);
95 },
96 );
97});