按 UI 评审闭环 UI-02~UI-07(查询降权、对象/处理人可读化、筛选分层、数据源名映射、焦点外环);概览与登录壳按约定暂缓。 Co-authored-by: Cursor <cursoragent@cursor.com>
119 lines
4.7 KiB
JavaScript
119 lines
4.7 KiB
JavaScript
/**
|
|
* Post-fix UI recheck. Credentials via env only.
|
|
* WATCHMAN_UI_USER / WATCHMAN_UI_PASSWORD
|
|
*/
|
|
import { chromium } from "@playwright/test";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const user = process.env.WATCHMAN_UI_USER;
|
|
const password = process.env.WATCHMAN_UI_PASSWORD;
|
|
if (!user || !password) {
|
|
console.error("Missing WATCHMAN_UI_USER or WATCHMAN_UI_PASSWORD");
|
|
process.exit(1);
|
|
}
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../../../");
|
|
const outDir = path.join(root, "docs/evidence/ui-review/2026-11-19-console-recheck/screenshots");
|
|
fs.mkdirSync(outDir, { recursive: true });
|
|
|
|
async function shot(page, name) {
|
|
await page.waitForTimeout(350);
|
|
await page.screenshot({ path: path.join(outDir, name), fullPage: false });
|
|
}
|
|
|
|
async function buttonTone(page, testId) {
|
|
const loc = page.getByTestId(testId);
|
|
if ((await loc.count()) === 0) return null;
|
|
return loc.evaluate((el) => ({
|
|
testId: el.getAttribute("data-testid"),
|
|
classes: el.className,
|
|
isPrimary: el.classList.contains("el-button--primary"),
|
|
}));
|
|
}
|
|
|
|
const browser = await chromium.launch({ headless: true });
|
|
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
|
|
|
|
await page.goto("http://127.0.0.1:5173/", { waitUntil: "networkidle" });
|
|
await page.getByTestId("login-username").locator("input").fill(user);
|
|
await page.getByTestId("login-password").locator("input").fill(password);
|
|
await page.getByTestId("login-submit").click();
|
|
await page.getByTestId("logout").waitFor({ timeout: 20000 });
|
|
|
|
await page.goto("http://127.0.0.1:5173/#/", { waitUntil: "networkidle" });
|
|
await shot(page, "home-1440x900-01.png");
|
|
|
|
await page.goto("http://127.0.0.1:5173/#/datasources", { waitUntil: "networkidle" });
|
|
await page.waitForTimeout(500);
|
|
const dsButtons = {
|
|
search: await buttonTone(page, "datasource-filter-search"),
|
|
create: await buttonTone(page, "datasource-create"),
|
|
};
|
|
await shot(page, "datasources-1440x900-02.png");
|
|
|
|
// keyboard focus on name filter
|
|
await page.getByTestId("datasource-filter-name").locator("input").focus();
|
|
await page.waitForTimeout(200);
|
|
const focusStyles = await page.evaluate(() => {
|
|
const el = document.activeElement;
|
|
const wrap = el?.closest(".el-input__wrapper") || el;
|
|
const cs = getComputedStyle(wrap);
|
|
return { outline: cs.outline, boxShadow: cs.boxShadow };
|
|
});
|
|
await shot(page, "datasources-1440x900-focus-03.png");
|
|
|
|
await page.goto("http://127.0.0.1:5173/#/queries", { waitUntil: "networkidle" });
|
|
await page.waitForTimeout(800);
|
|
const qButtons = {
|
|
search: await buttonTone(page, "query-filter-search"),
|
|
create: await buttonTone(page, "query-create"),
|
|
};
|
|
const dsCellSample = await page.locator("[data-testid=query-table] tbody tr").first().locator("td").nth(1).innerText().catch(() => "");
|
|
await shot(page, "queries-1440x900-04.png");
|
|
|
|
await page.goto("http://127.0.0.1:5173/#/mappings", { waitUntil: "networkidle" });
|
|
await page.waitForTimeout(500);
|
|
await shot(page, "mappings-1440x900-05.png");
|
|
|
|
await page.goto("http://127.0.0.1:5173/#/alarms", { waitUntil: "networkidle" });
|
|
await page.waitForTimeout(600);
|
|
const moreVisible = await page.getByTestId("alarm-filter-more").isVisible();
|
|
const moduleHidden = (await page.getByTestId("alarm-filter-module").count()) === 0;
|
|
await shot(page, "alarms-1440x900-default-06.png");
|
|
await page.getByTestId("alarm-filter-more").click();
|
|
await page.waitForTimeout(200);
|
|
const moduleVisible = await page.getByTestId("alarm-filter-module").isVisible();
|
|
await shot(page, "alarms-1440x900-more-07.png");
|
|
|
|
const objectText = await page.locator("[data-testid=alarm-object-label]").first().innerText().catch(() => "");
|
|
const objectTitle = await page.locator("[data-testid=alarm-object-label]").first().getAttribute("title").catch(() => "");
|
|
|
|
await page.getByTestId("alarm-open").first().click();
|
|
await page.waitForTimeout(700);
|
|
const identityText = await page.getByTestId("alarm-identity").innerText().catch(() => "");
|
|
const identityTitle = await page.getByTestId("alarm-identity").getAttribute("title").catch(() => "");
|
|
const handlerText = await page.getByTestId("alarm-handler").innerText().catch(() => "");
|
|
await shot(page, "alarm-detail-1440x900-08.png");
|
|
|
|
const notes = {
|
|
dsButtons,
|
|
qButtons,
|
|
focusStyles,
|
|
dsCellSample: dsCellSample.trim(),
|
|
alarms: {
|
|
moreVisible,
|
|
moduleHiddenBeforeMore: moduleHidden,
|
|
moduleVisibleAfterMore: moduleVisible,
|
|
objectText: objectText.trim(),
|
|
objectTitle,
|
|
identityText: identityText.trim(),
|
|
identityTitle,
|
|
handlerText: handlerText.trim(),
|
|
},
|
|
};
|
|
fs.writeFileSync(path.join(outDir, "..", "recheck-notes.json"), JSON.stringify(notes, null, 2), "utf8");
|
|
console.log(JSON.stringify(notes, null, 2));
|
|
await browser.close();
|