Checkpoint web parity through Chromium input tasks
This commit is contained in:
33
web/tests/e2e/script-save-reopen.spec.ts
Normal file
33
web/tests/e2e/script-save-reopen.spec.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
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")));
|
||||
});
|
||||
Reference in New Issue
Block a user