2026-04-10 12:24:54 +02:00
|
|
|
import path from "node:path";
|
|
|
|
|
import { readFile } from "node:fs/promises";
|
|
|
|
|
|
2026-04-10 12:33:09 +02:00
|
|
|
import { strToU8, unzipSync, Zip, ZipDeflate } from "fflate";
|
2026-04-10 12:24:54 +02:00
|
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
|
|
|
|
|
|
|
import { loadAudioAssetFromStorage } from "../../src/assets/audio-assets";
|
2026-04-11 04:19:50 +02:00
|
|
|
import {
|
|
|
|
|
loadModelAssetFromStorage,
|
|
|
|
|
importModelAssetFromFiles
|
|
|
|
|
} from "../../src/assets/gltf-model-import";
|
2026-04-10 12:24:54 +02:00
|
|
|
import { loadImageAssetFromStorage } from "../../src/assets/image-assets";
|
|
|
|
|
import { createModelInstance } from "../../src/assets/model-instances";
|
2026-04-11 04:19:50 +02:00
|
|
|
import {
|
|
|
|
|
createInMemoryProjectAssetStorage,
|
|
|
|
|
type ProjectAssetStorage
|
|
|
|
|
} from "../../src/assets/project-asset-storage";
|
|
|
|
|
import {
|
|
|
|
|
createProjectAssetStorageKey,
|
|
|
|
|
type AudioAssetRecord,
|
|
|
|
|
type ImageAssetRecord
|
|
|
|
|
} from "../../src/assets/project-assets";
|
2026-04-11 03:51:35 +02:00
|
|
|
import {
|
|
|
|
|
createEmptyProjectScene,
|
|
|
|
|
createEmptySceneDocument,
|
|
|
|
|
createProjectDocumentFromSceneDocument
|
|
|
|
|
} from "../../src/document/scene-document";
|
2026-04-10 12:24:54 +02:00
|
|
|
import {
|
|
|
|
|
loadProjectPackage,
|
|
|
|
|
PROJECT_PACKAGE_SCENE_PATH,
|
|
|
|
|
saveProjectPackage
|
|
|
|
|
} from "../../src/serialization/project-package";
|
2026-04-11 03:51:35 +02:00
|
|
|
import { serializeProjectDocument } from "../../src/serialization/scene-document-json";
|
2026-04-10 12:24:54 +02:00
|
|
|
|
2026-04-11 04:19:50 +02:00
|
|
|
const tinyGlbFixturePath = path.resolve(
|
|
|
|
|
process.cwd(),
|
|
|
|
|
"fixtures/assets/tiny-triangle.glb"
|
|
|
|
|
);
|
|
|
|
|
const externalTriangleGltfPath = path.resolve(
|
|
|
|
|
process.cwd(),
|
|
|
|
|
"fixtures/assets/external-triangle/scene.gltf"
|
|
|
|
|
);
|
|
|
|
|
const externalTriangleBinPath = path.resolve(
|
|
|
|
|
process.cwd(),
|
|
|
|
|
"fixtures/assets/external-triangle/triangle.bin"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
function createTestFile(
|
|
|
|
|
bytes: Uint8Array | Buffer,
|
|
|
|
|
name: string,
|
|
|
|
|
type: string
|
|
|
|
|
): File {
|
2026-04-10 12:24:54 +02:00
|
|
|
const arrayBuffer = new ArrayBuffer(bytes.byteLength);
|
|
|
|
|
new Uint8Array(arrayBuffer).set(bytes);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
name,
|
|
|
|
|
type,
|
|
|
|
|
lastModified: Date.now(),
|
|
|
|
|
size: arrayBuffer.byteLength,
|
|
|
|
|
webkitRelativePath: "",
|
|
|
|
|
arrayBuffer: async () => arrayBuffer.slice(0)
|
|
|
|
|
} as File;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 12:27:12 +02:00
|
|
|
function cloneArrayBuffer(bytes: Uint8Array): ArrayBuffer {
|
|
|
|
|
const clonedBytes = new Uint8Array(bytes.byteLength);
|
|
|
|
|
clonedBytes.set(bytes);
|
|
|
|
|
return clonedBytes.buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 12:28:13 +02:00
|
|
|
function listPackagedFiles(packageBytes: Uint8Array): string[] {
|
|
|
|
|
return Object.keys(unzipSync(packageBytes))
|
|
|
|
|
.filter((path) => !path.endsWith("/"))
|
|
|
|
|
.sort();
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 12:33:09 +02:00
|
|
|
function buildZipArchive(entries: Record<string, Uint8Array>): Uint8Array {
|
|
|
|
|
const chunks: Uint8Array[] = [];
|
|
|
|
|
const zip = new Zip((error, chunk) => {
|
|
|
|
|
if (error !== null) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (chunk !== null) {
|
|
|
|
|
chunks.push(chunk.slice(0));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (const [path, bytes] of Object.entries(entries)) {
|
|
|
|
|
const zippedFile = new ZipDeflate(path, { level: 6 });
|
|
|
|
|
zip.add(zippedFile);
|
|
|
|
|
zippedFile.push(bytes, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zip.end();
|
|
|
|
|
|
2026-04-11 04:19:50 +02:00
|
|
|
const archiveBytes = new Uint8Array(
|
|
|
|
|
chunks.reduce((sum, chunk) => sum + chunk.byteLength, 0)
|
|
|
|
|
);
|
2026-04-10 12:33:09 +02:00
|
|
|
let offset = 0;
|
|
|
|
|
|
|
|
|
|
for (const chunk of chunks) {
|
|
|
|
|
archiveBytes.set(chunk, offset);
|
|
|
|
|
offset += chunk.byteLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return archiveBytes;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-11 03:51:35 +02:00
|
|
|
function createProjectDocument(
|
|
|
|
|
document: ReturnType<typeof createEmptySceneDocument>
|
|
|
|
|
) {
|
|
|
|
|
return createProjectDocumentFromSceneDocument(document);
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 12:24:54 +02:00
|
|
|
describe("project package serialization", () => {
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
vi.restoreAllMocks();
|
|
|
|
|
vi.unstubAllGlobals();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("round-trips an asset-free scene through a .we3d package", async () => {
|
2026-04-11 03:51:35 +02:00
|
|
|
const document = createProjectDocument(
|
|
|
|
|
createEmptySceneDocument({ name: "Portable Empty Scene" })
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const packageBytes = await saveProjectPackage(document, null);
|
|
|
|
|
const restoredDocument = await loadProjectPackage(packageBytes, null);
|
|
|
|
|
|
|
|
|
|
expect(restoredDocument).toEqual(document);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("round-trips multiple scenes through a .we3d package", async () => {
|
|
|
|
|
const document = {
|
|
|
|
|
...createProjectDocument(
|
|
|
|
|
createEmptySceneDocument({ name: "Portable Entry" })
|
|
|
|
|
),
|
2026-04-11 13:26:46 +02:00
|
|
|
name: "Portable Campaign",
|
2026-04-11 03:51:35 +02:00
|
|
|
activeSceneId: "scene-dungeon",
|
|
|
|
|
scenes: {
|
2026-04-11 03:52:54 +02:00
|
|
|
"scene-main": createEmptyProjectScene({
|
2026-04-11 03:51:35 +02:00
|
|
|
id: "scene-main",
|
|
|
|
|
name: "Portable Entry"
|
|
|
|
|
}),
|
2026-04-11 03:52:54 +02:00
|
|
|
"scene-dungeon": createEmptyProjectScene({
|
2026-04-11 03:51:35 +02:00
|
|
|
id: "scene-dungeon",
|
2026-04-11 04:18:26 +02:00
|
|
|
name: "Portable Dungeon",
|
|
|
|
|
loadingScreen: {
|
|
|
|
|
colorHex: "#1f2d42",
|
|
|
|
|
headline: "Heading underground",
|
|
|
|
|
description: "Preparing dungeon encounter state."
|
|
|
|
|
}
|
2026-04-11 03:51:35 +02:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
};
|
2026-04-10 12:24:54 +02:00
|
|
|
|
|
|
|
|
const packageBytes = await saveProjectPackage(document, null);
|
|
|
|
|
const restoredDocument = await loadProjectPackage(packageBytes, null);
|
|
|
|
|
|
|
|
|
|
expect(restoredDocument).toEqual(document);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("round-trips bundled model, image, and audio assets through project storage", async () => {
|
|
|
|
|
const glbBytes = await readFile(tinyGlbFixturePath);
|
|
|
|
|
const storage = createInMemoryProjectAssetStorage();
|
|
|
|
|
const importedModel = await importModelAssetFromFiles(
|
|
|
|
|
[createTestFile(glbBytes, "tiny-triangle.glb", "model/gltf-binary")],
|
|
|
|
|
storage
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const imageAsset = {
|
|
|
|
|
id: "asset-image-panorama",
|
|
|
|
|
kind: "image",
|
|
|
|
|
sourceName: "panorama.svg",
|
|
|
|
|
mimeType: "image/svg+xml",
|
|
|
|
|
storageKey: createProjectAssetStorageKey("asset-image-panorama"),
|
|
|
|
|
byteLength: 118,
|
|
|
|
|
metadata: {
|
|
|
|
|
kind: "image",
|
|
|
|
|
width: 1024,
|
|
|
|
|
height: 512,
|
|
|
|
|
hasAlpha: false,
|
|
|
|
|
warnings: []
|
|
|
|
|
}
|
|
|
|
|
} satisfies ImageAssetRecord;
|
|
|
|
|
const audioAsset = {
|
|
|
|
|
id: "asset-audio-loop",
|
|
|
|
|
kind: "audio",
|
|
|
|
|
sourceName: "loop.ogg",
|
|
|
|
|
mimeType: "audio/ogg",
|
|
|
|
|
storageKey: createProjectAssetStorageKey("asset-audio-loop"),
|
|
|
|
|
byteLength: 4,
|
|
|
|
|
metadata: {
|
|
|
|
|
kind: "audio",
|
|
|
|
|
durationSeconds: 2.5,
|
|
|
|
|
channelCount: 2,
|
|
|
|
|
sampleRateHz: 44100,
|
|
|
|
|
warnings: []
|
|
|
|
|
}
|
|
|
|
|
} satisfies AudioAssetRecord;
|
|
|
|
|
|
|
|
|
|
await storage.putAsset(imageAsset.storageKey, {
|
|
|
|
|
files: {
|
|
|
|
|
[imageAsset.sourceName]: {
|
2026-04-11 04:19:50 +02:00
|
|
|
bytes: cloneArrayBuffer(
|
|
|
|
|
strToU8(
|
|
|
|
|
'<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="512"></svg>'
|
|
|
|
|
)
|
|
|
|
|
),
|
2026-04-10 12:24:54 +02:00
|
|
|
mimeType: imageAsset.mimeType
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
await storage.putAsset(audioAsset.storageKey, {
|
|
|
|
|
files: {
|
|
|
|
|
[audioAsset.sourceName]: {
|
|
|
|
|
bytes: new Uint8Array([1, 2, 3, 4]).buffer,
|
|
|
|
|
mimeType: audioAsset.mimeType
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-11 04:19:50 +02:00
|
|
|
const imageLoadListeners = new WeakMap<
|
|
|
|
|
object,
|
|
|
|
|
{ load?: () => void; error?: () => void }
|
|
|
|
|
>();
|
2026-04-10 12:24:54 +02:00
|
|
|
const mockImageWidth = 1024;
|
|
|
|
|
const mockImageHeight = 512;
|
|
|
|
|
|
|
|
|
|
class MockImage {
|
|
|
|
|
decoding = "async";
|
|
|
|
|
naturalWidth = mockImageWidth;
|
|
|
|
|
naturalHeight = mockImageHeight;
|
|
|
|
|
width = mockImageWidth;
|
|
|
|
|
height = mockImageHeight;
|
|
|
|
|
|
|
|
|
|
addEventListener(type: "load" | "error", listener: () => void) {
|
|
|
|
|
const listeners = imageLoadListeners.get(this) ?? {};
|
|
|
|
|
listeners[type] = listener;
|
|
|
|
|
imageLoadListeners.set(this, listeners);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set src(_value: string) {
|
|
|
|
|
imageLoadListeners.get(this)?.load?.();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MockAudioContext {
|
|
|
|
|
async decodeAudioData(_bytes: ArrayBuffer): Promise<AudioBuffer> {
|
|
|
|
|
return {
|
|
|
|
|
duration: 2.5,
|
|
|
|
|
numberOfChannels: 2,
|
|
|
|
|
sampleRate: 44100
|
|
|
|
|
} as AudioBuffer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async close(): Promise<void> {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vi.stubGlobal("Image", MockImage);
|
|
|
|
|
vi.stubGlobal("AudioContext", MockAudioContext);
|
|
|
|
|
vi.stubGlobal("webkitAudioContext", MockAudioContext);
|
|
|
|
|
|
2026-04-10 12:27:12 +02:00
|
|
|
const portableModelInstance = createModelInstance({
|
|
|
|
|
...importedModel.modelInstance,
|
|
|
|
|
id: "model-instance-portable"
|
|
|
|
|
});
|
2026-04-11 03:51:35 +02:00
|
|
|
const document = createProjectDocument({
|
2026-04-10 12:24:54 +02:00
|
|
|
...createEmptySceneDocument({ name: "Portable Asset Scene" }),
|
|
|
|
|
assets: {
|
|
|
|
|
[importedModel.asset.id]: importedModel.asset,
|
|
|
|
|
[imageAsset.id]: imageAsset,
|
|
|
|
|
[audioAsset.id]: audioAsset
|
|
|
|
|
},
|
|
|
|
|
modelInstances: {
|
2026-04-10 12:27:12 +02:00
|
|
|
[portableModelInstance.id]: portableModelInstance
|
2026-04-10 12:24:54 +02:00
|
|
|
}
|
2026-04-11 03:51:35 +02:00
|
|
|
});
|
2026-04-10 12:24:54 +02:00
|
|
|
|
|
|
|
|
const packageBytes = await saveProjectPackage(document, storage);
|
|
|
|
|
const restoredStorage = createInMemoryProjectAssetStorage();
|
2026-04-11 04:19:50 +02:00
|
|
|
const restoredDocument = await loadProjectPackage(
|
|
|
|
|
packageBytes,
|
|
|
|
|
restoredStorage
|
|
|
|
|
);
|
2026-04-10 12:24:54 +02:00
|
|
|
|
|
|
|
|
expect(restoredDocument).toEqual(document);
|
|
|
|
|
|
2026-04-11 04:19:50 +02:00
|
|
|
const restoredModel = await loadModelAssetFromStorage(
|
|
|
|
|
restoredStorage,
|
|
|
|
|
importedModel.asset
|
|
|
|
|
);
|
|
|
|
|
const restoredImage = await loadImageAssetFromStorage(
|
|
|
|
|
restoredStorage,
|
|
|
|
|
imageAsset
|
|
|
|
|
);
|
|
|
|
|
const restoredAudio = await loadAudioAssetFromStorage(
|
|
|
|
|
restoredStorage,
|
|
|
|
|
audioAsset
|
|
|
|
|
);
|
2026-04-10 12:24:54 +02:00
|
|
|
|
|
|
|
|
expect(restoredModel.metadata.format).toBe("glb");
|
|
|
|
|
expect(restoredModel.template.children.length).toBeGreaterThan(0);
|
|
|
|
|
expect(restoredImage.metadata.width).toBe(imageAsset.metadata.width);
|
2026-04-11 04:19:50 +02:00
|
|
|
expect(restoredAudio.metadata.durationSeconds).toBe(
|
|
|
|
|
audioAsset.metadata.durationSeconds
|
|
|
|
|
);
|
2026-04-10 12:24:54 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("preserves multi-file gltf asset bundles inside the packaged assets directory", async () => {
|
|
|
|
|
const gltfBytes = await readFile(externalTriangleGltfPath);
|
|
|
|
|
const binBytes = await readFile(externalTriangleBinPath);
|
|
|
|
|
const storage = createInMemoryProjectAssetStorage();
|
|
|
|
|
const importedModel = await importModelAssetFromFiles(
|
|
|
|
|
[
|
|
|
|
|
createTestFile(binBytes, "triangle.bin", "application/octet-stream"),
|
|
|
|
|
createTestFile(gltfBytes, "scene.gltf", "model/gltf+json")
|
|
|
|
|
],
|
|
|
|
|
storage
|
|
|
|
|
);
|
2026-04-11 03:51:35 +02:00
|
|
|
const document = createProjectDocument({
|
2026-04-10 12:24:54 +02:00
|
|
|
...createEmptySceneDocument({ name: "Portable Multi-file Scene" }),
|
|
|
|
|
assets: {
|
|
|
|
|
[importedModel.asset.id]: importedModel.asset
|
|
|
|
|
}
|
2026-04-11 03:51:35 +02:00
|
|
|
});
|
2026-04-10 12:24:54 +02:00
|
|
|
|
|
|
|
|
const packageBytes = await saveProjectPackage(document, storage);
|
2026-04-10 12:28:13 +02:00
|
|
|
expect(listPackagedFiles(packageBytes)).toEqual([
|
2026-04-10 12:24:54 +02:00
|
|
|
`assets/${importedModel.asset.id}/scene.gltf`,
|
2026-04-10 12:33:33 +02:00
|
|
|
`assets/${importedModel.asset.id}/triangle.bin`,
|
|
|
|
|
PROJECT_PACKAGE_SCENE_PATH
|
2026-04-10 12:24:54 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const restoredStorage = createInMemoryProjectAssetStorage();
|
|
|
|
|
|
|
|
|
|
await loadProjectPackage(packageBytes, restoredStorage);
|
|
|
|
|
|
2026-04-11 04:19:50 +02:00
|
|
|
const restoredModel = await loadModelAssetFromStorage(
|
|
|
|
|
restoredStorage,
|
|
|
|
|
importedModel.asset
|
|
|
|
|
);
|
2026-04-10 12:24:54 +02:00
|
|
|
|
|
|
|
|
expect(restoredModel.metadata.format).toBe("gltf");
|
|
|
|
|
expect(restoredModel.template.children.length).toBeGreaterThan(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("fails project save when the document references an asset missing from storage", async () => {
|
|
|
|
|
const storage = createInMemoryProjectAssetStorage();
|
|
|
|
|
const imageAsset = {
|
|
|
|
|
id: "asset-image-missing",
|
|
|
|
|
kind: "image",
|
|
|
|
|
sourceName: "missing.png",
|
|
|
|
|
mimeType: "image/png",
|
|
|
|
|
storageKey: createProjectAssetStorageKey("asset-image-missing"),
|
|
|
|
|
byteLength: 16,
|
|
|
|
|
metadata: {
|
|
|
|
|
kind: "image",
|
|
|
|
|
width: 8,
|
|
|
|
|
height: 8,
|
|
|
|
|
hasAlpha: true,
|
|
|
|
|
warnings: []
|
|
|
|
|
}
|
|
|
|
|
} satisfies ImageAssetRecord;
|
2026-04-11 03:51:35 +02:00
|
|
|
const document = createProjectDocument({
|
2026-04-10 12:24:54 +02:00
|
|
|
...createEmptySceneDocument({ name: "Broken Portable Scene" }),
|
|
|
|
|
assets: {
|
|
|
|
|
[imageAsset.id]: imageAsset
|
|
|
|
|
}
|
2026-04-11 03:51:35 +02:00
|
|
|
});
|
2026-04-10 12:24:54 +02:00
|
|
|
|
2026-04-11 04:19:50 +02:00
|
|
|
await expect(saveProjectPackage(document, storage)).rejects.toThrow(
|
|
|
|
|
"Missing stored binary data for image asset missing.png."
|
|
|
|
|
);
|
2026-04-10 12:24:54 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("fails project load when scene.json is missing", async () => {
|
2026-04-10 12:33:09 +02:00
|
|
|
const packageBytes = buildZipArchive({
|
|
|
|
|
"assets/readme.txt": strToU8("not a project")
|
2026-04-10 12:24:54 +02:00
|
|
|
});
|
|
|
|
|
|
2026-04-11 04:19:50 +02:00
|
|
|
await expect(loadProjectPackage(packageBytes, null)).rejects.toThrow(
|
|
|
|
|
"project package is missing scene.json"
|
|
|
|
|
);
|
2026-04-10 12:24:54 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("fails project load when a declared asset has no packaged files", async () => {
|
|
|
|
|
const imageAsset = {
|
|
|
|
|
id: "asset-image-missing-package",
|
|
|
|
|
kind: "image",
|
|
|
|
|
sourceName: "missing.svg",
|
|
|
|
|
mimeType: "image/svg+xml",
|
|
|
|
|
storageKey: createProjectAssetStorageKey("asset-image-missing-package"),
|
|
|
|
|
byteLength: 64,
|
|
|
|
|
metadata: {
|
|
|
|
|
kind: "image",
|
|
|
|
|
width: 64,
|
|
|
|
|
height: 64,
|
|
|
|
|
hasAlpha: false,
|
|
|
|
|
warnings: []
|
|
|
|
|
}
|
|
|
|
|
} satisfies ImageAssetRecord;
|
2026-04-11 03:51:35 +02:00
|
|
|
const document = createProjectDocument({
|
2026-04-10 12:24:54 +02:00
|
|
|
...createEmptySceneDocument({ name: "Incomplete Portable Scene" }),
|
|
|
|
|
assets: {
|
|
|
|
|
[imageAsset.id]: imageAsset
|
|
|
|
|
}
|
2026-04-11 03:51:35 +02:00
|
|
|
});
|
2026-04-10 12:33:09 +02:00
|
|
|
const packageBytes = buildZipArchive({
|
2026-04-11 03:51:35 +02:00
|
|
|
[PROJECT_PACKAGE_SCENE_PATH]: strToU8(serializeProjectDocument(document))
|
2026-04-10 12:24:54 +02:00
|
|
|
});
|
|
|
|
|
|
2026-04-11 04:19:50 +02:00
|
|
|
await expect(
|
|
|
|
|
loadProjectPackage(packageBytes, createInMemoryProjectAssetStorage())
|
|
|
|
|
).rejects.toThrow(
|
2026-04-10 12:24:54 +02:00
|
|
|
"project package is missing bundled files for image asset missing.svg"
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("allows loading an asset-free package without project asset storage", async () => {
|
2026-04-11 03:51:35 +02:00
|
|
|
const document = createProjectDocument(
|
|
|
|
|
createEmptySceneDocument({ name: "Portable Scene Without Storage" })
|
|
|
|
|
);
|
2026-04-11 04:19:50 +02:00
|
|
|
const packageBytes = await saveProjectPackage(
|
|
|
|
|
document,
|
|
|
|
|
createInMemoryProjectAssetStorage()
|
|
|
|
|
);
|
2026-04-10 12:24:54 +02:00
|
|
|
|
2026-04-11 04:19:50 +02:00
|
|
|
await expect(
|
|
|
|
|
loadProjectPackage(packageBytes, null as ProjectAssetStorage | null)
|
|
|
|
|
).resolves.toEqual(document);
|
2026-04-10 12:24:54 +02:00
|
|
|
});
|
|
|
|
|
});
|