feat(web): 对齐和信后台页壳并落地工业 UI 评审与 Skills 盘点
统一控制台列表/表单页壳与 Hexin 样式,补充 industrial-ui-review、管理员评审证据,以及 Skills 资产盘点与 test-strategy 消歧。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
48d1735c17
commit
c7a23837f4
74 files changed
+3839
-601
No files matched your search
@@ -0,0 +1,216 @@
|
||||
/**
|
||||
* Shared helpers for console UI smoke / layout tests.
|
||||
* Auth is mocked; APIs return synthetic envelopes. Login page is out of scope.
|
||||
*/
|
||||
import { expect, type Locator, type Page } from "@playwright/test";
|
||||
|
||||
export function ok(data: unknown, requestId = "ui-smoke"): string {
|
||||
return JSON.stringify({ success: true, data, request_id: requestId });
|
||||
}
|
||||
|
||||
/** Signed-in watchman-admin via /auth/me mock. */
|
||||
export async function signedInAdmin(page: Page): Promise<void> {
|
||||
await page.route("**/auth/me", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({
|
||||
subject: "admin-1",
|
||||
display_name: "Admin",
|
||||
roles: ["watchman-admin"],
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function mockHealth(page: Page): Promise<void> {
|
||||
await page.route("**/health", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({ status: "ok", app: "watchman", version: "0.1.0" }),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function mockDatasourceList(page: Page): Promise<void> {
|
||||
await page.route("**/datasources?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({
|
||||
items: [
|
||||
{
|
||||
id: "ds-1",
|
||||
name: "MES-PG",
|
||||
engine: "postgresql",
|
||||
host: "127.0.0.1",
|
||||
port: 5432,
|
||||
database_name: "mes",
|
||||
username: "ro",
|
||||
enabled: true,
|
||||
circuit_state: "closed",
|
||||
last_test_at: null,
|
||||
last_test_category: null,
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function mockQueryList(page: Page): Promise<void> {
|
||||
await page.route("**/datasources?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({ items: [], total: 0, page: 1, page_size: 100 }),
|
||||
});
|
||||
});
|
||||
await page.route("**/queries?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({
|
||||
items: [
|
||||
{
|
||||
id: "q-1",
|
||||
name: "炉温查询",
|
||||
datasource_id: "ds-1",
|
||||
enabled: true,
|
||||
current_version_no: 2,
|
||||
updated_at: "2024-11-18T10:00:00Z",
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function mockMappingList(page: Page): Promise<void> {
|
||||
await page.route("**/mappings**", async (route) => {
|
||||
const pathname = new URL(route.request().url()).pathname;
|
||||
if (!pathname.startsWith("/mappings") || route.request().method() !== "GET") {
|
||||
await route.continue();
|
||||
return;
|
||||
}
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({
|
||||
items: [{ id: "m-1", name: "炉温映射", query: "炉温查询", current_version_no: 1 }],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function mockAlarmList(page: Page): Promise<void> {
|
||||
await page.route("**/alarms?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: ok({
|
||||
items: [
|
||||
{
|
||||
id: "a-1",
|
||||
module_key: "furnace",
|
||||
scenario_key: "temp",
|
||||
scenario_name: "炉温超限",
|
||||
identity_key: "F1",
|
||||
status: "pending",
|
||||
close_result: null,
|
||||
last_occurred_at: "2024-11-18T12:00:00Z",
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/** Read a CSS custom property from :root. */
|
||||
export async function cssVar(page: Page, name: string): Promise<string> {
|
||||
return page.locator(":root").evaluate((el, prop) => getComputedStyle(el).getPropertyValue(prop).trim(), name);
|
||||
}
|
||||
|
||||
export async function computed(locator: Locator, prop: keyof CSSStyleDeclaration): Promise<string> {
|
||||
return locator.evaluate((el, p) => {
|
||||
const style = getComputedStyle(el);
|
||||
return String(style[p as keyof CSSStyleDeclaration] ?? "");
|
||||
}, prop);
|
||||
}
|
||||
|
||||
/** Assert list page card skeleton (P1): surface card + 32px filter gutters + right pager. */
|
||||
export async function expectListPageLayout(page: Page, listTestId: string): Promise<void> {
|
||||
const card = page.getByTestId(listTestId);
|
||||
await expect(card).toBeVisible();
|
||||
await expect(card).toHaveClass(/wm-list-page/);
|
||||
|
||||
const radius = await computed(card, "borderRadius");
|
||||
expect(radius).toMatch(/16px/);
|
||||
|
||||
const filters = card.locator(".wm-list-page__filters");
|
||||
await expect(filters).toBeVisible();
|
||||
const padLeft = await computed(filters, "paddingLeft");
|
||||
const padRight = await computed(filters, "paddingRight");
|
||||
expect(padLeft).toBe("32px");
|
||||
expect(padRight).toBe("32px");
|
||||
|
||||
const pager = card.locator(".wm-list-page__pager");
|
||||
if ((await pager.count()) > 0) {
|
||||
await expect(pager).toBeVisible();
|
||||
// Chromium may serialize flex-end as flow-end.
|
||||
expect(await computed(pager, "justifyContent")).toMatch(/^(flex-end|end|flow-end)$/);
|
||||
expect(await computed(pager, "paddingLeft")).toBe("32px");
|
||||
expect(await computed(pager, "paddingRight")).toBe("32px");
|
||||
}
|
||||
}
|
||||
|
||||
/** Assert form/detail card: scroll body + centered sticky footer. */
|
||||
export async function expectFormPageLayout(
|
||||
page: Page,
|
||||
opts: { pageTestId: string; footerTestId: string; bodyTestId?: string },
|
||||
): Promise<void> {
|
||||
const card = page.getByTestId(opts.pageTestId);
|
||||
await expect(card).toBeVisible();
|
||||
await expect(card).toHaveClass(/wm-form-page/);
|
||||
expect(await computed(card, "borderRadius")).toMatch(/16px/);
|
||||
|
||||
if (opts.bodyTestId) {
|
||||
const body = page.getByTestId(opts.bodyTestId);
|
||||
await expect(body).toBeVisible();
|
||||
expect(await computed(body, "overflow")).toMatch(/auto|scroll/);
|
||||
expect(await computed(body, "paddingLeft")).toBe("32px");
|
||||
}
|
||||
|
||||
const footer = page.getByTestId(opts.footerTestId);
|
||||
await expect(footer).toBeVisible();
|
||||
expect(await computed(footer, "justifyContent")).toMatch(/^(center|flex-center)$/);
|
||||
expect(await computed(footer, "paddingLeft")).toBe("32px");
|
||||
}
|
||||
|
||||
/** Shell chrome: brand nav, breadcrumb bar, padded main stage. */
|
||||
export async function expectShellChrome(page: Page): Promise<void> {
|
||||
await expect(page.getByTestId("side-nav")).toBeVisible();
|
||||
await expect(page.getByTestId("side-brand")).toBeVisible();
|
||||
await expect(page.getByTestId("breadcrumb")).toBeVisible();
|
||||
await expect(page.getByTestId("side-user")).toBeVisible();
|
||||
await expect(page.getByTestId("logout")).toBeVisible();
|
||||
|
||||
// AppShell content column: header + main stage with page padding.
|
||||
const shellMain = page.locator("div.flex.min-w-0.flex-1.flex-col > main");
|
||||
await expect(shellMain).toBeVisible();
|
||||
expect(await computed(shellMain, "paddingTop")).toBe("16px");
|
||||
expect(await computed(shellMain, "paddingLeft")).toBe("16px");
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
/**
|
||||
* Visual evidence for hexin UI alignment. Mocks auth + list APIs; does not cover login.
|
||||
*/
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const evidenceDir = path.resolve(
|
||||
path.dirname(fileURLToPath(import.meta.url)),
|
||||
"../../../../docs/evidence/ui-hexin",
|
||||
);
|
||||
|
||||
async function signedInAdmin(page: Page) {
|
||||
await page.route("**/auth/me", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { subject: "admin-1", display_name: "Admin", roles: ["watchman-admin"] },
|
||||
request_id: "ui-hexin-me",
|
||||
}),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function shot(page: Page, name: string) {
|
||||
await page.setViewportSize({ width: 1440, height: 900 });
|
||||
await page.screenshot({ path: path.join(evidenceDir, name), fullPage: true });
|
||||
}
|
||||
|
||||
test.describe("ui hexin screenshots", () => {
|
||||
test("S0 shell + S1 home", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/health", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { status: "ok", app: "watchman", version: "0.1.0" },
|
||||
request_id: "ui-hexin-health",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.goto("/");
|
||||
await expect(page.getByTestId("side-nav")).toBeVisible();
|
||||
await expect(page.getByTestId("home-page")).toBeVisible();
|
||||
await expect(page.getByTestId("health-success")).toBeVisible();
|
||||
await shot(page, "S0-shell-S1-home.png");
|
||||
});
|
||||
|
||||
test("S2 datasource list", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/datasources?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
id: "ds-1",
|
||||
name: "MES-PG",
|
||||
engine: "postgresql",
|
||||
host: "127.0.0.1",
|
||||
port: 5432,
|
||||
database_name: "mes",
|
||||
username: "ro",
|
||||
enabled: true,
|
||||
circuit_state: "closed",
|
||||
last_test_at: null,
|
||||
last_test_category: null,
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
},
|
||||
request_id: "ui-hexin-ds",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.goto("/#/datasources");
|
||||
await expect(page.getByTestId("datasource-list")).toBeVisible();
|
||||
await expect(page.getByTestId("datasource-table")).toBeVisible();
|
||||
await shot(page, "S2-datasource-list.png");
|
||||
});
|
||||
|
||||
test("S3 datasource create", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.goto("/#/datasources/new");
|
||||
await expect(page.getByTestId("datasource-edit")).toBeVisible();
|
||||
await expect(page.getByTestId("datasource-footer")).toBeVisible();
|
||||
await shot(page, "S3-datasource-create.png");
|
||||
});
|
||||
|
||||
test("S4 query list", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/datasources?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { items: [], total: 0, page: 1, page_size: 100 },
|
||||
request_id: "ui-hexin-ds-opt",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route("**/queries?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
id: "q-1",
|
||||
name: "炉温查询",
|
||||
datasource_id: "ds-1",
|
||||
enabled: true,
|
||||
current_version_no: 2,
|
||||
updated_at: "2024-11-18T10:00:00Z",
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
},
|
||||
request_id: "ui-hexin-q",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.goto("/#/queries");
|
||||
await expect(page.getByTestId("query-list")).toBeVisible();
|
||||
await expect(page.getByTestId("query-table")).toBeVisible();
|
||||
await shot(page, "S4-query-list.png");
|
||||
});
|
||||
|
||||
test("S5 query create", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/datasources?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { items: [], total: 0, page: 1, page_size: 100 },
|
||||
request_id: "ui-hexin-ds-opt",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.goto("/#/queries/new");
|
||||
await expect(page.getByTestId("query-edit")).toBeVisible();
|
||||
await expect(page.getByTestId("query-footer")).toBeVisible();
|
||||
await shot(page, "S5-query-create.png");
|
||||
});
|
||||
|
||||
test("S6 mapping list", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/health", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { status: "ok", app: "watchman", version: "0.1.0" },
|
||||
request_id: "ui-hexin-health",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.route("**/mappings**", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
if (!url.pathname.startsWith("/mappings") || route.request().method() !== "GET") {
|
||||
await route.continue();
|
||||
return;
|
||||
}
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: {
|
||||
items: [{ id: "m-1", name: "炉温映射", query: "炉温查询", current_version_no: 1 }],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
},
|
||||
request_id: "ui-hexin-m",
|
||||
}),
|
||||
});
|
||||
});
|
||||
page.on("pageerror", (err) => console.error("PAGEERROR", err.message));
|
||||
await page.goto("/#/mappings");
|
||||
await expect(page.getByTestId("nav-mappings")).toBeVisible();
|
||||
await expect(page.getByTestId("mapping-list")).toBeVisible({ timeout: 10_000 });
|
||||
await expect(page.getByTestId("mapping-table")).toBeVisible();
|
||||
await shot(page, "S6-mapping-list.png");
|
||||
});
|
||||
|
||||
test("S7 mapping edit", async ({ page }) => {
|
||||
const mapId = "44444444-4444-4444-8444-444444444444";
|
||||
const columns = [
|
||||
{
|
||||
source_column_name: "temperature",
|
||||
value_type: "number",
|
||||
is_identity: false,
|
||||
is_observation_time: false,
|
||||
numeric_multiply: null,
|
||||
numeric_offset: null,
|
||||
},
|
||||
];
|
||||
const tree = { column: "temperature", operator: "gt", value: 80 };
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/mappings**", async (route) => {
|
||||
const pathname = new URL(route.request().url()).pathname;
|
||||
if (!pathname.startsWith("/mappings")) {
|
||||
await route.continue();
|
||||
return;
|
||||
}
|
||||
if (route.request().method() === "GET" && pathname === `/mappings/${mapId}`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { id: mapId, query_definition_id: "q1", current_version_no: 1 },
|
||||
request_id: "ui-hexin-m-get",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (route.request().method() === "GET" && pathname === `/mappings/${mapId}/versions`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { items: [{ version_no: 1 }] },
|
||||
request_id: "ui-hexin-m-ver",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (route.request().method() === "GET" && pathname.startsWith(`/mappings/${mapId}/versions/`)) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { version_no: 1, columns, condition_tree: tree },
|
||||
request_id: "ui-hexin-m-v1",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
await route.fulfill({
|
||||
status: 404,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ success: true, data: {}, request_id: "ui-hexin-m-404" }),
|
||||
});
|
||||
});
|
||||
await page.route("**/queries/q1**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: {
|
||||
id: "q1",
|
||||
name: "炉温查询",
|
||||
description: null,
|
||||
datasource_id: "ds-1",
|
||||
enabled: true,
|
||||
current_version_no: 1,
|
||||
latest_version_no: 1,
|
||||
current: {
|
||||
sql_template: "select 1",
|
||||
param_schema: [],
|
||||
output_schema: [{ name: "temperature", type: "number" }],
|
||||
allowed_identifiers: [],
|
||||
timeout_ms: 5000,
|
||||
max_rows: 100,
|
||||
},
|
||||
},
|
||||
request_id: "ui-hexin-q-get",
|
||||
}),
|
||||
});
|
||||
});
|
||||
page.on("pageerror", (err) => console.error("PAGEERROR", err.message));
|
||||
await page.goto(`/#/mappings/${mapId}`);
|
||||
await expect(page.getByTestId("mapping-edit")).toBeVisible({ timeout: 10_000 });
|
||||
await expect(page.getByTestId("mapping-footer")).toBeVisible();
|
||||
await shot(page, "S7-mapping-edit.png");
|
||||
});
|
||||
|
||||
test("S8 alarm list", async ({ page }) => {
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/alarms?**", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
id: "a-1",
|
||||
module_key: "furnace",
|
||||
scenario_key: "temp",
|
||||
scenario_name: "炉温超限",
|
||||
identity_key: "F1",
|
||||
status: "pending",
|
||||
close_result: null,
|
||||
last_occurred_at: "2024-11-18T12:00:00Z",
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
},
|
||||
request_id: "ui-hexin-a",
|
||||
}),
|
||||
});
|
||||
});
|
||||
await page.goto("/#/alarms");
|
||||
await expect(page.getByTestId("alarm-list")).toBeVisible();
|
||||
await expect(page.getByTestId("alarm-table")).toBeVisible();
|
||||
await shot(page, "S8-alarm-list.png");
|
||||
});
|
||||
|
||||
test("S9 alarm detail", async ({ page }) => {
|
||||
const alarmId = "aaaaaaaa-aaaa-aaaa-8aaa-aaaaaaaaaaaa";
|
||||
const alarm = {
|
||||
id: alarmId,
|
||||
status: "pending",
|
||||
current_handler: null,
|
||||
claimed_at: null,
|
||||
closed_at: null,
|
||||
close_result: null,
|
||||
occurrence_count: 1,
|
||||
first_occurred_at: "2024-11-18T12:00:00Z",
|
||||
last_occurred_at: "2024-11-18T12:00:00Z",
|
||||
previous_alarm_id: null,
|
||||
mapped_input_id: "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb",
|
||||
identity_key: "F1",
|
||||
module_key: "furnace",
|
||||
scenario_key: "temp",
|
||||
scenario_name: "炉温超限",
|
||||
snapshot_id: "cccccccc-cccc-4ccc-8ccc-cccccccccccc",
|
||||
snapshot_version_no: 1,
|
||||
cycle_key: "c1",
|
||||
event_key: "e1",
|
||||
opened_at: "2024-11-18T12:00:00Z",
|
||||
updated_at: "2024-11-18T12:00:00Z",
|
||||
};
|
||||
await signedInAdmin(page);
|
||||
await page.route("**/alarms/**", async (route) => {
|
||||
const path = new URL(route.request().url()).pathname;
|
||||
if (path === `/alarms/${alarmId}`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ success: true, data: alarm, request_id: "ui-hexin-ad" }),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (path === `/alarms/${alarmId}/occurrences`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { alarm_id: alarmId, items: [] },
|
||||
request_id: "ui-hexin-occ",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (path === `/alarms/${alarmId}/evidence`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { alarm_id: alarmId, revision_evidence: [], closed_basis: [] },
|
||||
request_id: "ui-hexin-ev",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (path === `/alarms/${alarmId}/history`) {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({
|
||||
success: true,
|
||||
data: { alarm_id: alarmId, items: [] },
|
||||
request_id: "ui-hexin-hi",
|
||||
}),
|
||||
});
|
||||
return;
|
||||
}
|
||||
await route.continue();
|
||||
});
|
||||
await page.goto(`/#/alarms/${alarmId}`);
|
||||
await expect(page.getByTestId("alarm-detail")).toBeVisible();
|
||||
await expect(page.getByTestId("alarm-summary")).toBeVisible();
|
||||
await expect(page.getByTestId("alarm-footer")).toBeVisible();
|
||||
await shot(page, "S9-alarm-detail.png");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
});
|
||||
});
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Reference in new issue
Block a user