blob: 5c968d43ae7c8e85d0f8d96e00bd7315baf3e991 [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 Zeyligerbce3a132025-04-30 22:03:39 +00004// Test for when no error message is present - component should not render
5test("does not display anything when no error is provided", async ({
Sean McCulloughb29f8912025-04-20 15:39:11 -07006 mount,
7}) => {
8 const component = await mount(SketchNetworkStatus, {
9 props: {
10 connection: "connected",
Sean McCulloughb29f8912025-04-20 15:39:11 -070011 },
Sean McCullough86b56862025-04-18 13:04:03 -070012 });
13
Philip Zeyligerbce3a132025-04-30 22:03:39 +000014 // The component should be empty
15 await expect(component.locator(".status-container")).not.toBeVisible();
Sean McCulloughb29f8912025-04-20 15:39:11 -070016});
Sean McCullough86b56862025-04-18 13:04:03 -070017
Philip Zeyligerbce3a132025-04-30 22:03:39 +000018// Test that error message is displayed correctly
Sean McCulloughb29f8912025-04-20 15:39:11 -070019test("displays error message when provided", async ({ mount }) => {
20 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
28 await expect(component.locator(".status-text")).toBeVisible();
29 await expect(component.locator(".status-text")).toContainText(errorMsg);
Sean McCullough86b56862025-04-18 13:04:03 -070030});