chore(web): continuous handoff WBV2-P1267-001
This commit is contained in:
57
web/tests/e2e/wbv2-fcurve-sample-production.spec.ts
Normal file
57
web/tests/e2e/wbv2-fcurve-sample-production.spec.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
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 fixturePath = process.env.WBV2_BATCH_FIXTURE ?? "tests/files/web/generated/M16-GAP-00161-action-fcurve-samples.blend";
|
||||
const fixture = fs.readFileSync(path.join(root, fixturePath));
|
||||
const fixtureSha256 = crypto.createHash("sha256").update(fixture).digest("hex");
|
||||
const task = process.env.WBV2_BATCH_TASK ?? "WBV2-P1142-001";
|
||||
const productionPath = process.env.WBV2_BATCH_PRODUCTION ?? `tests/golden/${task}/fcurve-sample-production.json`;
|
||||
const sourceUnits = JSON.parse(process.env.WBV2_BATCH_UNITS ?? "[\"rna-struct:FCurveSample\"]") as string[];
|
||||
|
||||
test("WBV2 sampled FCurve data is read from Blender Main and survives recovery/reopen", async ({ page }) => {
|
||||
test.setTimeout(180_000);
|
||||
await page.goto("/");
|
||||
const result = await page.evaluate(async (input) => {
|
||||
const { WebEngineClient } = await import("/src/engine-client/WebEngineClient.ts");
|
||||
const client = new WebEngineClient({ timeoutMs: 60_000 });
|
||||
const reopenedClient = new WebEngineClient({ timeoutMs: 60_000 });
|
||||
const summarize = (snapshot: any) => {
|
||||
const animation = snapshot.animations?.find((entry: any) => entry.targetId === "object:WebGapAnimChannelsGroupObject");
|
||||
const channel = animation?.channels?.find((entry: any) => entry.path === "location[0]");
|
||||
return { animationId: animation?.id, keyframeSource: channel?.keyframeSource, frames: channel?.keyframes?.map((keyframe: any) => keyframe.frame), values: channel?.keyframes?.map((keyframe: any) => keyframe.value?.[0]), channelCount: animation?.channels?.length ?? 0 };
|
||||
};
|
||||
try {
|
||||
const opened = await client.openBlend(Uint8Array.from(input.bytes).buffer);
|
||||
const before = summarize(opened.snapshot);
|
||||
if (before.keyframeSource !== "SAMPLED" || before.frames?.length !== 4) throw new Error("sampled FCurve source reader data missing");
|
||||
const edited = await client.applyCommand({ type: "setFrame", frame: 3 } as any);
|
||||
const undo = await client.callJson<any>("undo");
|
||||
const redo = await client.callJson<any>("redo");
|
||||
const afterRedo = summarize((await client.snapshot()).snapshot);
|
||||
const malformed = await client.openBlend(Uint8Array.from([0x42, 0x4c, 0x45, 0x4e, 0x44]).buffer).then(() => ({ code: "NO_ERROR" })).catch((error: any) => ({ code: error?.code, message: error?.message }));
|
||||
const saved = await client.saveBlend();
|
||||
const reopened = await reopenedClient.openBlend(saved.slice(0));
|
||||
return { fixtureSha256: input.fixtureSha256, before, edited: summarize(edited.snapshot), undo: undo.result, redo: redo.result, afterRedo, malformed, reopened: summarize(reopened.snapshot), openedRevision: opened.snapshot.revision, editedRevision: edited.snapshot.revision, savedSha256: Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", saved.slice(0))), (byte) => byte.toString(16).padStart(2, "0")).join("") };
|
||||
}
|
||||
catch (error: any) { return { error: { code: error?.code, message: error?.message, detail: String(error) } } as any; }
|
||||
finally { client.terminate(); reopenedClient.terminate(); }
|
||||
}, { bytes: Array.from(fixture), fixtureSha256 });
|
||||
|
||||
fs.mkdirSync(path.dirname(path.join(root, productionPath)), { recursive: true });
|
||||
fs.writeFileSync(path.join(root, productionPath), `${JSON.stringify({ schemaVersion: 1, task, operation: "FCURVE_SAMPLE_READER_MAIN_CHROMIUM", browser: "chromium", queueMutation: false, fixture: fixturePath, fixtureSha256, sourceUnits, sourceRnaStructs: { "rna-struct:FCurveSample": "animations[].channels[].keyframes[] where keyframeSource=SAMPLED" }, ...result }, null, 2)}\n`);
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.fixtureSha256).toBe(fixtureSha256);
|
||||
expect(result.before.keyframeSource).toBe("SAMPLED");
|
||||
expect(result.before.frames).toEqual([1, 2, 3, 4]);
|
||||
expect(result.before.values).toEqual([0, 0.625, 2, 3.375]);
|
||||
expect(result.editedRevision).toBe(result.openedRevision + 1);
|
||||
expect(result.undo).toBeDefined();
|
||||
expect(result.redo).toBeDefined();
|
||||
expect(result.afterRedo).toEqual(result.before);
|
||||
expect(result.malformed.code).not.toBe("NO_ERROR");
|
||||
expect(result.reopened).toEqual(result.before);
|
||||
expect(result.savedSha256).not.toBe(fixtureSha256);
|
||||
});
|
||||
Reference in New Issue
Block a user