| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 1 | import { test, expect } from "@sand4rt/experimental-ct-web"; |
| 2 | import { SketchCallStatus } from "./sketch-call-status"; |
| 3 | |
| 4 | test("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 Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 20 | // 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 Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 23 | }); |
| 24 | |
| 25 | test("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/); |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 35 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 36 | // Check that LLM indicator has the correct background and color |
| 37 | await expect(component.locator(".llm-indicator.active")).toBeVisible(); |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 38 | |
| 39 | // Check that tool indicator is not active |
| 40 | await expect(component.locator(".tool-indicator")).not.toHaveClass(/active/); |
| 41 | }); |
| 42 | |
| 43 | test("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/); |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 53 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 54 | // Check that tool indicator has the correct background and color |
| 55 | await expect(component.locator(".tool-indicator.active")).toBeVisible(); |
| Philip Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 56 | |
| 57 | // Check that LLM indicator is not active |
| 58 | await expect(component.locator(".llm-indicator")).not.toHaveClass(/active/); |
| 59 | }); |
| 60 | |
| 61 | test("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/); |
| Autoformatter | 570c3f8 | 2025-04-29 18:26:50 +0000 | [diff] [blame] | 74 | |
| Philip Zeyliger | c2b6bdf | 2025-04-29 11:17:47 -0700 | [diff] [blame] | 75 | // 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 Zeyliger | 99a9a02 | 2025-04-27 15:15:25 +0000 | [diff] [blame] | 78 | }); |
| 79 | |
| 80 | test("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 | |
| 110 | test("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 | }); |