Files
pleno-vue/tests/e2e/edge-gateways.routes.spec.js
T

97 lines
4.6 KiB
JavaScript

import { expect, test } from "@playwright/test";
import { mockApi, primeMockSession } 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");
});
});