blob: 45882a0c36fbcee3219df04578d58f146e9b6f2d [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
Sean McCulloughb29f8912025-04-20 15:39:11 -07004test("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 McCullough86b56862025-04-18 13:04:03 -070012 });
13
Sean McCulloughb29f8912025-04-20 15:39:11 -070014 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 McCullough86b56862025-04-18 13:04:03 -070021
Sean McCulloughb29f8912025-04-20 15:39:11 -070022test("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 McCullough86b56862025-04-18 13:04:03 -070030 });
31
Sean McCulloughb29f8912025-04-20 15:39:11 -070032 await expect(component.locator(".polling-indicator")).toBeVisible();
33 await expect(component.locator(".polling-indicator.error")).toBeVisible();
34});
Sean McCullough86b56862025-04-18 13:04:03 -070035
Sean McCulloughb29f8912025-04-20 15:39:11 -070036test("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 McCullough86b56862025-04-18 13:04:03 -070044 });
45
Sean McCulloughb29f8912025-04-20 15:39:11 -070046 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 McCullough86b56862025-04-18 13:04:03 -070052
Sean McCulloughb29f8912025-04-20 15:39:11 -070053test("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 McCullough86b56862025-04-18 13:04:03 -070061 });
Sean McCulloughb29f8912025-04-20 15:39:11 -070062
63 await expect(component.locator(".status-text")).toBeVisible();
64 await expect(component.locator(".status-text")).toContainText(errorMsg);
Sean McCullough86b56862025-04-18 13:04:03 -070065});