Files
workinf_Blender_Wasm/web/tests/e2e/wbv2-modifier-production.spec.ts
mes123456 d436f268f0
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Complete WBV2 feature parity evidence epoch
2026-08-27 23:08:13 +08:00

65 lines
4.7 KiB
TypeScript

import { expect, test } from "@playwright/test";
import fs from "node:fs";
import path from "node:path";
const evidenceRoot = path.resolve(import.meta.dirname, "../../../tests/golden/WBV2-P9-002");
test("WBV2-P9-002 production Chromium Modifier receipt is exact and fail-closed", async ({ page }) => {
await page.goto("/");
const report = await page.evaluate(async () => {
const { CorrectiveHistoryStore, createModifierMain, createModifierRegistry } = await import("/src/corrective-pilot-bridge.ts");
const fixture = [{ uuid: "modifier:bevel", name: "Pilot Bevel", type: "BEVEL", enabled: false, showViewport: true, showRender: true }];
const command = (overrides = {}) => ({
schemaVersion: 1,
requestId: "wbv2-p9-002-modifier-enabled",
commandType: "modifierSetEnabled",
baseRevision: 7,
context: { mainId: "main:wbv2-p9-002", targetKind: "MODIFIER", targetId: "modifier:bevel", editMode: "EDITABLE", authorization: "USER_EDIT", source: { kind: "LOCAL", sha256: "a".repeat(64) } },
payload: { modifierUuid: "modifier:bevel", enabled: true },
...overrides,
});
const clone = (value) => ({ modifiers: value.modifiers.map((modifier) => ({ ...modifier })) });
const desktopMain = createModifierMain(fixture, 7, false);
const wasmMain = createModifierMain(fixture, 7, false);
const desktop = await createModifierRegistry(desktopMain).dispatch("DESKTOP", { command: command(), mainRevision: 7 });
const wasm = await createModifierRegistry(wasmMain).dispatch("WASM", { command: command(), mainRevision: 7 });
const rollbackMain = createModifierMain(fixture, 7, false);
const rollbackRegistry = createModifierRegistry(rollbackMain);
const malformed = await rollbackRegistry.dispatch("DESKTOP", { command: command({ payload: { modifierUuid: "modifier:bevel", enabled: true, unexpected: true } }), mainRevision: 7 });
const stale = await rollbackRegistry.dispatch("WASM", { command: command({ baseRevision: 6 }), mainRevision: 7 });
const unknown = await rollbackRegistry.dispatch("DESKTOP", { command: command({ payload: { modifierUuid: "modifier:missing", enabled: true } }), mainRevision: 7 });
const history = new CorrectiveHistoryStore({ modifiers: fixture }, 7, false, clone);
await createModifierRegistry(history).dispatch("WASM", { command: command(), mainRevision: 7 });
const saved = history.save();
const postSave = await createModifierRegistry(history).dispatch("DESKTOP", { command: command({ requestId: "wbv2-p9-002-modifier-post-save", baseRevision: 8, payload: { modifierUuid: "modifier:bevel", enabled: false } }), mainRevision: 8 });
const beforeReopen = history.snapshot();
history.reopen();
const reopened = history.snapshot();
return {
fixture,
positive: { desktop: desktop.result, wasm: wasm.result, desktopMain: desktopMain.snapshot(), wasmMain: wasmMain.snapshot(), parity: JSON.stringify(desktop.result) === JSON.stringify(wasm.result) && JSON.stringify(desktopMain.snapshot()) === JSON.stringify(wasmMain.snapshot()) },
negative: { malformed: malformed.result, stale: stale.result, unknown: unknown.result, rollbackMain: rollbackMain.snapshot() },
persistence: { saved, postSave: postSave.result, beforeReopen, reopened, exact: JSON.stringify(saved) === JSON.stringify(reopened) },
};
});
fs.mkdirSync(evidenceRoot, { recursive: true });
const output = process.env.WBV2_MODIFIER_PRODUCTION_REPORT ?? "chromium-modifier-production.json";
fs.writeFileSync(path.join(evidenceRoot, output), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P9-002", operation: "MODIFIER_PRODUCTION_CHROMIUM", browser: "chromium", queueMutation: false, ...report }, null, 2)}\n`);
expect(report.positive.parity).toBe(true);
expect(report.positive.desktop.status).toBe("FINISHED");
expect(report.positive.wasm.status).toBe("FINISHED");
expect(report.positive.desktop.delta).toEqual({ modifierUuid: "modifier:bevel", previousEnabled: false, enabled: true });
expect(report.positive.desktop.mainRevisionBefore).toBe(7);
expect(report.positive.desktop.mainRevisionAfter).toBe(8);
expect(report.positive.wasm).toEqual(report.positive.desktop);
expect(report.persistence.exact).toBe(true);
expect(report.persistence.reopened).toEqual(report.persistence.saved);
expect(report.negative.malformed.code).toBe("COMMAND_MALFORMED");
expect(report.negative.stale.code).toBe("REVISION_CONFLICT");
expect(report.negative.unknown.code).toBe("COMMAND_UNSUPPORTED");
expect(report.negative.rollbackMain).toEqual({ value: { modifiers: [{ uuid: "modifier:bevel", name: "Pilot Bevel", type: "BEVEL", enabled: false, showViewport: true, showRender: true }] }, revision: 7, dirty: false });
});