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>
54 lines
5.4 KiB
TypeScript
54 lines
5.4 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/animation_scene.blend"));
|
|
const fixtureSha256 = crypto.createHash("sha256").update(fixture).digest("hex");
|
|
|
|
test("WBV2-P1112-000 preserves active Action and keyframe deletion Main commands", 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 keyframes = (snapshot: any, actionId: string) => snapshot.animations?.find((animation: any) => animation.id === actionId)?.channels?.flatMap((channel: any) => channel.keyframes.map((keyframe: any) => ({ path: channel.path, frame: keyframe.frame })));
|
|
try {
|
|
const opened = await client.openBlend(Uint8Array.from(input.bytes).buffer);
|
|
const object = opened.snapshot.nodes.find((node: any) => node.id === "object:AnimatedObject");
|
|
const action = opened.snapshot.animations?.find((candidate: any) => candidate.targetId === object?.id);
|
|
if (!object || !action) throw new Error("animation fixture has no active object/action");
|
|
const before = keyframes(opened.snapshot, action.id);
|
|
const slots = action.slots ?? [];
|
|
if (!Array.isArray(slots) || slots.some((slot: any) => typeof slot.identifier !== "string" || !Number.isInteger(slot.idtype) || !Number.isInteger(slot.handle) || !Number.isInteger(slot.flags))) throw new Error("animation action slots are not source-backed records");
|
|
const unassigned = await client.applyCommand({ type: "setActiveAction", objectId: object.id, actionId: null } as any);
|
|
const reassigned = await client.applyCommand({ type: "setActiveAction", objectId: object.id, actionId: action.id } as any);
|
|
const inserted = await client.applyCommand({ type: "insertObjectKeyframe", objectId: object.id, frame: 5, property: "LOCATION", interpolation: "BEZIER" } as any);
|
|
const deleted = await client.applyCommand({ type: "deleteObjectKeyframe", objectId: object.id, frame: 5, property: "LOCATION" } as any);
|
|
const malformed = await client.applyCommand({ type: "deleteObjectKeyframe", objectId: object.id, frame: 999, property: "LOCATION" } as any).then(() => ({ code: "NO_ERROR" })).catch((error: any) => ({ code: error?.code, message: error?.message }));
|
|
const afterMalformed = await client.snapshot();
|
|
const saved = await client.saveBlend();
|
|
const reopened = await reopenedClient.openBlend(saved.slice(0));
|
|
return { fixtureSha256: input.fixtureSha256, objectId: object.id, actionId: action.id, slots, before, unassigned: keyframes(unassigned.snapshot, action.id), reassigned: keyframes(reassigned.snapshot, action.id), inserted: keyframes(inserted.snapshot, action.id), deleted: keyframes(deleted.snapshot, action.id), malformed, malformedRevisionPreserved: afterMalformed.snapshot.revision === deleted.snapshot.revision, reopened: keyframes(reopened.snapshot, action.id), reopenedSlots: reopened.snapshot.animations?.find((candidate: any) => candidate.id === action.id)?.slots ?? [], revisions: [opened.snapshot.revision, unassigned.snapshot.revision, reassigned.snapshot.revision, inserted.snapshot.revision, deleted.snapshot.revision], reopenedRevision: reopened.snapshot.revision, savedSha256: await crypto.subtle.digest("SHA-256", saved).then((hash) => Array.from(new Uint8Array(hash), (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.join(root, "tests/golden/WBV2-P1112-000"), { recursive: true });
|
|
fs.writeFileSync(path.join(root, "tests/golden/WBV2-P1112-000/animation-action-production.json"), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P1112-000", operation: "ANIMATION_ACTION_KEYFRAME_MAIN_CHROMIUM", browser: "chromium", queueMutation: false, sourceRnaStructs: { "rna-struct:ActionLayers": "animations[].channels", "rna-struct:ActionLayer": "animations[].channels", "rna-struct:ActionKeyframeStrip": "animations[].channels", "rna-struct:ActionChannelbags": "animations[].channels", "rna-struct:ActionChannelbag": "animations[].channels", "rna-struct:ActionSlot": "animations[].slots[]" }, ...result }, null, 2)}\n`);
|
|
expect(result.error).toBeUndefined();
|
|
expect(result.fixtureSha256).toBe(fixtureSha256);
|
|
expect(Array.isArray(result.slots)).toBe(true);
|
|
expect(result.reopenedSlots).toEqual(result.slots);
|
|
expect(result.revisions).toEqual([result.revisions[0], result.revisions[0] + 1, result.revisions[0] + 2, result.revisions[0] + 3, result.revisions[0] + 4]);
|
|
expect(result.inserted.some((keyframe: any) => keyframe.frame === 5)).toBe(true);
|
|
expect(result.deleted.some((keyframe: any) => keyframe.frame === 5)).toBe(false);
|
|
expect(result.malformed.code).not.toBe("NO_ERROR");
|
|
expect(result.malformedRevisionPreserved).toBe(true);
|
|
expect(result.reopened).toEqual(result.deleted);
|
|
expect(result.reopenedRevision).toBe(1);
|
|
expect(result.savedSha256).not.toBe(fixtureSha256);
|
|
});
|