blob: bf0f4ba304bb07e798025b45ca6b51e674fd23ed [file] [log] [blame]
Sean McCulloughb29f8912025-04-20 15:39:11 -07001import { test, expect } from "@sand4rt/experimental-ct-web";
2import { SketchNetworkStatus } from "./sketch-network-status";
Sean McCullough86b56862025-04-18 13:04:03 -07003
Philip Zeyliger25f6ff12025-05-02 04:24:10 +00004// Test for the status indicator dot
5test("shows status indicator dot when connected", async ({ mount }) => {
Sean McCulloughb29f8912025-04-20 15:39:11 -07006 const component = await mount(SketchNetworkStatus, {
7 props: {
8 connection: "connected",
Sean McCulloughb29f8912025-04-20 15:39:11 -07009 },
Sean McCullough86b56862025-04-18 13:04:03 -070010 });
11
Philip Zeyliger25f6ff12025-05-02 04:24:10 +000012 // 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 McCulloughb29f8912025-04-20 15:39:11 -070016});
Sean McCullough86b56862025-04-18 13:04:03 -070017
Philip Zeyliger25f6ff12025-05-02 04:24:10 +000018// Test that tooltip shows error message when provided
19test("includes error in tooltip when provided", async ({ mount }) => {
Sean McCulloughb29f8912025-04-20 15:39:11 -070020 const errorMsg = "Connection error";
21 const component = await mount(SketchNetworkStatus, {
22 props: {
23 connection: "disconnected",
Sean McCulloughb29f8912025-04-20 15:39:11 -070024 error: errorMsg,
25 },
Sean McCullough86b56862025-04-18 13:04:03 -070026 });
Sean McCulloughb29f8912025-04-20 15:39:11 -070027
Philip Zeyliger25f6ff12025-05-02 04:24:10 +000028 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 McCullough86b56862025-04-18 13:04:03 -070033});