blob: c8a0c28077ff004437a3c1b1ccb5701f0ae5332d [file] [log] [blame]
Philip Zeyliger99a9a022025-04-27 15:15:25 +00001import { test, expect } from "@sand4rt/experimental-ct-web";
2import { SketchCallStatus } from "./sketch-call-status";
3
4test("initializes with zero LLM calls and empty tool calls by default", async ({
5 mount,
6}) => {
7 const component = await mount(SketchCallStatus, {});
8
9 // Check properties via component's evaluate method
10 const llmCalls = await component.evaluate(
11 (el: SketchCallStatus) => el.llmCalls,
12 );
13 expect(llmCalls).toBe(0);
14
15 const toolCalls = await component.evaluate(
16 (el: SketchCallStatus) => el.toolCalls,
17 );
18 expect(toolCalls).toEqual([]);
19
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070020 // Check that indicators are not active
21 await expect(component.locator(".llm-indicator")).not.toHaveClass(/active/);
22 await expect(component.locator(".tool-indicator")).not.toHaveClass(/active/);
Philip Zeyliger99a9a022025-04-27 15:15:25 +000023});
24
25test("displays the correct state for active LLM calls", async ({ mount }) => {
26 const component = await mount(SketchCallStatus, {
27 props: {
28 llmCalls: 3,
29 toolCalls: [],
30 },
31 });
32
33 // Check that LLM indicator is active
34 await expect(component.locator(".llm-indicator")).toHaveClass(/active/);
Autoformatter570c3f82025-04-29 18:26:50 +000035
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070036 // Check that LLM indicator has the correct background and color
37 await expect(component.locator(".llm-indicator.active")).toBeVisible();
Philip Zeyliger99a9a022025-04-27 15:15:25 +000038
39 // Check that tool indicator is not active
40 await expect(component.locator(".tool-indicator")).not.toHaveClass(/active/);
41});
42
43test("displays the correct state for active tool calls", async ({ mount }) => {
44 const component = await mount(SketchCallStatus, {
45 props: {
46 llmCalls: 0,
47 toolCalls: ["bash", "think"],
48 },
49 });
50
51 // Check that tool indicator is active
52 await expect(component.locator(".tool-indicator")).toHaveClass(/active/);
Autoformatter570c3f82025-04-29 18:26:50 +000053
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070054 // Check that tool indicator has the correct background and color
55 await expect(component.locator(".tool-indicator.active")).toBeVisible();
Philip Zeyliger99a9a022025-04-27 15:15:25 +000056
57 // Check that LLM indicator is not active
58 await expect(component.locator(".llm-indicator")).not.toHaveClass(/active/);
59});
60
61test("displays both indicators when both call types are active", async ({
62 mount,
63}) => {
64 const component = await mount(SketchCallStatus, {
65 props: {
66 llmCalls: 1,
67 toolCalls: ["patch"],
68 },
69 });
70
71 // Check that both indicators are active
72 await expect(component.locator(".llm-indicator")).toHaveClass(/active/);
73 await expect(component.locator(".tool-indicator")).toHaveClass(/active/);
Autoformatter570c3f82025-04-29 18:26:50 +000074
Philip Zeyligerc2b6bdf2025-04-29 11:17:47 -070075 // Check that both active indicators are visible with their respective styles
76 await expect(component.locator(".llm-indicator.active")).toBeVisible();
77 await expect(component.locator(".tool-indicator.active")).toBeVisible();
Philip Zeyliger99a9a022025-04-27 15:15:25 +000078});
79
80test("has correct tooltip text for LLM calls", async ({ mount }) => {
81 // Test with singular
82 let component = await mount(SketchCallStatus, {
83 props: {
84 llmCalls: 1,
85 toolCalls: [],
86 },
87 });
88
89 await expect(component.locator(".llm-indicator")).toHaveAttribute(
90 "title",
91 "1 LLM call in progress",
92 );
93
94 await component.unmount();
95
96 // Test with plural
97 component = await mount(SketchCallStatus, {
98 props: {
99 llmCalls: 2,
100 toolCalls: [],
101 },
102 });
103
104 await expect(component.locator(".llm-indicator")).toHaveAttribute(
105 "title",
106 "2 LLM calls in progress",
107 );
108});
109
110test("has correct tooltip text for tool calls", async ({ mount }) => {
111 // Test with singular
112 let component = await mount(SketchCallStatus, {
113 props: {
114 llmCalls: 0,
115 toolCalls: ["bash"],
116 },
117 });
118
119 await expect(component.locator(".tool-indicator")).toHaveAttribute(
120 "title",
121 "1 tool call in progress: bash",
122 );
123
124 await component.unmount();
125
126 // Test with plural
127 component = await mount(SketchCallStatus, {
128 props: {
129 llmCalls: 0,
130 toolCalls: ["bash", "think"],
131 },
132 });
133
134 await expect(component.locator(".tool-indicator")).toHaveAttribute(
135 "title",
136 "2 tool calls in progress: bash, think",
137 );
138});
Philip Zeyliger5e357022025-05-16 04:50:34 +0000139
Autoformatter8c463622025-05-16 21:54:17 +0000140test("displays IDLE status when isIdle is true and not disconnected", async ({
141 mount,
142}) => {
Philip Zeyliger5e357022025-05-16 04:50:34 +0000143 const component = await mount(SketchCallStatus, {
144 props: {
145 isIdle: true,
146 isDisconnected: false,
147 llmCalls: 0,
148 toolCalls: [],
149 },
150 });
151
152 // Check that the status banner has the correct class and text
153 await expect(component.locator(".status-banner")).toHaveClass(/status-idle/);
154 await expect(component.locator(".status-banner")).toHaveText("IDLE");
155});
156
Autoformatter8c463622025-05-16 21:54:17 +0000157test("displays WORKING status when isIdle is false and not disconnected", async ({
158 mount,
159}) => {
Philip Zeyliger5e357022025-05-16 04:50:34 +0000160 const component = await mount(SketchCallStatus, {
161 props: {
162 isIdle: false,
163 isDisconnected: false,
164 llmCalls: 1,
165 toolCalls: [],
166 },
167 });
168
169 // Check that the status banner has the correct class and text
Autoformatter8c463622025-05-16 21:54:17 +0000170 await expect(component.locator(".status-banner")).toHaveClass(
171 /status-working/,
172 );
Philip Zeyliger5e357022025-05-16 04:50:34 +0000173 await expect(component.locator(".status-banner")).toHaveText("WORKING");
174});
175
Autoformatter8c463622025-05-16 21:54:17 +0000176test("displays DISCONNECTED status when isDisconnected is true regardless of isIdle", async ({
177 mount,
178}) => {
Philip Zeyliger5e357022025-05-16 04:50:34 +0000179 const component = await mount(SketchCallStatus, {
180 props: {
181 isIdle: true, // Even when idle
182 isDisconnected: true,
183 llmCalls: 0,
184 toolCalls: [],
185 },
186 });
187
188 // Check that the status banner has the correct class and text
Autoformatter8c463622025-05-16 21:54:17 +0000189 await expect(component.locator(".status-banner")).toHaveClass(
190 /status-disconnected/,
191 );
Philip Zeyliger5e357022025-05-16 04:50:34 +0000192 await expect(component.locator(".status-banner")).toHaveText("DISCONNECTED");
193});