Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer, web workflow engine and protocol, tooling, docs and task records. Large generated evidence, user-testing archives, build snapshots and imported test assets remain untracked. Co-Authored-By: Claude Code <noreply@anthropic.com>
65 lines
5.2 KiB
TypeScript
65 lines
5.2 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 fixturePath = path.join(root, "tests/files/web/generated/M16-GAP-00161-operator-anim.channels_group.blend");
|
|
const fixture = fs.readFileSync(fixturePath);
|
|
const fixtureSha256 = crypto.createHash("sha256").update(fixture).digest("hex");
|
|
|
|
test("WBV2 ActionGroup reader preserves Blender Main group metadata through recovery and 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 digestInPage = async (bytes: ArrayBuffer) => Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", bytes)), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
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");
|
|
return {
|
|
animationId: animation?.id,
|
|
groups: [...new Set((animation?.channels ?? []).map((channel: any) => channel.group).filter(Boolean))],
|
|
expanded: (animation?.channels ?? []).map((channel: any) => channel.expanded),
|
|
strips: (animation?.strips ?? []).map((strip: any) => ({ name: strip.name, type: strip.type, frameStart: strip.frameStart, frameEnd: strip.frameEnd, dataIndex: strip.dataIndex })),
|
|
channels: (animation?.channels ?? []).map((channel: any) => ({ path: channel.path, group: channel.group, expanded: channel.expanded, frames: channel.keyframes.map((keyframe: any) => keyframe.frame) })),
|
|
};
|
|
};
|
|
try {
|
|
const opened = await client.openBlend(Uint8Array.from(input.bytes).buffer);
|
|
const before = summarize(opened.snapshot);
|
|
if (before.groups.length !== 1 || before.groups[0] !== "WebGapTransforms" || before.channels.length !== 3 || before.strips.length !== 1 || before.strips[0].type !== "KEYFRAME") throw new Error("ActionGroup source reader metadata missing");
|
|
const edited = await client.applyCommand({ type: "setFCurveInterpolation", animationId: before.animationId, path: "location[0]", interpolation: "LINEAR", baseRevision: opened.snapshot.revision } 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: await digestInPage(saved.slice(0)) };
|
|
}
|
|
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.join(root, "tests/golden/WBV2-P1140-001"), { recursive: true });
|
|
fs.writeFileSync(path.join(root, "tests/golden/WBV2-P1140-001/action-group-reader-production.json"), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P1140-001", operation: "ACTION_GROUP_READER_MAIN_CHROMIUM", browser: "chromium", queueMutation: false, sourceRnaStructs: { "rna-struct:ActionGroup": "animations[].channels[].group + animations[].channels[].expanded", "rna-struct:ActionChannelbagFCurves": "animations[].channels[]", "rna-struct:ActionChannelbagGroups": "animations[].channels[].group", "rna-struct:ActionSlots": "animations[].slots[]", "rna-struct:ActionStrips": "animations[].strips[]", "rna-struct:ActionStrip": "animations[].strips[]" }, ...result }, null, 2)}\n`);
|
|
expect(result.error).toBeUndefined();
|
|
expect(result.fixtureSha256).toBe(fixtureSha256);
|
|
expect(result.before.groups).toEqual(["WebGapTransforms"]);
|
|
expect(result.before.channels).toHaveLength(3);
|
|
expect(result.before.strips).toEqual([{ name: "", type: "KEYFRAME", frameStart: 1, frameEnd: 5, dataIndex: 0 }]);
|
|
expect(result.editedRevision).toBe(result.openedRevision + 1);
|
|
expect(result.undo).toBeDefined();
|
|
expect(result.redo).toBeDefined();
|
|
expect(result.afterRedo.groups).toEqual(result.before.groups);
|
|
expect(result.afterRedo.expanded).toEqual(result.before.expanded);
|
|
expect(result.afterRedo.strips).toEqual(result.before.strips);
|
|
expect(result.malformed.code).not.toBe("NO_ERROR");
|
|
expect(result.reopened.groups).toEqual(result.before.groups);
|
|
expect(result.reopened.strips).toEqual(result.before.strips);
|
|
expect(result.reopened.channels).toEqual(result.before.channels);
|
|
expect(result.savedSha256).not.toBe(fixtureSha256);
|
|
});
|