Elffuss BraidHub

kikocis/continue public

main · 2.2 KiBRawPermalink
1import { createUITestContext } from "../../test-helpers/ui-test-context.js";
2
3import { testBothModes, renderInMode } from "./TUIChat.dualModeHelper.js";
4
5describe("TUIChat - Message Display Tests", () => {
6 testBothModes("displays empty chat correctly", (mode) => {
7 const { lastFrame } = renderInMode(mode);
8
9 const frame = lastFrame();
10
11 // Should show the interface
12 expect(frame).toContain("Ask anything");
13
14 // Should have box borders (using the actual characters)
15 expect(frame).toContain("│");
16
17 // Mode-specific assertions
18 if (mode === "remote") {
19 expect(frame).toContain("Remote Mode");
20 } else {
21 expect(frame).not.toContain("Remote Mode");
22 expect(frame).toContain("Continue CLI");
23 }
24 });
25
26 testBothModes("shows input prompt", (mode) => {
27 const { lastFrame } = renderInMode(mode);
28
29 const frame = lastFrame();
30
31 // Should show the default prompt
32 expect(frame).toContain("Ask anything");
33
34 // Should show slash commands hint
35 expect(frame).toContain("/ for slash commands");
36
37 // In local mode, also shows context hint
38 if (mode === "local") {
39 expect(frame).toContain("@ for context");
40 }
41
42 // Verify mode-specific UI
43 if (mode === "remote") {
44 expect(frame).toContain("Remote Mode");
45 } else {
46 expect(frame).toContain("Continue CLI");
47 }
48 });
49
50 testBothModes("displays messages in correct order", (mode) => {
51 // Set up chat history in context
52 const context = createUITestContext({
53 allServicesReady: true,
54 serviceState: "ready",
55 chatMessages: [
56 { role: "user", content: "First message" },
57 { role: "assistant", content: "First response" },
58 { role: "user", content: "Second message" },
59 { role: "assistant", content: "Second response" },
60 ],
61 });
62
63 const { lastFrame } = renderInMode(mode);
64
65 // Verify the component renders
66 const frame = lastFrame();
67 expect(frame).toContain("Ask anything");
68
69 // In local mode, we have access to more UI elements
70 if (mode === "local") {
71 expect(frame).toContain("@ for context");
72 expect(frame).toContain("/ for slash commands");
73 }
74
75 context.cleanup();
76 });
77});