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,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");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user