160 lines
7.6 KiB
JavaScript
160 lines
7.6 KiB
JavaScript
import { expect, test } from "@playwright/test";
|
|
import { mockApi, primeMockSession, seedAuthenticatedState } from "./support/network.js";
|
|
|
|
async function primeSuperuserSession(page) {
|
|
await primeMockSession(page, { token: "superuser-edge-gateway-routes-token" });
|
|
}
|
|
|
|
test.describe("Edge gateway routing and fleet navigation", () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await mockApi(page, {
|
|
authenticated: true,
|
|
permissions: ["superuser", "user"],
|
|
});
|
|
await primeSuperuserSession(page);
|
|
});
|
|
|
|
test("redirects canonical detail routes onto overview", async ({ page }) => {
|
|
await page.goto("/superuser/configuration/edgegateway/701");
|
|
|
|
await expect(page).toHaveURL(/\/superuser\/configuration\/edgegateway\/701\/overview$/);
|
|
await expect(page.getByTestId("gateway-detail-header")).toContainText("CPH Edge 01");
|
|
await expect(page.getByTestId("gateway-tab-nav")).toBeVisible();
|
|
});
|
|
|
|
test("redirects legacy sub-page URLs onto the mapped module route", async ({ page }) => {
|
|
await page.goto("/superuser/gateways/701/configure");
|
|
|
|
await expect(page).toHaveURL(/\/superuser\/configuration\/edgegateway\/701\/inventory$/);
|
|
await expect(page.getByTestId("gateway-inventory-page")).toBeVisible();
|
|
});
|
|
|
|
test("redirects legacy operations and manage routes onto tasks and settings", async ({ page }) => {
|
|
await page.goto("/superuser/configuration/edgegateway/701/operations");
|
|
await expect(page).toHaveURL(/\/superuser\/configuration\/edgegateway\/701\/tasks$/);
|
|
await expect(page.getByTestId("gateway-tasks-page")).toBeVisible();
|
|
|
|
await page.goto("/superuser/gateways/701/manage");
|
|
await expect(page).toHaveURL(/\/superuser\/configuration\/edgegateway\/701\/settings$/);
|
|
await expect(page.getByTestId("gateway-settings-page")).toBeVisible();
|
|
});
|
|
|
|
test("shows the unavailable state for unknown detail routes", async ({ page }) => {
|
|
await page.goto("/superuser/configuration/edgegateway/999999/overview");
|
|
|
|
await expect(page).toHaveURL(/\/superuser\/configuration\/edgegateway\/999999\/overview$/);
|
|
await expect(page.getByTestId("gateway-unavailable-state")).toContainText("999999");
|
|
});
|
|
|
|
test("filters the fleet roster with search and summary chips", async ({ page }) => {
|
|
await page.goto("/superuser/configuration/edgegateway");
|
|
|
|
await expect(page.getByTestId("hardware-fleet-landing")).toBeVisible();
|
|
await page.getByTestId("gateway-fleet-search").fill("ode");
|
|
await expect(page.getByTestId("gateway-fleet-item-702")).toBeVisible();
|
|
await expect(page.getByTestId("gateway-fleet-item-701")).toHaveCount(0);
|
|
|
|
await page.getByTestId("gateway-fleet-search").fill("");
|
|
await page.getByTestId("gateway-summary-offline").click();
|
|
await expect(page.getByTestId("gateway-fleet-item-702")).toBeVisible();
|
|
await expect(page.getByTestId("gateway-fleet-item-701")).toHaveCount(0);
|
|
});
|
|
|
|
test("opens a department workspace from the fleet landing", async ({ page }) => {
|
|
await page.goto("/superuser/configuration/edgegateway");
|
|
|
|
await expect(page.getByTestId("hardware-fleet-landing")).toBeVisible();
|
|
await expect(page.getByTestId("hardware-fleet-department-1")).toContainText("Copenhagen");
|
|
|
|
await page.getByTestId("hardware-fleet-open-workspace-1").click();
|
|
|
|
await expect(page).toHaveURL(/\/superuser\/departments\/1\/gateways(?:\?.*)?$/);
|
|
await expect(page.getByTestId("department-hardware-workspace")).toBeVisible();
|
|
await expect(page.getByTestId("department-hardware-primary-gateway")).toContainText("CPH Edge 01");
|
|
});
|
|
|
|
test("keeps the department workspace on the safe subset and links into the full page", async ({ page }) => {
|
|
await page.goto("/superuser/departments/1/gateways");
|
|
|
|
await expect(page.getByTestId("department-hardware-workspace")).toBeVisible();
|
|
await expect(page.getByTestId("department-hardware-panel-overview")).toBeVisible();
|
|
await expect(page.getByTestId("department-hardware-tab-gateways")).toBeVisible();
|
|
|
|
await page.getByTestId("department-hardware-tab-gateways").click();
|
|
|
|
await expect(page.getByTestId("edge-gateway-workspace")).toBeVisible();
|
|
await expect(page.getByTestId("gateway-tab-terminal")).toHaveCount(0);
|
|
await expect(page.getByTestId("gateway-tab-settings")).toHaveCount(0);
|
|
await page.getByTestId("gateway-tab-tasks").click();
|
|
await expect(page.getByTestId("gateway-operation-uninstall")).toHaveCount(0);
|
|
|
|
await page.getByTestId("gateway-open-full-page").click();
|
|
|
|
await expect(page).toHaveURL(/\/superuser\/configuration\/edgegateway\/701\/overview$/);
|
|
await expect(page.getByTestId("gateway-detail-header")).toContainText("CPH Edge 01");
|
|
});
|
|
});
|
|
|
|
test("shows colored issues with suggest-fix actions in the department workspace", async ({ page }) => {
|
|
await mockApi(page, {
|
|
authenticated: true,
|
|
permissions: ["superuser", "user"],
|
|
});
|
|
await seedAuthenticatedState(page, "superuser-edge-gateway-routes-token");
|
|
|
|
await page.goto("/superuser/configuration/edgegateway");
|
|
await page.getByTestId("hardware-fleet-open-workspace-1").click();
|
|
await expect(page.getByTestId("department-hardware-workspace")).toBeVisible();
|
|
|
|
const laneIssue = page.getByTestId("department-hardware-issue-LANE_BINDING_GAP-8");
|
|
const laneIssueSeverity = page.getByTestId("department-hardware-issue-severity-LANE_BINDING_GAP-8");
|
|
const laneIssueFix = page.getByTestId("department-hardware-issue-fix-LANE_BINDING_GAP-REVIEW_LANE_BINDINGS");
|
|
|
|
await expect(laneIssue).toBeVisible();
|
|
await expect(laneIssue).toHaveAttribute("data-severity", "warning");
|
|
await expect(laneIssueSeverity).toHaveText("Warning");
|
|
await expect(laneIssueSeverity).toHaveCSS("background-color", "rgb(254, 243, 199)");
|
|
await expect(laneIssueFix).toContainText("Suggest fix: Resolve lane bindings");
|
|
|
|
await laneIssueFix.click();
|
|
|
|
await expect(page).toHaveURL(/\/superuser\/departments\/1\/gateways\?tab=lanes$/);
|
|
await expect(page.getByTestId("department-hardware-panel-lanes")).toBeVisible();
|
|
|
|
await page.getByTestId("department-hardware-tab-issues").click();
|
|
|
|
await expect(page.getByTestId("department-hardware-panel-issues")).toBeVisible();
|
|
await expect(page.getByTestId("department-hardware-issue-SCANNER_UNASSIGNED-2")).toHaveAttribute(
|
|
"data-severity",
|
|
"warning"
|
|
);
|
|
await expect(page.getByTestId("department-hardware-issue-fix-SCANNER_UNASSIGNED-ASSIGN_SCANNERS")).toContainText(
|
|
"Suggest fix: Assign scanners to lanes"
|
|
);
|
|
});
|
|
|
|
test("keeps overview action shortcuts aligned to the workspace tabs", async ({ page }) => {
|
|
await mockApi(page, {
|
|
authenticated: true,
|
|
permissions: ["superuser", "user"],
|
|
});
|
|
await seedAuthenticatedState(page, "superuser-edge-gateway-routes-token");
|
|
|
|
await page.goto("/superuser/departments/1/gateways");
|
|
await expect(page.getByTestId("department-hardware-panel-overview")).toBeVisible();
|
|
|
|
await page.getByTestId("department-hardware-action-REVIEW_LANE_BINDINGS").click();
|
|
await expect(page).toHaveURL(/\/superuser\/departments\/1\/gateways\?tab=lanes$/);
|
|
await expect(page.getByTestId("department-hardware-panel-lanes")).toBeVisible();
|
|
|
|
await page.getByTestId("department-hardware-tab-overview").click();
|
|
await page.getByTestId("department-hardware-action-ASSIGN_SCANNERS").click();
|
|
await expect(page).toHaveURL(/\/superuser\/departments\/1\/gateways\?tab=scanners$/);
|
|
await expect(page.getByTestId("department-hardware-panel-scanners")).toBeVisible();
|
|
|
|
await page.getByTestId("department-hardware-tab-overview").click();
|
|
await page.getByTestId("department-hardware-action-OPEN_GATEWAY_TAB").click();
|
|
await expect(page).toHaveURL(/\/superuser\/departments\/1\/gateways\?tab=gateways$/);
|
|
await expect(page.getByTestId("department-hardware-panel-gateways")).toBeVisible();
|
|
});
|