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

216 lines
11 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.describe.configure({ timeout: 120_000 });
test.beforeEach(async ({ page }) => {
await mockApi(page, {
authenticated: true,
permissions: ["superuser", "user"],
});
await primeSuperuserSession(page);
});
test("redirects legacy configuration detail routes onto the Edge Agents overview", async ({ page }) => {
await page.goto("/superuser/configuration/edgegateway/701", { waitUntil: "domcontentloaded" });
await expect(page).toHaveURL(/\/superuser\/selfserve\/edge-agents\/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 Edge Agents route", async ({ page }) => {
await page.goto("/superuser/gateways/701/configure", { waitUntil: "domcontentloaded" });
await expect(page).toHaveURL(/\/superuser\/selfserve\/edge-agents\/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\/selfserve\/edge-agents\/701\/tasks$/);
await expect(page.getByTestId("gateway-tasks-page")).toBeVisible();
await page.goto("/superuser/gateways/701/manage");
await expect(page).toHaveURL(/\/superuser\/selfserve\/edge-agents\/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/selfserve/edge-agents/999999/overview");
await expect(page).toHaveURL(/\/superuser\/selfserve\/edge-agents\/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/selfserve/edge-agents");
await expect(page.getByLabel("Self-serve pages").getByRole("link", { name: "Edge Agents" })).toHaveClass(
/selfserve-tabs__link--active/
);
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("saves broker module configuration values", async ({ page }) => {
await page.goto("/superuser/configuration/edgegateway", { waitUntil: "domcontentloaded" });
await expect(page.getByTestId("gateway-module-broker-url")).toHaveValue("http://edge-broker:4300");
await page.getByTestId("gateway-module-broker-url").fill("http://edge-broker:4301");
await page.getByTestId("gateway-module-public-broker-url").fill("https://api.truckwash.io:4433/edge-broker");
await page.getByTestId("gateway-module-broker-auth-mode").selectOption("manager");
await page.getByTestId("gateway-module-broker-shared-secret").fill("updated-broker-secret");
const saveRequest = page.waitForRequest(
(request) => request.method() === "POST" && request.url().includes("/edgegateway/config")
);
await page.getByTestId("gateway-module-save").click();
await saveRequest;
await expect(page.getByTestId("gateway-module-broker-url")).toHaveValue("http://edge-broker:4301");
await expect(page.getByTestId("gateway-module-broker-shared-secret")).toHaveValue("");
});
test("tests broker module configuration values", async ({ page }) => {
await page.goto("/superuser/configuration/edgegateway", { waitUntil: "domcontentloaded" });
await page.getByTestId("gateway-module-test-internal-broker").click();
await expect(page.getByTestId("gateway-module-broker-diagnostic-internal")).toContainText(
"Internal broker responded"
);
await expect(page.getByTestId("gateway-module-broker-diagnostic-internal")).toHaveAttribute(
"data-state",
"success"
);
await page.getByTestId("gateway-module-test-public-broker").click();
await expect(page.getByTestId("gateway-module-broker-diagnostic-public")).toContainText("Public broker responded");
await expect(page.getByTestId("gateway-module-broker-diagnostic-public")).toHaveAttribute("data-state", "success");
await page.getByTestId("gateway-module-test-broker-secret").click();
await expect(page.getByTestId("gateway-module-broker-diagnostic-secret")).toContainText(
"Broker accepted the configured shared secret"
);
await expect(page.getByTestId("gateway-module-broker-diagnostic-secret")).toHaveAttribute("data-state", "success");
await page.getByTestId("gateway-module-broker-shared-secret").fill("wrong-secret");
await page.getByTestId("gateway-module-test-broker-secret").click();
await expect(page.getByTestId("gateway-module-broker-diagnostic-secret")).toContainText(
"Broker rejected the configured shared secret"
);
await expect(page.getByTestId("gateway-module-broker-diagnostic-secret")).toHaveAttribute("data-state", "danger");
});
test("opens a department workspace from the fleet landing", async ({ page }) => {
await page.goto("/superuser/selfserve/edge-agents");
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.locator("h1").first()).toBeVisible();
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-tab-overview").click();
await page.getByTestId("gateway-open-full-page").click();
await expect(page).toHaveURL(/\/superuser\/selfserve\/edge-agents\/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/selfserve/edge-agents");
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();
});