diff --git a/docs/status/VIEWPORT-NAV-20261125.md b/docs/status/VIEWPORT-NAV-20261125.md index da8279093..4912b4c71 100644 --- a/docs/status/VIEWPORT-NAV-20261125.md +++ b/docs/status/VIEWPORT-NAV-20261125.md @@ -491,3 +491,17 @@ Web 视图里在大纲中 Ctrl+点击选中两个对象后,原生选择被覆 - 每份通过回执 `consoleNoise` 非空、`productConsoleErrors` 为空;反向用例回执含 2 条注入错误。 - 本批只跑该文件;配置内其余 3 个 spec(`mesh-lod-reader-production`、`object-hierarchy-production`、`hierarchy-simplify-combined`)未在本批运行。 - `acceptance: NOT_CLAIMED`:单次、单候选、单环境结果,不给整体完成度。 + +--- + +### 简化套件其余三个 spec 关闭(整套 15 例通过) + +- 用 `playwright.mesh-simplify.config.ts` 跑完整套件:`mesh-simplify-production`(12 例)+ `mesh-lod-reader-production` + `object-hierarchy-production` + `hierarchy-simplify-combined`,共 15 例全部通过(15 passed)。 +- 修正(皆为测试与当前入口的漂移,非产品缺口): + - 控制台断言统一改用共享夹具 `web/tests/fixtures/runtime-console.ts`(窄过滤 `__syscall_*` 桩,原始文本仍留 `consoleErrors`,回执另存 `consoleNoise` / `productConsoleErrors`)。 + - `mesh-lod-reader-production` 的对象可见性等待改走 Outliner `treeitem`(视口侧栏同名节点导致 strict 冲突)。 + - 共享夹具 `NativeUIWorkflow.save()` 与 `hierarchy-simplify-combined` 的保存改走「下载 .blend」入口(OPFS 保存不再自动下载)。 + - `object-hierarchy-production` 的集合可见性工作台在 `集合` 属性标签下,诊断面板关闭时被外壳 CSS 隐藏;用例先点「集合」标签(`jumpToPropertySection` 打开诊断并滚动到该区块),再操作 `Hide/Show Viewport`、`Enable/Disable Render`。 +- 文档:新增 `docs/web/P1424-MESH-SIMPLIFY-SUITE.md`(套件构成、有头运行命令、测试口径、回执约定)。 +- 候选绑定:`web_engine.wasm` sha256 `f0a528ae44be8335d4c340bcc5d08ffb1e450b9e5420318dba50370d4fab8280`。 +- `acceptance: NOT_CLAIMED`:结果只代表该候选、该环境。 diff --git a/docs/web/P1424-MESH-SIMPLIFY-SUITE.md b/docs/web/P1424-MESH-SIMPLIFY-SUITE.md new file mode 100644 index 000000000..0e210f54d --- /dev/null +++ b/docs/web/P1424-MESH-SIMPLIFY-SUITE.md @@ -0,0 +1,43 @@ +# WBV2-P1424 网格简化 / 层级套件(有头) + +桌面 Blender 简化、LOD 与层级工作的生产回归套件。四个 spec 共用 +`web/playwright.mesh-simplify.config.ts`,默认对 `web/dist` 候选运行,可显式指定其它候选目录。 + +## 构成 + +| 文件 | 覆盖 | 夹具 / oracle | +| --- | --- | --- | +| `web/tests/e2e/mesh-simplify-production.spec.ts` | 预览/取消/应用/撤销重做、保存重开、LOD 缓存恢复与拒绝、三种 Decimate 模式 | `tests/files/web/mesh_simplify_high.blend` 等;`tests/golden/WBV2-P1424-001/{mesh-simplify-20261020,lod-current-main-20261021,...}` | +| `web/tests/e2e/mesh-lod-reader-production.spec.ts` | 凹形缺口按桌面三角化的 LOD 读回 | `tests/golden/WBV2-P1424-001/lod-current-main-20261021/desktop-concave.json` | +| `web/tests/e2e/object-hierarchy-production.spec.ts` | 父级/集合生命周期、撤销重做、保存重开 | `tests/golden/WBV2-P1424-001/object-hierarchy-20261021/desktop-hierarchy.json` | +| `web/tests/e2e/hierarchy-simplify-combined.spec.ts` | 层级 + 简化在 Worker 两次终止后仍可导出 | `tests/golden/WBV2-P1424-001/hierarchy-simplify-combined-20261021/desktop-combined.json` | + +## 运行 + +```bash +cd /home/mes123456/workinf_Blender_Wasm/web +DISPLAY=:1 \ +WBV2_PRODUCTION_CANDIDATE=/home/mes123456/workinf_Blender_Wasm/web/dist \ +WEB_TEST_PORT=5620 \ +npx playwright test --config playwright.mesh-simplify.config.ts --reporter=line +``` + +- 有头:`playwright.config.ts` 依据 `DISPLAY` 选择 `hardware` 模式;本配置另以 swiftshader 参数启动 Chrome。视口渲染的是网格几何(`?ui=web`)。 +- 单文件:在命令末尾追加 spec 文件名。 +- 回执:按各 spec 的约定目录落盘(`tests/golden/WBV2-P1424-001/**`,按时间戳新建,不覆盖历史)。`mesh-simplify-production` 可用 `WBV2_EVIDENCE_DIR` 指向独立目录。 +- 候选绑定:回执 `modules[]` 记录 `web_engine.wasm` 与 manifest 的 sha256;报告只对该候选成立。 + +## 测试口径(与当前产品入口一致) + +- **控制台噪声**:Emscripten 调试版 libc 的 `__syscall_mprotect` 桩返回成功并打印警告。共享夹具 `web/tests/fixtures/runtime-console.ts` 提供 `RUNTIME_STUB_NOISE / runtimeNoise / productErrors`;原始文本留在 `consoleErrors`,回执另存 `consoleNoise` 与 `productConsoleErrors`,真实控制台错误仍为硬失败。 +- **对象选择**:对象名同时出现在视口侧栏与 Outliner,选择走 `getByRole('treeitem', {name})` 的 `.tree-node-name`。 +- **保存**:OPFS 保存(`保存项目`)不下载;需要本地文件时走用户可见的「下载 .blend」入口(同时持久化同一份字节)。 +- **属性工作台**:`*-workbench` 区块在诊断面板关闭时被外壳隐藏;集合可见性等入口需先点属性标签(如「集合」),由 `jumpToPropertySection` 打开诊断并滚动到对应区块。 +- **简化契约**:`protocol/simplify.ts` 与引擎都要求 `ratio > 0`;COLLAPSE 比例 0 断言为 `INVALID_ARGUMENT`。UI 滑杆最小值 0.05,用户不可达 0。 +- **快照比较**:场景相等性剔除以数据块为单位的 revision、编辑器焦点与窗口管理器区域状态(`sceneState`)。 +- **项目动作锁**:保存/打开未释放时产品会拒绝编辑并提示“请稍后再编辑”;测试按用户行为重试。 + +## 已知状态 + +- 最近一次整套运行:4 个 spec 全部通过;候选 `web_engine.wasm` sha256 `f0a528ae44be8335d4c340bcc5d08ffb1e450b9e5420318dba50370d4fab8280`。 +- `acceptance: NOT_CLAIMED`:结果只代表该候选、该环境。 diff --git a/web/tests/e2e/hierarchy-simplify-combined.spec.ts b/web/tests/e2e/hierarchy-simplify-combined.spec.ts index 669cc35e7..24c5cf109 100644 --- a/web/tests/e2e/hierarchy-simplify-combined.spec.ts +++ b/web/tests/e2e/hierarchy-simplify-combined.spec.ts @@ -3,6 +3,7 @@ import fs from 'node:fs'; import path from 'node:path'; import crypto from 'node import { NativeUIWorkflow, observeNative } from '../fixtures/native-ui-workflow'; import type { WebEngineRequest, WebEngineResponse } from '../../protocol/web-engine'; import type { SceneSnapshotIR } from '../../protocol/scene-ir'; +import { productErrors, runtimeNoise } from '../fixtures/runtime-console'; const root = path.resolve(import.meta.dirname, '../../..'), evidence = path.join(root, 'tests/golden/WBV2-P1424-001/hierarchy-simplify-combined-20261021'); const sha = (file: string) => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex'); const digest = (value: unknown) => crypto.createHash('sha256').update(JSON.stringify(value)).digest('hex'); type Reply = Extract; @@ -49,16 +50,16 @@ test('hierarchy simplify survives both Worker terminations and GLB export', asyn record.states.recovered = await snapshot(page); expect(canonical(record.states.recovered)).toEqual(canonical(record.states.saved)); record.restartedWorkers = await page.evaluate(() => (window as unknown as { __combinedWorkers: { url: string; worker: Worker }[] }).__combinedWorkers.map(item=>item.url)); expect(record.restartedWorkers.some(url=>url.includes('web-engine.worker'))).toBe(true); expect(record.restartedWorkers.some(url=>url.includes('storage.worker'))).toBe(true); const oldCommit = Number(await page.locator('main.blender-app').getAttribute('data-save-committed-revision')); - const recoveredDownload = page.waitForEvent('download', { timeout: 60_000 }); await page.getByRole('button', { name: '保存项目', exact: true }).click(); await (await recoveredDownload).saveAs(path.join(directory, 'recovered.blend')); + const recoveredDownload = page.waitForEvent('download', { timeout: 60_000 }); await page.getByRole('button', { name: '下载 .blend', exact: true }).click(); await (await recoveredDownload).saveAs(path.join(directory, 'recovered.blend')); await expect(page.locator('main.blender-app')).toHaveAttribute('data-save-committed-revision', String(oldCommit+1)); await expect(page.locator('main.blender-app')).toHaveAttribute('data-dirty', 'false'); await ui.save('recovered-again'); expect(sha(path.join(directory,'recovered-again.blend'))).toBe(sha(path.join(directory,'recovered.blend'))); await expect(page.locator('main.blender-app')).toHaveAttribute('data-save-committed-revision', String(oldCommit+1)); const download = page.waitForEvent('download', { timeout: 60_000 }); await page.getByRole('button', { name: '导出 GLB', exact: true }).click(); await (await download).saveAs(path.join(directory, 'recovered.glb')); await expect(page.getByTestId('engine-status')).toContainText('fixture_weight'); record.exportStatus = (await page.getByTestId('engine-status').getAttribute('title')) ?? ''; expect(canonical(await snapshot(page))).toEqual(canonical(record.states.recovered)); expect(record.exportStatus).toContain('InspectionCamera: CAMERA data is exported as an empty hierarchy node'); expect(record.exportStatus).toContain('KeyLight: LIGHT data is exported as an empty hierarchy node'); - expect(record.failures).toEqual([]); expect(record.consoleErrors).toEqual([]); passed = true; + expect(record.failures).toEqual([]); expect(productErrors(record.consoleErrors)).toEqual([]); passed = true; } finally { if (await page.getByTestId('export-diagnostics').isEnabled()) { const diagnostic = page.waitForEvent('download'); await page.getByTestId('export-diagnostics').click(); await (await diagnostic).saveAs(path.join(directory,'diagnostics.json')); } fs.writeFileSync(path.join(directory,'terminal-ui.json'), JSON.stringify(await page.evaluate(() => ({ attributes: Object.fromEntries(Array.from(document.querySelector('main.blender-app')?.attributes ?? []).map(attribute=>[attribute.name,attribute.value])), status: document.querySelector('[data-testid="engine-status"]')?.getAttribute('title'), requests: (window as unknown as { __nativeWorkflowRequests: unknown[] }).__nativeWorkflowRequests, responses: (window as unknown as { __nativeWorkflowResponses: unknown[] }).__nativeWorkflowResponses })), null, 2)); - fs.writeFileSync(path.join(directory, 'receipt.json'), JSON.stringify({ ...record, passed, exitCode: passed ? 0 : 1, durationMs: Date.now()-started, canonicalHashes: Object.fromEntries(Object.entries(record.states).map(([name,state])=>[name,digest(canonical(state))])), testSourceSha256: sha(import.meta.filename) }, null, 2)); + fs.writeFileSync(path.join(directory, 'receipt.json'), JSON.stringify({ ...record, consoleNoise: runtimeNoise(record.consoleErrors), productConsoleErrors: productErrors(record.consoleErrors), passed, exitCode: passed ? 0 : 1, durationMs: Date.now()-started, canonicalHashes: Object.fromEntries(Object.entries(record.states).map(([name,state])=>[name,digest(canonical(state))])), testSourceSha256: sha(import.meta.filename) }, null, 2)); } }); diff --git a/web/tests/e2e/mesh-lod-reader-production.spec.ts b/web/tests/e2e/mesh-lod-reader-production.spec.ts index bd5d7fc1d..fecb64dc8 100644 --- a/web/tests/e2e/mesh-lod-reader-production.spec.ts +++ b/web/tests/e2e/mesh-lod-reader-production.spec.ts @@ -3,6 +3,7 @@ import fs from 'node:fs'; import path from 'node:path'; import crypto from 'node:crypto'; import type { WebEngineLODResult } from '../../protocol/web-engine'; +import { productErrors, runtimeNoise } from '../fixtures/runtime-console'; const root = path.resolve(import.meta.dirname, '../../..'); const baseline = path.join(root, 'tests/golden/WBV2-P1424-001/lod-current-main-20261021'); const evidence = process.env.WBV2_EVIDENCE_DIR ?? baseline; @@ -21,7 +22,8 @@ test('concave reader uses native desktop triangulation', async ({ page, browser await page.addInitScript(() => { const Native = window.Worker; window.Worker = class extends Native { constructor(url: string | URL, options?: WorkerOptions) { super(url, options); this.addEventListener('message', ({ data }) => { if (data.result?.lod) (window as unknown as { __concaveLOD: unknown }).__concaveLOD = data.result.lod; }); } }; }); await page.goto('/?ui=web'); record.isolated = await page.evaluate(() => crossOriginIsolated); expect(record.isolated).toBe(true); await page.getByTestId('blend-file-input').setInputFiles(fixture); - await expect(page.getByText('ConcaveNotch', { exact: true })).toBeVisible({ timeout: 60_000 }); + /* The name also renders in the viewport sidebar; wait on the Outliner row. */ + await expect(page.getByRole('treeitem', { name: 'ConcaveNotch', exact: true }).first()).toBeVisible({ timeout: 60_000 }); const before = await page.getByTestId('scene-stats').textContent(); await page.getByRole('button', { name: '生成 LOD' }).click(); await expect(page.getByTestId('engine-status')).toContainText('cache ready', { timeout: 90_000 }); const observed = await page.evaluate(() => { const lod = (window as unknown as { __concaveLOD: WebEngineLODResult }).__concaveLOD; return { revision: lod.manifest.sourceMeshRevision, unavailable: lod.errors?.length ?? 0, levels: lod.levels.map(level => ({ triangles: level.outputTriangleCount, positions: Array.from(new Float32Array(level.geometryBuffers[0].positions)), indices: Array.from(new Uint32Array(level.geometryBuffers[0].indices)) })) }; }); @@ -29,6 +31,6 @@ test('concave reader uses native desktop triangulation', async ({ page, browser expect(observed.levels[0]).toEqual({ triangles: oracle.triangles, positions: oracle.positions, indices: oracle.indices }); expect(observed.unavailable).toBe(2); await expect(page.getByTestId('engine-status')).toContainText('2 unavailable level(s)'); expect(await page.getByTestId('scene-stats').textContent()).toBe(before); - expect(record.failures).toEqual([]); expect(record.consoleErrors).toEqual([]); passed = true; - } finally { fs.writeFileSync(path.join(evidence, `${record.started}-concave-reader.json`), JSON.stringify({ ...record, passed, exitCode: passed ? 0 : 1, durationMs: Date.now() - record.started, testSourceSha256: hash(import.meta.filename) }, null, 2)); } + expect(record.failures).toEqual([]); expect(productErrors(record.consoleErrors)).toEqual([]); passed = true; + } finally { fs.writeFileSync(path.join(evidence, `${record.started}-concave-reader.json`), JSON.stringify({ ...record, consoleNoise: runtimeNoise(record.consoleErrors), productConsoleErrors: productErrors(record.consoleErrors), passed, exitCode: passed ? 0 : 1, durationMs: Date.now() - record.started, testSourceSha256: hash(import.meta.filename) }, null, 2)); } }); diff --git a/web/tests/e2e/mesh-simplify-production.spec.ts b/web/tests/e2e/mesh-simplify-production.spec.ts index 7a6874f1d..54045c808 100644 --- a/web/tests/e2e/mesh-simplify-production.spec.ts +++ b/web/tests/e2e/mesh-simplify-production.spec.ts @@ -5,6 +5,7 @@ import crypto from 'node:crypto'; import { decodeLODGeometry } from '../../protocol/mesh-cache'; import type { LODCacheRecord } from '../../protocol/lod'; import type { SimplifyResult } from '../../protocol/simplify'; +import { RUNTIME_STUB_NOISE, productErrors as sharedProductErrors, runtimeNoise as sharedRuntimeNoise } from '../fixtures/runtime-console'; const root = path.resolve(import.meta.dirname, '../../..'); const baseline = path.join(root, 'tests/golden/WBV2-P1424-001/mesh-simplify-20261020'); const lodBaseline = path.join(root, 'tests/golden/WBV2-P1424-001/lod-current-main-20261021'); @@ -18,14 +19,8 @@ type LODObservation = { manifest: { meshId: string; sourceMeshRevision: number } type Wire = { requestId: string; ok: boolean; result?: { snapshot?: Snapshot; simplify?: SimplifyResult; lod?: LODObservation; projectId?: string; cacheKey?: string; bytes?: number; dataBase64?: string; manifest?: LODCacheRecord; manifests?: LODCacheRecord[]; remainingBytes?: number }; error?: unknown; errorCode?: string }; type Record = { started: number; chrome: string; failures: string[]; errors: string[]; modules: { url: string; sha256: string }[]; wire: Wire[]; fixture?: { path: string; sha256: string }; isolated?: boolean }; const records = new WeakMap(); -/* Emscripten's debug libc reports unimplemented syscalls on stderr, which the - * worker surfaces as a console error. __syscall_mprotect is a no-op returning - * success ("let's not and say we did", emscripten_system_stubs.c), so the line - * is runtime noise with no observable product effect. Raw text stays in the - * receipt under consoleErrors; only the assertion uses this filter. */ -const RUNTIME_STUB_NOISE = /^warning: unsupported syscall: __syscall_[a-z0-9_]+$/; -const runtimeNoise = (record: Record) => record.errors.filter(text => RUNTIME_STUB_NOISE.test(text.trim())); -const productErrors = (record: Record) => record.errors.filter(text => !RUNTIME_STUB_NOISE.test(text.trim())); +const runtimeNoise = (record: Record) => sharedRuntimeNoise(record.errors); +const productErrors = (record: Record) => sharedProductErrors(record.errors); /* Snapshots carry session bookkeeping -- revision counters on every datablock, * editor focus, window-manager region flags -- that UI actions move without * touching scene data. Scene comparisons drop those. */ diff --git a/web/tests/e2e/object-hierarchy-production.spec.ts b/web/tests/e2e/object-hierarchy-production.spec.ts index 8cd4ffe02..e6654fc30 100644 --- a/web/tests/e2e/object-hierarchy-production.spec.ts +++ b/web/tests/e2e/object-hierarchy-production.spec.ts @@ -5,6 +5,7 @@ import crypto from 'node:crypto'; import { NativeUIWorkflow, observeNative } from '../fixtures/native-ui-workflow'; import type { WebEngineRequest, WebEngineResponse, WebEngineEditCommand } from '../../protocol/web-engine'; import type { SceneSnapshotIR } from '../../protocol/scene-ir'; +import { productErrors, runtimeNoise } from '../fixtures/runtime-console'; const root = path.resolve(import.meta.dirname, '../../..'); const evidence = path.join(root, 'tests/golden/WBV2-P1424-001/object-hierarchy-20261021'); const candidate = process.env.WBV2_PRODUCTION_CANDIDATE ?? path.join(root, 'web/dist'); @@ -74,6 +75,10 @@ test('hierarchy parent and collection lifecycle in production', async ({ page, b record.states.moved = await mutate(page, () => page.getByRole('combobox', { name: '移动到 Collection' }).selectOption(archiveId)); expect(memberships(record.states.moved)).toEqual(['Archive']); await ui.save('moved'); await mutate(page, () => page.getByRole('button', { name: '撤销', exact: true }).click()); expect(memberships(await snapshot(page))).toEqual(['Archive','Parts']); await mutate(page, () => page.getByRole('button', { name: '重做', exact: true }).click()); expect(memberships(await snapshot(page))).toEqual(['Archive']); + /* Collection controls live under the 集合 property tab, which reveals the + * workbench section that the shell hides until the tab is chosen. */ + await page.getByRole('tab', { name: '集合', exact: true }).first().click(); + await expect(page.getByTestId('collection-visibility-workbench')).toBeVisible(); const collection = page.getByTestId('collection-visibility-workbench').getByRole('group', { name: 'Assembly', exact: true }); record.states.hidden = await mutate(page, () => collection.getByRole('button', { name: 'Hide Viewport', exact: true }).click()); expect(record.states.hidden.nodes.filter(node => ['RootRig','Mount','KeyLight','InspectionCamera'].includes(node.name)).every(node => !node.visible)).toBe(true); expect(record.states.hidden.nodes.find(node => node.id === ids.Payload)?.visible).toBe(true); await ui.save('hidden'); @@ -91,9 +96,9 @@ test('hierarchy parent and collection lifecycle in production', async ({ page, b const beforeReopen = canonical(await snapshot(page)); await ui.save('final'); await page.getByTestId('blend-file-input').setInputFiles(path.join(directory, 'final.blend')); await expect(page.getByTestId('engine-status')).toContainText(/SceneIR r\d+/); record.states.reopened = await snapshot(page); expect(canonical(record.states.reopened)).toEqual(beforeReopen); - expect(record.failures).toEqual([]); expect(record.consoleErrors).toEqual([]); + expect(record.failures).toEqual([]); expect(productErrors(record.consoleErrors)).toEqual([]); passed = true; } finally { - fs.writeFileSync(path.join(directory, 'receipt.json'), JSON.stringify({ ...record, passed, exitCode: passed ? 0 : 1, durationMs: Date.now()-started, testSourceSha256: sha(import.meta.filename) }, null, 2)); + fs.writeFileSync(path.join(directory, 'receipt.json'), JSON.stringify({ ...record, consoleNoise: runtimeNoise(record.consoleErrors), productConsoleErrors: productErrors(record.consoleErrors), passed, exitCode: passed ? 0 : 1, durationMs: Date.now()-started, testSourceSha256: sha(import.meta.filename) }, null, 2)); } }); diff --git a/web/tests/fixtures/native-ui-workflow.ts b/web/tests/fixtures/native-ui-workflow.ts index 50916da28..d57d06868 100644 --- a/web/tests/fixtures/native-ui-workflow.ts +++ b/web/tests/fixtures/native-ui-workflow.ts @@ -128,8 +128,10 @@ export class NativeUIWorkflow { await expect(item).toHaveAttribute("aria-selected", "true"); } async save(name: string) { - const promise = this.page.waitForEvent("download", { timeout: 10000 }); - await this.page.getByRole("button", { name: "保存项目", exact: true }).click(); + /* The OPFS save entry no longer downloads; 下载 .blend persists the same + * bytes and hands the user a local copy (OPFS rule: download is manual). */ + const promise = this.page.waitForEvent("download", { timeout: 30000 }); + await this.page.getByRole("button", { name: "下载 .blend", exact: true }).click(); const download = await promise; await download.saveAs(path.join(this.directory, `${name}.blend`)); } diff --git a/web/tests/fixtures/runtime-console.ts b/web/tests/fixtures/runtime-console.ts new file mode 100644 index 000000000..21f7c9d62 --- /dev/null +++ b/web/tests/fixtures/runtime-console.ts @@ -0,0 +1,8 @@ +/* Emscripten's debug libc reports unimplemented syscalls on stderr, which the + * worker surfaces as a console error. __syscall_mprotect is such a stub: it + * prints only in non-NDEBUG builds and returns success ("let's not and say we + * did", system/lib/libc/emscripten_syscall_stubs.c). Keep the raw text in the + * receipt (consoleErrors) and exclude only this exact shape from assertions. */ +export const RUNTIME_STUB_NOISE = /^warning: unsupported syscall: __syscall_[a-z0-9_]+$/; +export const runtimeNoise = (errors: string[]): string[] => errors.filter(text => RUNTIME_STUB_NOISE.test(text.trim())); +export const productErrors = (errors: string[]): string[] => errors.filter(text => !RUNTIME_STUB_NOISE.test(text.trim()));