Files
workinf_Blender_Wasm/web/tests/e2e/script-save-reopen.spec.ts
mes123456 380cbed4ff
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
Checkpoint web parity through Chromium input tasks
2026-08-19 10:39:03 -04:00

34 lines
2.1 KiB
TypeScript

import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { expect, test } from "@playwright/test";
const root = path.resolve(import.meta.dirname, "../../..");
const fixture = fs.readFileSync(path.join(root, "tests/files/web/script_scene.blend"));
const reportPath = path.join(root, "tests/golden/M13-01E/script-save-reopen-report.json");
const sha256 = (bytes: Uint8Array | Buffer) => crypto.createHash("sha256").update(bytes).digest("hex");
test("M13-01E preserves Text sources through save and reopen", async ({ page }) => {
await page.goto("/");
const result = await page.evaluate(async (bytes) => {
const { WebEngineClient } = await import("/src/engine-client/WebEngineClient.ts");
const first = new WebEngineClient({ timeoutMs: 30_000 });
const opened = await first.openBlend(Uint8Array.from(bytes).buffer);
const before = opened.snapshot.scriptSources;
const saved = await first.saveBlend();
const savedBytes = saved.byteLength;
first.terminate();
const second = new WebEngineClient({ timeoutMs: 30_000 });
const reopened = await second.openBlend(saved);
const after = reopened.snapshot.scriptSources;
second.terminate();
return { before, after, savedBytes };
}, Array.from(fixture));
expect(result.before?.sources).toHaveLength(3);
expect(result.after?.sources).toEqual(result.before?.sources);
expect(result.after?.sources.every((source: any) => source.readOnly && source.executionStatus === "BLOCKED")).toBe(true);
const report = { schemaVersion: 1, task: "M13-01E", operation: "SCRIPT_TEXT_SAVE_REOPEN", source: { fixtureSha256: sha256(fixture), fixtureBytes: fixture.byteLength }, before: result.before, after: result.after, savedBytes: result.savedBytes, exact: JSON.stringify(result.before) === JSON.stringify(result.after), nextTask: "M13-01F" };
if (process.env.UPDATE_SCRIPT_SAVE_REOPEN_REPORT === "1") { fs.mkdirSync(path.dirname(reportPath), { recursive: true }); fs.writeFileSync(reportPath, JSON.stringify(report, null, 2) + "\n"); }
expect(report).toEqual(JSON.parse(fs.readFileSync(reportPath, "utf8")));
});