import { expect, test, type Page } from "./support/deployed-test"; import { FIXTURES, gotoApp, openProject, receipt, shot, waitForObjects } from "./support/deployed"; import { CAPABILITIES, type CapabilityRow } from "./support/matrix"; /** * Coverage ledger for the 31 capability rows in tools/web/manual/feature-matrix.json. * * One case per functional area so the suite does not reload the 300 MB engine 31 * times. Each case walks the workspace the rows belong to and records a verdict * per row: what was observed, and whether a user could actually reach it. */ test.use({ viewport: { width: 1600, height: 900 } }); async function switchWorkspace(page: Page, name: string): Promise { await page.locator('nav[aria-label="工作区"] button', { hasText: new RegExp(`^${name}$`) }).click(); await expect(page.locator("main.blender-app")).toHaveAttribute("data-workspace", name, { timeout: 15_000 }); } interface AreaPlan { workspace: string | null; /** * User-visible surfaces that must render for the area to count as usable. * `conditional` names where a surface is proven instead when it is not * expected to render for this scene (for example NLA strips need an object * that owns NLA tracks). */ surfaces: Array<{ name: string; selector: string; conditional?: string }>; } const AREA_PLANS: Record = { Layout: { workspace: "Layout", surfaces: [ { name: "3D viewport", selector: ".viewport-area canvas.viewport-canvas" }, { name: "outliner", selector: ".outliner-area" }, { name: "properties", selector: ".properties-area" }, { name: "timeline", selector: ".timeline-area" }, ] }, Modeling: { workspace: "Modeling", surfaces: [ { name: "viewport", selector: ".viewport-area" }, { name: "quick toolbar", selector: ".legacy-quick-toolbar" }, ] }, Sculpting: { workspace: "Sculpting", surfaces: [ { name: "viewport", selector: ".viewport-area" }, { name: "properties", selector: ".properties-area" }, ] }, "UV Editing": { workspace: "UV Editing", surfaces: [ { name: "uv image editor", selector: ".area-frame.image-editor-area, .image-editor-area" }, { name: "viewport", selector: ".viewport-area" }, ] }, "Texture Paint": { workspace: "Texture Paint", surfaces: [ { name: "paint canvas", selector: "canvas" }, { name: "properties", selector: ".properties-area" }, ] }, Shading: { workspace: "Shading", surfaces: [ { name: "asset library", selector: ".pbr-asset-library" }, { name: "node editor", selector: ".area-frame.node-editor-area, .blender-shader-canvas" }, ] }, Animation: { workspace: "Animation", surfaces: [ { name: "dope sheet / timeline", selector: ".timeline-area, .area-frame.camera-view-area" }, /* Only rendered when the active object owns NLA tracks; ch20 walks it with * nla_time_mapping_scene.blend, so its absence here is not a gap. */ { name: "nla selectors", selector: "[data-testid='nla-track-select']", conditional: "[ch20] with nla_time_mapping_scene.blend" }, ] }, Rendering: { workspace: "Rendering", surfaces: [ { name: "render result", selector: ".area-frame.render-result-area, .render-result-view" }, { name: "render panel", selector: ".pbr-render-panel, .native-render-panel" }, ] }, Compositing: { workspace: "Compositing", surfaces: [ { name: "compositor canvas", selector: ".compositor-canvas-shell" }, ] }, "Geometry Nodes": { workspace: "Geometry Nodes", surfaces: [ { name: "geometry node canvas", selector: "[data-testid='geometry-node-canvas']" }, { name: "spreadsheet", selector: ".spreadsheet, [data-testid='spreadsheet-view']" }, ] }, Scripting: { workspace: "Scripting", surfaces: [ { name: "text editor", selector: ".area-frame.text-editor-area" }, { name: "python console", selector: ".area-frame.console-area" }, { name: "info", selector: ".area-frame.info-area" }, ] }, Files: { workspace: "Layout", surfaces: [ { name: "open input", selector: "[data-testid='blend-file-input']" }, { name: "recent projects", selector: "[data-testid='recent-projects']" }, { name: "save", selector: "[aria-label='保存项目']" }, ] }, IO: { workspace: "Layout", surfaces: [ { name: "open input", selector: "[data-testid='blend-file-input']" }, { name: "export glb", selector: "[aria-label='导出 GLB']" }, ] }, Settings: { workspace: "Layout", surfaces: [ { name: "preferences entry", selector: "[aria-label='导出诊断报告']" }, ] }, Simulation: { workspace: "Layout", surfaces: [ { name: "properties", selector: ".properties-area" }, ] }, Sequencer: { workspace: "Animation", surfaces: [ { name: "animation area", selector: ".timeline-area, .area-frame.camera-view-area" }, ] }, Camera: { workspace: "Layout", surfaces: [ { name: "camera view button", selector: "[aria-label='相机视图']" }, { name: "camera lock", selector: "[aria-label='锁定相机']" }, ] }, }; function rowsFor(area: string): CapabilityRow[] { return CAPABILITIES.filter((row) => row.area === area); } const areas = [...new Set(CAPABILITIES.map((row) => row.area))]; for (const area of areas) { const plan = AREA_PLANS[area]; const slug = area.toLowerCase().replace(/[^a-z]+/g, "-"); test(`[cap-${slug}] 能力矩阵 · ${area}(${rowsFor(area).length} 条)`, async ({ page }, testInfo) => { if (!plan) { receipt(testInfo, { workflow: `capability rows for ${area}`, capabilities: rowsFor(area).map((row) => ({ feature: row.feature, status: "NOT_COVERED", reason: "本区域没有可执行的界面证据" })), status: "NOT_COVERED", }); test.skip(true, `${area} has no executable browser evidence yet`); return; } await gotoApp(page, "web"); await openProject(page, FIXTURES.studio, { objects: 6, active: /PBR Studio Ground/ }); await waitForObjects(page, 6); if (plan.workspace && plan.workspace !== "Layout") await switchWorkspace(page, plan.workspace); const observed: Array<{ name: string; found: boolean; conditional?: string }> = []; for (const surface of plan.surfaces) { const visible = await page.locator(surface.selector).first().isVisible({ timeout: 20_000 }).catch(() => false); observed.push({ name: surface.name, found: visible, ...(surface.conditional ? { conditional: surface.conditional } : {}) }); } const missing = observed.filter((item) => !item.found && !item.conditional); const image = await shot(page, testInfo, "capability-area"); receipt(testInfo, { workflow: `${plan.workspace ?? "Layout"} workspace surfaces for ${area}`, capabilities: rowsFor(area).map((row) => ({ feature: row.feature, chapter: row.chapter, status: missing.length === 0 ? "PASS" : "PARTIAL", missing: missing.map((item) => item.name), })), surfaces: observed, screenshot: image, status: missing.length === 0 ? "PASS" : "FAIL", }); expect(missing.map((item) => item.name), `surfaces missing for ${area}`).toEqual([]); }); } test("[cap-ledger] 能力矩阵 31 条全部有归属区域", async ({}, testInfo) => { expect(CAPABILITIES.length, "the feature matrix carries 31 capability rows").toBe(31); const unmapped = CAPABILITIES.filter((row) => !AREA_PLANS[row.area]); expect(unmapped.map((row) => `${row.area}/${row.feature}`)).toEqual([]); const chapters = new Set(CAPABILITIES.map((row) => row.chapter).filter(Boolean)); receipt(testInfo, { workflow: "feature-matrix.json rows all map to an executable area plan", rows: CAPABILITIES.length, areas: [...new Set(CAPABILITIES.map((row) => row.area))], chapters: [...chapters].sort(), status: "PASS", }); });