Files
unknownandCursor c7a23837f4 feat(web): 对齐和信后台页壳并落地工业 UI 评审与 Skills 盘点
统一控制台列表/表单页壳与 Hexin 样式,补充 industrial-ui-review、管理员评审证据,以及 Skills 资产盘点与 test-strategy 消歧。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 17:44:26 +08:00

173 lines
6.4 KiB
TypeScript

/**
* UI smoke: shell chrome, list/form skeleton, design tokens, soft visual baselines.
* Follows playwright-automation (user-facing locators + auto-wait) and visual-testing
* (toHaveScreenshot with animations disabled). Login page is out of scope.
*/
import { expect, test } from "@playwright/test";
import {
cssVar,
expectFormPageLayout,
expectListPageLayout,
expectShellChrome,
mockAlarmList,
mockDatasourceList,
mockHealth,
mockMappingList,
mockQueryList,
signedInAdmin,
} from "./helpers/ui";
const DESKTOP = { width: 1440, height: 900 };
const shotOpts = {
animations: "disabled" as const,
caret: "hide" as const,
maxDiffPixelRatio: 0.02,
};
test.describe("UI smoke — tokens and shell", () => {
test.beforeEach(async ({ page }) => {
await page.setViewportSize(DESKTOP);
await signedInAdmin(page);
await mockHealth(page);
});
test("design tokens expose hexin primary and surface radius", async ({ page }) => {
await page.goto("/");
await expect(page.getByTestId("home-page")).toBeVisible();
const primary = await cssVar(page, "--color-primary");
const elPrimary = await cssVar(page, "--el-color-primary");
const radius = await cssVar(page, "--radius-surface");
const pageBg = await cssVar(page, "--bg-page");
expect(primary.toLowerCase()).toBe("#0284c7");
expect(elPrimary.toLowerCase()).toBe("#0284c7");
expect(radius).toBe("16px");
expect(pageBg.toLowerCase()).toBe("#f8fafc");
// Guard against drifting back to company-doc purple baseline.
expect(primary.toLowerCase()).not.toBe("#5e6ad2");
});
test("shell shows brand nav, breadcrumb, and padded content stage", async ({ page }) => {
await page.goto("/");
await expectShellChrome(page);
await expect(page.getByTestId("nav-home")).toBeVisible();
await expect(page.getByTestId("nav-datasources")).toBeVisible();
await expect(page.getByTestId("nav-queries")).toBeVisible();
await expect(page.getByTestId("nav-mappings")).toBeVisible();
await expect(page.getByTestId("nav-alarms")).toBeVisible();
await expect(page.getByTestId("health-success")).toBeVisible();
await expect(page).toHaveScreenshot("shell-home.png", shotOpts);
});
});
test.describe("UI smoke — list page layout", () => {
test.beforeEach(async ({ page }) => {
await page.setViewportSize(DESKTOP);
await signedInAdmin(page);
});
test("datasource list uses single card, 32px gutters, and status tags", async ({ page }) => {
await mockDatasourceList(page);
await page.goto("/#/datasources");
await expectShellChrome(page);
await expectListPageLayout(page, "datasource-list");
await expect(page.getByTestId("datasource-list-toolbar")).toBeVisible();
await expect(page.getByRole("button", { name: "新建" })).toBeVisible();
await expect(page.getByTestId("datasource-table")).toBeVisible();
await expect(page.getByTestId("datasource-pagination")).toBeVisible();
await expect(page.locator(".el-tag").first()).toBeVisible();
await expect(page.getByTestId("datasource-list")).toHaveScreenshot("list-datasources-card.png", shotOpts);
});
test("query list uses the same list skeleton", async ({ page }) => {
await mockQueryList(page);
await page.goto("/#/queries");
await expectListPageLayout(page, "query-list");
await expect(page.getByTestId("query-table")).toBeVisible();
await expect(page.getByTestId("query-pagination")).toBeVisible();
await expect(page.getByTestId("row-status")).toBeVisible();
});
test("mapping list uses the same list skeleton", async ({ page }) => {
await mockMappingList(page);
await page.goto("/#/mappings");
await expectListPageLayout(page, "mapping-list");
await expect(page.getByTestId("mapping-table")).toBeVisible();
await expect(page.getByRole("button", { name: "新建" })).toBeVisible();
});
test("alarm list uses the same list skeleton", async ({ page }) => {
await mockAlarmList(page);
await page.goto("/#/alarms");
await expectListPageLayout(page, "alarm-list");
await expect(page.getByTestId("alarm-table")).toBeVisible();
await expect(page.getByTestId("alarm-pagination")).toBeVisible();
await expect(page.getByTestId("alarm-status")).toBeVisible();
await expect(page.getByTestId("alarm-list")).toHaveScreenshot("list-alarms-card.png", shotOpts);
});
});
test.describe("UI smoke — form page layout", () => {
test.beforeEach(async ({ page }) => {
await page.setViewportSize(DESKTOP);
await signedInAdmin(page);
});
test("datasource create form keeps footer outside the scroll body", async ({ page }) => {
await page.goto("/#/datasources/new");
await expectFormPageLayout(page, {
pageTestId: "datasource-edit",
footerTestId: "datasource-footer",
bodyTestId: "datasource-scroll",
});
await expect(page.getByTestId("footer-back")).toBeVisible();
await expect(page.getByRole("button", { name: "测试连接" })).toBeVisible();
await expect(page.getByTestId("datasource-edit")).toHaveScreenshot("form-datasource-create.png", shotOpts);
});
test("query create form uses form shell and centered footer", async ({ page }) => {
await mockQueryList(page);
await page.goto("/#/queries/new");
await expectFormPageLayout(page, {
pageTestId: "query-edit",
footerTestId: "query-footer",
bodyTestId: "query-scroll",
});
await expect(page.getByTestId("footer-back")).toBeVisible();
});
});
test.describe("UI smoke — navigation routes", () => {
test("admin can open every primary module without a blank main", async ({ page }) => {
await page.setViewportSize(DESKTOP);
await signedInAdmin(page);
await mockHealth(page);
await mockDatasourceList(page);
await mockQueryList(page);
await mockMappingList(page);
await mockAlarmList(page);
const stops: { path: string; marker: string }[] = [
{ path: "/", marker: "home-page" },
{ path: "/#/datasources", marker: "datasource-list" },
{ path: "/#/queries", marker: "query-list" },
{ path: "/#/mappings", marker: "mapping-list" },
{ path: "/#/alarms", marker: "alarm-list" },
];
for (const stop of stops) {
await page.goto(stop.path);
await expect(page.getByTestId(stop.marker)).toBeVisible();
await expect(page.getByTestId("side-nav")).toBeVisible();
await expect(page.getByTestId("breadcrumb")).toBeVisible();
}
});
});