| 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 | |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 4 | test("displays the correct connection status when connected", async ({ |
| 5 | mount, |
| 6 | }) => { |
| 7 | const component = await mount(SketchNetworkStatus, { |
| 8 | props: { |
| 9 | connection: "connected", |
| 10 | message: "Connected to server", |
| 11 | }, |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 12 | }); |
| 13 | |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 14 | await expect(component.locator(".polling-indicator")).toBeVisible(); |
| 15 | await expect(component.locator(".status-text")).toBeVisible(); |
| 16 | await expect(component.locator(".polling-indicator.active")).toBeVisible(); |
| 17 | await expect(component.locator(".status-text")).toContainText( |
| 18 | "Connected to server", |
| 19 | ); |
| 20 | }); |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 21 | |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 22 | test("displays the correct connection status when disconnected", async ({ |
| 23 | mount, |
| 24 | }) => { |
| 25 | const component = await mount(SketchNetworkStatus, { |
| 26 | props: { |
| 27 | connection: "disconnected", |
| 28 | message: "Disconnected", |
| 29 | }, |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 30 | }); |
| 31 | |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 32 | await expect(component.locator(".polling-indicator")).toBeVisible(); |
| 33 | await expect(component.locator(".polling-indicator.error")).toBeVisible(); |
| 34 | }); |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 35 | |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 36 | test("displays the correct connection status when disabled", async ({ |
| 37 | mount, |
| 38 | }) => { |
| 39 | const component = await mount(SketchNetworkStatus, { |
| 40 | props: { |
| 41 | connection: "disabled", |
| 42 | message: "Disabled", |
| 43 | }, |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 44 | }); |
| 45 | |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 46 | await expect(component.locator(".polling-indicator")).toBeVisible(); |
| 47 | await expect(component.locator(".polling-indicator.error")).not.toBeVisible(); |
| 48 | await expect( |
| 49 | component.locator(".polling-indicator.active"), |
| 50 | ).not.toBeVisible(); |
| 51 | }); |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 52 | |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 53 | test("displays error message when provided", async ({ mount }) => { |
| 54 | const errorMsg = "Connection error"; |
| 55 | const component = await mount(SketchNetworkStatus, { |
| 56 | props: { |
| 57 | connection: "disconnected", |
| 58 | message: "Disconnected", |
| 59 | error: errorMsg, |
| 60 | }, |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 61 | }); |
| Sean McCullough | b29f891 | 2025-04-20 15:39:11 -0700 | [diff] [blame] | 62 | |
| 63 | await expect(component.locator(".status-text")).toBeVisible(); |
| 64 | await expect(component.locator(".status-text")).toContainText(errorMsg); |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 65 | }); |