| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 1 | import { test, expect } from "@sand4rt/experimental-ct-web"; |
| 2 | import { SketchNetworkStatus } from "./sketch-network-status"; |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 3 | |
| Philip Zeyliger | 25f6ff1 | 2025-05-02 04:24:10 +0000 | [diff] [blame] | 4 | // Test for the status indicator dot |
| 5 | test("shows status indicator dot when connected", async ({ mount }) => { |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 6 | const component = await mount(SketchNetworkStatus, { |
| 7 | props: { |
| 8 | connection: "connected", |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 9 | }, |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 10 | }); |
| 11 | |
| Philip Zeyliger | 25f6ff1 | 2025-05-02 04:24:10 +0000 | [diff] [blame] | 12 | // The status container and indicator should be visible |
| 13 | await expect(component.locator(".status-container")).toBeVisible(); |
| 14 | await expect(component.locator(".status-indicator")).toBeVisible(); |
| 15 | await expect(component.locator(".status-indicator")).toHaveClass(/connected/); |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 16 | }); |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 17 | |
| Philip Zeyliger | 25f6ff1 | 2025-05-02 04:24:10 +0000 | [diff] [blame] | 18 | // Test that tooltip shows error message when provided |
| 19 | test("includes error in tooltip when provided", async ({ mount }) => { |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 20 | const errorMsg = "Connection error"; |
| 21 | const component = await mount(SketchNetworkStatus, { |
| 22 | props: { |
| 23 | connection: "disconnected", |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 24 | error: errorMsg, |
| 25 | }, |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 26 | }); |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 27 | |
| Philip Zeyliger | 25f6ff1 | 2025-05-02 04:24:10 +0000 | [diff] [blame] | 28 | await expect(component.locator(".status-indicator")).toBeVisible(); |
| 29 | await expect(component.locator(".status-indicator")).toHaveAttribute( |
| 30 | "title", |
| 31 | "Connection status: disconnected - Connection error", |
| 32 | ); |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 33 | }); |