Add e2e tests for admin module functionalities:
- Introduced tests for admin daily report features, including tile rendering, complaint management, and stale response handling. - Added department visibility tests to ensure hidden departments are excluded from UI controls. - Implemented night wash overview tests for breakdown validation, missing hours detection, and stable range updates.
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { mockApi, seedAuthenticatedState } from "./support/network.js";
|
||||
|
||||
async function primeSuperuserSession(page) {
|
||||
const token = "superuser-edge-gateway-token";
|
||||
await seedAuthenticatedState(page, token);
|
||||
await page.goto("/login");
|
||||
await page.evaluate(async (sessionToken) => {
|
||||
const sessionModule = await import("/src/components/session/token/SessionUser.vue");
|
||||
window.localStorage.setItem("token", sessionToken);
|
||||
sessionModule.SessionUser.token.value = sessionToken;
|
||||
sessionModule.SessionUser.authenticated.value = true;
|
||||
sessionModule.SessionUser.permissions.value = ["superuser", "user"];
|
||||
sessionModule.SessionUser.initiated.value = true;
|
||||
}, token);
|
||||
}
|
||||
|
||||
test.describe("Edge gateway management smoke", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await mockApi(page, {
|
||||
authenticated: true,
|
||||
permissions: ["superuser", "user"],
|
||||
});
|
||||
await primeSuperuserSession(page);
|
||||
});
|
||||
|
||||
test("@smoke manages installers, bindings, updates, and shell approval", async ({ page }) => {
|
||||
await page.goto("/superuser/gateways");
|
||||
|
||||
await expect(page).toHaveURL(/\/superuser\/gateways$/);
|
||||
await expect(page.locator("body")).toContainText("Edge gateways");
|
||||
await expect(page.locator("body")).toContainText("Valgt gateway");
|
||||
await expect(page.locator("body")).toContainText("CPH Edge 01");
|
||||
await expect(page.locator("body")).toContainText("Shelly Plus 2PM");
|
||||
|
||||
await page.getByLabel("Installer afdeling").selectOption("1");
|
||||
await page.locator('input[placeholder="F.eks. Roskilde Pi 01"]').fill("Canary Pi");
|
||||
await page.getByRole("button", { name: "Generér installer" }).click();
|
||||
await expect(page.getByLabel("Installationskommando")).toHaveValue(/curl -fsSL/);
|
||||
|
||||
await page.getByRole("button", { name: "Kør discovery" }).click();
|
||||
await expect(page.locator("body")).toContainText("shelly-plus-new");
|
||||
|
||||
const relayBindingInput = page.locator(".edge-table--editor tbody tr").nth(0).locator('input[type="text"]').first();
|
||||
await relayBindingInput.fill("M-7-CANARY");
|
||||
await page.getByRole("button", { name: "Gem bindinger" }).click();
|
||||
await expect(relayBindingInput).toHaveValue("M-7-CANARY");
|
||||
|
||||
await page.locator('input[placeholder="F.eks. 1.3.0"]').fill("1.3.0");
|
||||
await page.getByRole("button", { name: "Planlæg opdatering" }).click();
|
||||
await expect(page.locator("body")).toContainText("1.3.0");
|
||||
|
||||
await page.getByRole("button", { name: "Åbn root shell-panel" }).click();
|
||||
await page.locator('input[placeholder="Beskriv hvorfor root shell er nødvendig"]').fill("Investigate offline relay");
|
||||
await page.getByRole("button", { name: "Godkend root shell" }).click();
|
||||
await expect(page.getByLabel("Root shell-transcript")).toHaveValue(/\[Godkendt til/);
|
||||
});
|
||||
|
||||
test("@smoke applies department cutover mode from department page", async ({ page }) => {
|
||||
await page.goto("/superuser/departments/1/gateways");
|
||||
|
||||
await expect(page).toHaveURL(/\/superuser\/departments\/1\/gateways$/);
|
||||
await expect(page.locator("body")).toContainText("Gateway for afdelingen");
|
||||
await page.getByLabel("Transporttilstand").selectOption("cloud");
|
||||
await page.getByRole("button", { name: "Anvend cutover" }).click();
|
||||
await expect(page.getByLabel("Transporttilstand")).toHaveValue("cloud");
|
||||
await expect(page.locator("body")).toContainText("Cloud fallback");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user