blob: 88ae3bd8c50a35dc281d2e3e32040e078bc523cc [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});