44 lines
1.9 KiB
JavaScript
44 lines
1.9 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { updateVisualDescriptors } from "./apply-wow-visual-optimization.mjs";
|
|
|
|
test("visual publisher rejects a descriptor URL mismatch before updating any package", () => {
|
|
const targets = [
|
|
{ label: "stage pack", packageDefinition: { visual: [{ url: "/assets/game/manastorm/33-shadowfang/visual.glb", checksum: "old-stage" }] } },
|
|
{ label: "registry", packageDefinition: { visual: [{ url: "/assets/game/other/visual.glb", checksum: "old-registry" }] } },
|
|
{ label: "import", packageDefinition: { visual: [{ url: "/assets/game/manastorm/33-shadowfang/visual.glb", checksum: "old-import" }] } },
|
|
{ label: "dungeon pack", packageDefinition: { visual: [{ url: "/assets/game/manastorm/33-shadowfang/visual.glb", checksum: "old-dungeon" }] } },
|
|
];
|
|
const before = structuredClone(targets);
|
|
const descriptor = {
|
|
url: "/assets/game/manastorm/33-shadowfang/visual.glb",
|
|
checksum: "new",
|
|
byteLength: 123,
|
|
triangleCount: 456,
|
|
};
|
|
|
|
assert.throws(() => updateVisualDescriptors(targets, descriptor), /registry visual URL does not match/u);
|
|
assert.deepEqual(targets, before, "a mismatch in any of the four targets must prevent partial metadata updates");
|
|
});
|
|
|
|
test("visual publisher updates all prevalidated visual descriptors together", () => {
|
|
const targets = ["stage pack", "registry", "import", "dungeon pack"].map((label) => ({
|
|
label,
|
|
packageDefinition: { visual: [{ url: "/assets/game/manastorm/33-shadowfang/visual.glb", checksum: "old" }] },
|
|
}));
|
|
const descriptor = {
|
|
url: "/assets/game/manastorm/33-shadowfang/visual.glb",
|
|
checksum: "new",
|
|
byteLength: 123,
|
|
triangleCount: 456,
|
|
};
|
|
|
|
updateVisualDescriptors(targets, descriptor);
|
|
for (const { packageDefinition } of targets) {
|
|
assert.deepEqual(packageDefinition.visual[0], {
|
|
...descriptor,
|
|
compression: "meshopt+ktx2",
|
|
});
|
|
}
|
|
});
|