Files
workinf_Blender_Wasm/web/tests/e2e/asset-catalog-restart.spec.ts
mes123456 63db6caf1f
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
feat(web): studio worlds, camera-view/offscreen environment parity, material and undo coverage
Environment lighting:
- ship all eight desktop studiolights/world datasets (WBENV1 float32) and a
  shared loader used by both the main viewport and the offscreen worker
- add the N-panel "studio 环境" selector
- rotate the world background together with the environment
  (backgroundRotation/backgroundIntensity), so camera view and offscreen
  renders match the desktop Mapping-node behaviour

Verification (Chromium, OPFS, NOT_CLAIMED):
- environment lighting + 8 world pixel identity
- camera-view rotation correspondence (camera matrices, 207 samples)
- offscreen vs on-screen background parity after hiding geometry (1305 samples)
- metals case extended with material-field OPFS roundtrip
- material Principled edits and rename undo/redo
- eight studio worlds: pairwise frame differences + luminance rank correlation
- undo history depth capped at 64 steps and undo across OPFS save/reopen

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 09:27:47 +08:00

82 lines
3.7 KiB
TypeScript

import { expect, test } from "@playwright/test";
import fs from "node:fs";
import path from "node:path";
const fixture = JSON.parse(fs.readFileSync(
path.resolve(import.meta.dirname, "../../../tests/golden/M12-01D/catalog-v1.json"),
"utf8",
)) as unknown;
test("M12-01H preserves catalog order and asset identity across page and Worker restarts", async ({ page }) => {
await page.goto("/");
const databaseName = `m12-01h-${Date.now()}`;
const baseline = await page.evaluate(async ({ databaseName, source }) => {
const storage = await import("/src/storage/asset-catalog-indexeddb.ts");
const { openKvDatabase } = await import("/src/storage/opfs-kv.ts");
const database = await openKvDatabase(databaseName, ["setting", "migration"]);
const transaction = database.transaction("setting", "readwrite");
transaction.objectStore("setting").put({ id: storage.ASSET_CATALOG_INDEX_V1_ID, value: source });
await new Promise<void>((resolve, reject) => {
transaction.oncomplete = () => resolve();
transaction.onerror = () => reject(transaction.error);
transaction.onabort = () => reject(transaction.error);
});
const snapshot = await storage.loadAssetCatalogIndexedDBSnapshot(database);
database.close();
return snapshot;
}, { databaseName, source: fixture });
await page.reload();
const pageRestart = await page.evaluate(async (name) => {
const storage = await import("/src/storage/asset-catalog-indexeddb.ts");
const { openKvDatabase } = await import("/src/storage/opfs-kv.ts");
const database = await openKvDatabase(name, ["setting", "migration"]);
const snapshot = await storage.loadAssetCatalogIndexedDBSnapshot(database);
database.close();
return snapshot;
}, databaseName);
const workerSnapshot = async () => page.evaluate((name) => new Promise<unknown>((resolve, reject) => {
const worker = new Worker("/src/workers/asset-catalog-restart-test.worker.ts", { type: "module" });
worker.onmessage = (event) => {
worker.terminate();
event.data.ok ? resolve(event.data.snapshot) : reject(new Error(event.data.error));
};
worker.onerror = (event) => { worker.terminate(); reject(new Error(event.message)); };
worker.postMessage({ databaseName: name });
}), databaseName);
const firstWorker = await workerSnapshot();
const secondWorker = await workerSnapshot();
expect(pageRestart).toEqual(baseline);
expect(firstWorker).toEqual(baseline);
expect(secondWorker).toEqual(baseline);
expect(baseline).toEqual({
schemaVersion: 1,
revision: 7,
manifestSha256: "0c08ed1af1dd0998c809f76d969fd21d8fdae28ad37cf5571bdc99b16bf3ec90",
catalogOrder: [
{ catalogId: "44444444-4444-4444-8444-444444444444", path: "Animation" },
{ catalogId: "fe3ca14c-95d7-549f-a13b-1bb4c07b6074", path: "Characters" },
{ catalogId: "b4bb3608-9267-5aba-bb9e-9e97b006d5ab", path: "Characters/Heroes" },
],
assetOrder: [
"asset:ac88c6147ada877adccf4df8ca54d64e1a9cb50a13514212f6d19b1da1660f8d",
"asset:bb91ef0dddf69bb7d87dd4217a01e7f549b50ad628db0367d3896c6840b3a326",
],
assetIdentities: [
{
assetId: "asset:ac88c6147ada877adccf4df8ca54d64e1a9cb50a13514212f6d19b1da1660f8d",
assetLibraryIdentifier: null,
relativeAssetIdentifier: "Action/Legacy Walk",
},
{
assetId: "asset:bb91ef0dddf69bb7d87dd4217a01e7f549b50ad628db0367d3896c6840b3a326",
assetLibraryIdentifier: null,
relativeAssetIdentifier: "Object/Legacy Hero",
},
],
});
await page.evaluate(async (name) => { const kv = await (await navigator.storage.getDirectory()).getDirectoryHandle("_kv_v1"); await kv.removeEntry(name, { recursive: true }); }, databaseName);
});