Files
pleno-vue/tests/e2e/edge-gateways.smoke.spec.js
T
Jeppe Bundgaard 1bd1b992a2 Add assign draft order customer modal and related e2e tests:
- Introduced `AssignDraftOrderCustomerModal` component with supporting localization for managing customer assignments.
- Added e2e harness for modal testing in `assign-draft-order-customer-modal.html` and `assign-draft-order-customer-modal.ts`.
- Implemented e2e test cases for customer assignment workflows in `assign-draft-order-modal-create.spec.ts` and `assign-draft-order-modal-layout.spec.ts`.
2026-04-21 13:16:22 +02:00

183 lines
7.5 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-token" });
}
test.describe("Edge gateway management smoke", () => {
test.describe.configure({ mode: "serial" });
test("@smoke shows technical request details for backend errors", async ({ page }) => {
await mockApi(page, {
authenticated: true,
permissions: ["superuser", "user"],
});
await page.route(/\/edge-gateways(?:\?.*)?$/i, async (route, request) => {
if (request.method() !== "GET") {
await route.fallback();
return;
}
await route.fulfill({
status: 500,
contentType: "application/json",
body: JSON.stringify({
success: false,
data: {
message: "Internal server error: SQLSTATE[42S22]: Column not found",
error_code: "EDGE_GATEWAY_VALIDATION_FAILED",
},
}),
});
});
await primeSuperuserSession(page);
await page.goto("/superuser/gateways");
await expect(page.getByTestId("gateway-error-banner")).toContainText("Column not found");
await page.getByTestId("gateway-error-details").click();
await expect(page.getByTestId("gateway-error-details")).toContainText("Request:");
await expect(page.getByTestId("gateway-error-details")).toContainText("Status: HTTP 500");
});
test("@smoke exposes a copy action for generated installer commands", async ({ page }) => {
await page.addInitScript(() => {
Object.defineProperty(navigator, "clipboard", {
configurable: true,
value: {
writeText: async (text) => {
window.__copiedInstallerCommand = text;
},
},
});
window.__copiedInstallerCommand = "";
});
await mockApi(page, {
authenticated: true,
permissions: ["superuser", "user"],
edgeGateways: {
empty: true,
claimPollsRemaining: 99,
},
});
await primeSuperuserSession(page);
await page.goto("/superuser/gateways");
await page.getByTestId("gateway-installer-department").selectOption("1");
await page.getByTestId("gateway-installer-label").fill("Copy Test Pi");
await page.getByTestId("gateway-installer-generate").click();
await expect(page.getByTestId("gateway-install-command")).toHaveValue(/install\.sh\?token=edge-install-token/);
await page.getByTestId("gateway-installer-copy").click();
await expect(page.locator("body")).toContainText("Installer command copied.");
await expect(page.getByTestId("gateway-installer-copy")).toContainText("Copied");
await expect.poll(() => page.evaluate(() => window.__copiedInstallerCommand)).toContain(
"install.sh?token=edge-install-token"
);
});
test("@smoke shows fleet usage statistics on the landing page", async ({ page }) => {
await mockApi(page, {
authenticated: true,
permissions: ["superuser", "user"],
});
await primeSuperuserSession(page);
await page.goto("/superuser/gateways");
await expect(page.getByTestId("gateway-fleet-usage")).toBeVisible();
await expect(page.getByTestId("gateway-fleet-usage-coverage")).toContainText("2 gateways · 1 online");
await expect(page.getByTestId("gateway-fleet-usage-devices")).toContainText("1 online · 1 offline");
await expect(page.getByTestId("gateway-fleet-usage-bindings")).toContainText("1 overrides · 1 cloud only");
await expect(page.getByTestId("gateway-fleet-usage-runtime")).toContainText("298 ms");
});
test("@smoke onboards the first gateway from the fleet landing page", async ({ page }) => {
await mockApi(page, {
authenticated: true,
permissions: ["superuser", "user"],
edgeGateways: {
empty: true,
claimPollsRemaining: 1,
},
});
await primeSuperuserSession(page);
await page.goto("/superuser/gateways");
await expect(page.getByTestId("gateway-fleet-landing")).toBeVisible();
await expect(page.getByTestId("gateway-empty-state")).toContainText("No gateways");
await page.getByTestId("gateway-installer-department").selectOption("1");
await page.getByTestId("gateway-installer-label").fill("Canary Pi");
await page.getByTestId("gateway-installer-generate").click();
await expect(page).toHaveURL(/\/superuser\/gateways\/703\/overview$/, { timeout: 8_000 });
await expect(page.getByTestId("gateway-detail-header")).toContainText("Canary Pi");
});
test("@smoke updates metadata and rotates credentials from the manage view", async ({ page }) => {
await mockApi(page, {
authenticated: true,
permissions: ["superuser", "user"],
});
await primeSuperuserSession(page);
await page.goto("/superuser/gateways/701/overview");
await expect(page.getByTestId("gateway-detail-header")).toContainText("CPH Edge 01");
await page.getByTestId("gateway-tab-manage").click();
await page.getByTestId("gateway-metadata-label").fill("CPH Edge Prime");
await page.getByTestId("gateway-metadata-save").click();
await expect(page.locator("body")).toContainText("Gateway metadata updated.");
await expect(page.getByTestId("gateway-detail-header")).toContainText("CPH Edge Prime");
await page.getByTestId("gateway-rotate-confirmation").fill("ROTATE");
await page.getByTestId("gateway-rotate-credentials").click();
await expect(page.getByTestId("gateway-credential-bundle")).toContainText("rotated-edge-agent-token");
await expect(page.locator("body")).toContainText("Gateway credentials rotated.");
});
test("@smoke manages discovery, bindings, operations, uninstall, and delete", async ({ page }) => {
await mockApi(page, {
authenticated: true,
permissions: ["superuser", "user"],
});
await primeSuperuserSession(page);
await page.goto("/superuser/gateways/701/inventory");
await page.getByTestId("gateway-discovery-trigger").click();
await expect(page.locator("body")).toContainText("Gateway operation DISCOVERY queued.");
await page.getByTestId("gateway-binding-add").click();
await page.locator('[data-testid^="gateway-binding-relay-"]').last().fill("M-8");
await page.locator('[data-testid^="gateway-binding-device-"]').last().selectOption("shelly-plus-01");
await page.locator('[data-testid^="gateway-binding-channel-"]').last().selectOption("0");
await page.locator('[data-testid^="gateway-binding-fallback-"]').last().selectOption("CLOUD_ONLY");
await page.getByTestId("gateway-bindings-save").click();
await expect(page.locator("body")).toContainText("Relay bindings saved.");
await page.getByTestId("gateway-tab-operations").click();
await page.getByTestId("gateway-update-target-version").fill("php-agent-v2.0");
await page.getByTestId("gateway-operation-update").click();
await expect(page.getByTestId("gateway-operations-list")).toContainText("UPDATE");
await expect(page.getByTestId("gateway-operation-events")).toContainText("Operation completed successfully");
await page.getByTestId("gateway-operation-uninstall").click();
await expect(page.getByTestId("gateway-operations-list")).toContainText("UNINSTALL");
await page.getByTestId("gateway-tab-manage").click();
await page.getByTestId("gateway-delete-confirmation").fill("CPH Edge 01");
await page.getByTestId("gateway-delete").click();
await expect(page).toHaveURL(/\/superuser\/gateways$/, { timeout: 8_000 });
await expect(page.locator("body")).toContainText("Gateway deleted.");
});
});