Align GUI audit with workbench selection and sync dist manifest

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
2026-11-13 23:26:50 +08:00
parent 87faaf0796
commit 1feee94eac
5 changed files with 34 additions and 5 deletions

View File

@@ -35,6 +35,17 @@ const url = `${origin}/project.html?workbench=${encodeURIComponent(workbench)}`;
const response = await page.goto(url, { waitUntil: "domcontentloaded", timeout: 120000 });
await page.waitForSelector('select[aria-label="Workbench"]', { timeout: 120000 }).catch(() => {});
await page.waitForTimeout(1500);
if (workbench !== "Part") {
await page.locator('nav[aria-label="Application menus"] details').filter({ hasText: "File" }).locator("summary").click();
await page.getByRole("button", { name: "新建 Document", exact: true }).click();
await page.waitForTimeout(1800);
await page.evaluate(() => { for (const details of document.querySelectorAll('nav[aria-label="Application menus"] details[open]')) details.open = false; });
const selector = page.locator('select[aria-label="Workbench"]');
if (await selector.count() && !(await selector.isDisabled())) {
await selector.selectOption(workbench).catch(() => {});
await page.waitForTimeout(1600);
}
}
const metrics = await page.evaluate(() => ({
menus: [...document.querySelectorAll('nav[aria-label="Application menus"] details > summary')]
.map(node => node.textContent.trim()),
@@ -49,7 +60,20 @@ const metrics = await page.evaluate(() => ({
overflow: document.documentElement.scrollWidth - document.documentElement.clientWidth,
}));
const expectedMenus = desktop.menus.map(menu => menu.label);
const missingMenus = expectedMenus.filter(label => !metrics.menus.includes(label));
let submenus = [];
if (workbench !== "Part") {
const toggle = page.locator(`summary[aria-label="${workbench} menu"]`).first();
if (await toggle.count()) {
await toggle.click();
for (let attempt = 0; attempt < 12; attempt++) {
await page.waitForTimeout(400);
submenus = await page.locator(".parity-menu-items>details>summary").allTextContents();
if (submenus.length) break;
}
await toggle.click().catch(() => {});
}
}
const missingMenus = expectedMenus.filter(label => !metrics.menus.includes(label) && !submenus.includes(label));
const shot = path.join(outDir, `${workbench}-web.png`);
await page.screenshot({ path: shot, fullPage: false });
const report = {
@@ -57,7 +81,7 @@ const report = {
generatedAt: new Date().toISOString(), workbench, url,
desktop: { menus: expectedMenus, toolbars: desktop.toolbars.map(bar => bar.name),
menuCommandCount: desktop.menus.reduce((sum, menu) => sum + menu.items.length, 0) },
web: metrics, missingMenus,
web: { ...metrics, submenus }, missingMenus,
status: response?.status(), errors, failed,
ok: response?.status() === 200 && errors.length === 0 && failed.length === 0 && metrics.overflow === 0,
};

View File

@@ -306,5 +306,10 @@ fs.mkdirSync(path.join(webRoot, "docs/current"), { recursive: true });
fs.writeFileSync(path.join(webRoot, "public/api/desktop-gui-manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`);
fs.writeFileSync(path.join(webRoot, "docs/current/desktop-parity-matrix.json"), `${JSON.stringify(matrixOut, null, 2)}\n`);
fs.writeFileSync(path.join(webRoot, "public/api/gui-command-gap-report.json"), `${JSON.stringify(gapReport, null, 2)}\n`);
const distApi = path.join(webRoot, "dist", "api");
if (fs.existsSync(distApi)) {
fs.copyFileSync(path.join(webRoot, "public/api/desktop-gui-manifest.json"), path.join(distApi, "desktop-gui-manifest.json"));
fs.copyFileSync(path.join(webRoot, "public/api/gui-command-gap-report.json"), path.join(distApi, "gui-command-gap-report.json"));
}
console.log(JSON.stringify({ ok: true, workbenches: workbenches.length, commands: records.length,
menuCommands: menuCommandIds.size, stats: matrixOut.stats }));