| 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 | bce3a13 | 2025-04-30 22:03:39 +0000 | [diff] [blame] | 4 | // Test for when no error message is present - component should not render |
| 5 | test("does not display anything when no error is provided", async ({ |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 6 | mount, |
| 7 | }) => { |
| 8 | const component = await mount(SketchNetworkStatus, { |
| 9 | props: { |
| 10 | connection: "connected", |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 11 | }, |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 12 | }); |
| 13 | |
| Philip Zeyliger | bce3a13 | 2025-04-30 22:03:39 +0000 | [diff] [blame] | 14 | // The component should be empty |
| 15 | await expect(component.locator(".status-container")).not.toBeVisible(); |
| 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 | bce3a13 | 2025-04-30 22:03:39 +0000 | [diff] [blame] | 18 | // Test that error message is displayed correctly |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 19 | test("displays error message when provided", async ({ mount }) => { |
| 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 | |
| 28 | await expect(component.locator(".status-text")).toBeVisible(); |
| 29 | await expect(component.locator(".status-text")).toContainText(errorMsg); |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 30 | }); |