Files
pikasTech-HWLAB/web/hwlab-cloud-web/tests/workbench-e2e/specs/admin-hwpod-performance.spec.ts
T

39 lines
1.9 KiB
TypeScript

import { expect, test } from "../fixtures/test";
test("admin HWPOD groups renders node-ops as structured UI before raw JSON is requested", async ({ page }) => {
await page.goto("/admin/hwpod-groups");
await expect(page.getByRole("heading", { name: "HWPOD 分组" })).toBeVisible();
await expect(page.getByText("hwpod-node-ops-v1")).toBeVisible();
await expect(page.getByText("/v1/hwpod-node-ops")).toBeVisible();
await expect(page.getByText("node.health")).toBeVisible();
await expect(page.getByText("node-d601-f103-v2")).toBeVisible();
await expect(page.locator("[data-testid='hwpod-raw-json']")).toHaveCount(0);
await expect(page.locator("body")).not.toContainText('"contractVersion"');
await page.getByTestId("hwpod-raw-json-toggle").click();
await expect(page.getByTestId("hwpod-raw-json")).toContainText('"contractVersion"');
});
test("performance tables keep wide columns reachable inside local mobile scrollers", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await page.goto("/performance");
await expect(page.getByRole("heading", { name: "性能监控" })).toBeVisible();
await expect(page.getByText("Problem rows")).toBeVisible();
const scrollers = await page.locator(".performance-page .data-table-wrap").evaluateAll((items) => items.map((item) => ({
clientWidth: Math.round(item.clientWidth),
scrollWidth: Math.round(item.scrollWidth),
overflowX: getComputedStyle(item).overflowX
})));
expect(scrollers.length).toBeGreaterThanOrEqual(4);
expect(scrollers.every((item) => item.clientWidth <= 390)).toBeTruthy();
expect(scrollers.some((item) => item.scrollWidth > item.clientWidth + 120)).toBeTruthy();
expect(scrollers.every((item) => item.overflowX === "auto" || item.overflowX === "scroll")).toBeTruthy();
const documentScrollWidth = await page.evaluate(() => Math.round(document.documentElement.scrollWidth));
expect(documentScrollWidth).toBeLessThanOrEqual(390);
});