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>
36 lines
4.2 KiB
TypeScript
36 lines
4.2 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import crypto from "node:crypto";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
const root = path.resolve(import.meta.dirname, "../../..");
|
|
const fixture = fs.readFileSync(path.join(root, "tests/files/web/generated/WBV2-P24-001-OBJECT_OPERATIONS.MOVE_COLLECTION.blend"));
|
|
const fixtureSha256 = crypto.createHash("sha256").update(fixture).digest("hex");
|
|
|
|
test("WBV2-P24-002 binds moveObjectToCollection to compiled WASM Main", async ({ page }) => {
|
|
test.setTimeout(120_000); await page.goto("/");
|
|
const result = await page.evaluate(async (bytes) => {
|
|
const { WebEngineClient } = await import("/src/engine-client/WebEngineClient.ts");
|
|
const client = new WebEngineClient({ timeoutMs: 30_000 }); const reopened = new WebEngineClient({ timeoutMs: 30_000 });
|
|
try {
|
|
const opened = await client.openBlend(Uint8Array.from(bytes).buffer);
|
|
const source = opened.snapshot.collections.find((collection) => collection.name === "SourceCollection");
|
|
const target = opened.snapshot.collections.find((collection) => collection.name === "MoveTargetCollection");
|
|
const object = opened.snapshot.nodes.find((node) => node.name === "WBV2P2401Cube");
|
|
if (!source || !target || !object) throw new Error("move fixture missing source, target, or object");
|
|
const baseRevision = opened.snapshot.revision;
|
|
const changed = await client.applyCommand({ type: "moveObjectToCollection", objectId: object.id, collectionId: target.id } as any);
|
|
const moved = changed.snapshot.collections.find((collection) => collection.id === target.id);
|
|
const undone = await client.applyCommand({ type: "undo" }); const redone = await client.applyCommand({ type: "redo" });
|
|
const malformed = await client.applyCommand({ type: "moveObjectToCollection", objectId: object.id, collectionId: "collection:missing" } 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 reopen = await reopened.openBlend(saved);
|
|
const reopenedTarget = reopen.snapshot.collections.find((collection) => collection.id === target.id);
|
|
const reopenedSource = reopen.snapshot.collections.find((collection) => collection.id === source.id);
|
|
return { browser: "chromium", baseRevision, objectId: object.id, sourceId: source.id, targetId: target.id, beforeSourceHasObject: source.objectIds.includes(object.id), movedTargetHasObject: moved?.objectIds.includes(object.id), changedRevision: changed.snapshot.revision, undoRevision: undone.snapshot.revision, redoRevision: redone.snapshot.revision, malformed, malformedRevisionPreserved: afterMalformed.snapshot.revision === redone.snapshot.revision, reopenedTargetHasObject: reopenedTarget?.objectIds.includes(object.id), reopenedSourceHasObject: reopenedSource?.objectIds.includes(object.id), reopenedRevision: reopen.snapshot.revision, savedSha256: await (async (value) => { const hash = await crypto.subtle.digest("SHA-256", value); return Array.from(new Uint8Array(hash), (byte) => byte.toString(16).padStart(2, "0")).join(""); })(saved) };
|
|
} finally { client.terminate(); reopened.terminate(); }
|
|
}, Array.from(fixture));
|
|
fs.mkdirSync(path.join(root, "tests/golden/WBV2-P24-002"), { recursive: true }); const output = process.env.WBV2_MOVE_REPORT ?? "object-move-production.json";
|
|
fs.writeFileSync(path.join(root, "tests/golden/WBV2-P24-002", output), `${JSON.stringify({ schemaVersion: 1, task: "WBV2-P24-002", operation: "OBJECT_MOVE_COLLECTION_ENGINE_CHROMIUM", queueMutation: false, fixtureSha256, ...result }, null, 2)}\n`);
|
|
expect(result.browser).toBe("chromium"); expect(result.beforeSourceHasObject).toBe(true); expect(result.movedTargetHasObject).toBe(true); expect(result.changedRevision).toBe(result.baseRevision + 1); expect(result.undoRevision).toBe(result.baseRevision + 2); expect(result.redoRevision).toBe(result.baseRevision + 3); expect(result.malformed.code).not.toBe("NO_ERROR"); expect(result.malformedRevisionPreserved).toBe(true); expect(result.reopenedTargetHasObject).toBe(true); expect(result.reopenedSourceHasObject).toBe(false); expect(result.reopenedRevision).toBe(1);
|
|
});
|