From 1feee94eac654111e1ffbec8c7cda52a538662a8 Mon Sep 17 00:00:00 2001 From: wangdequan Date: Fri, 13 Nov 2026 23:26:50 +0800 Subject: [PATCH] Align GUI audit with workbench selection and sync dist manifest Co-Authored-By: Claude Code --- tools/parity/audit-web-gui.mjs | 28 +++++++++++++++++++-- tools/parity/extract-desktop-gui.mjs | 5 ++++ web/docs/current/desktop-parity-matrix.json | 2 +- web/public/api/desktop-gui-manifest.json | 2 +- web/public/api/gui-command-gap-report.json | 2 +- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/tools/parity/audit-web-gui.mjs b/tools/parity/audit-web-gui.mjs index ed7dd187..582f84f1 100644 --- a/tools/parity/audit-web-gui.mjs +++ b/tools/parity/audit-web-gui.mjs @@ -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, }; diff --git a/tools/parity/extract-desktop-gui.mjs b/tools/parity/extract-desktop-gui.mjs index ea152683..d276d412 100644 --- a/tools/parity/extract-desktop-gui.mjs +++ b/tools/parity/extract-desktop-gui.mjs @@ -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 })); diff --git a/web/docs/current/desktop-parity-matrix.json b/web/docs/current/desktop-parity-matrix.json index 58797b5e..ea98fc3d 100644 --- a/web/docs/current/desktop-parity-matrix.json +++ b/web/docs/current/desktop-parity-matrix.json @@ -1,6 +1,6 @@ { "schema": "freecad-web-desktop-parity-matrix/v1", - "generatedAt": "2026-11-13T15:23:28.947Z", + "generatedAt": "2026-11-13T15:26:40.898Z", "stats": { "workbenches": 29, "commands": 1492, diff --git a/web/public/api/desktop-gui-manifest.json b/web/public/api/desktop-gui-manifest.json index 5fcc1cc5..b10a59aa 100644 --- a/web/public/api/desktop-gui-manifest.json +++ b/web/public/api/desktop-gui-manifest.json @@ -1,6 +1,6 @@ { "schema": "freecad-web-desktop-gui-manifest/v1", - "generatedAt": "2026-11-13T15:23:28.947Z", + "generatedAt": "2026-11-13T15:26:40.898Z", "sourceRevision": { "matrix": "0f467b45c2ed0105bc3f9d58a6149f18a6dc65dd86a93fc6b4f53cd1a39cfe5c", "routes": "6b21e4b2a7b06f5516433771bba06d61d1e7f3daa0e9a68c83aad6e000b4a25a" diff --git a/web/public/api/gui-command-gap-report.json b/web/public/api/gui-command-gap-report.json index 1b2e90a0..610fe247 100644 --- a/web/public/api/gui-command-gap-report.json +++ b/web/public/api/gui-command-gap-report.json @@ -1,6 +1,6 @@ { "schema": "freecad-web-desktop-gui-gap-report/v1", - "generatedAt": "2026-11-13T15:23:28.947Z", + "generatedAt": "2026-11-13T15:26:40.898Z", "byStatus": { "workbenches": 29, "commands": 1492,