import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import test from "node:test"; import { findProviderCatalogEntry, mergeProviderAdvertisement } from "./provider-advertisements.mjs"; const catalog = JSON.parse(readFileSync(new URL("./local-provider-catalog.json", import.meta.url), "utf8")); const aetheriaAdvertisement = JSON.parse(readFileSync(new URL("./fixtures/aetheria.provider-advertisement.json", import.meta.url), "utf8")); const aetheriaUnityAssetManifest = JSON.parse(readFileSync(new URL("./fixtures/aetheria.unity-playable-world-asset-manifest.json", import.meta.url), "utf8")); const worldSmokeAdvertisement = JSON.parse(readFileSync(new URL("./fixtures/eve-world-smoke.provider-advertisement.json", import.meta.url), "utf8")); const saiAdvertisement = JSON.parse(readFileSync(new URL("./fixtures/sai-vn.provider-advertisement.json", import.meta.url), "utf8")); test("merges local fixture transport with advertised Aetheria world interaction", () => { const catalogProvider = findProviderCatalogEntry(catalog, "aetheria"); const provider = mergeProviderAdvertisement(catalogProvider, aetheriaAdvertisement); const surface = provider.surfaces.find(candidate => candidate.surfaceId === "aetheria.daemon.game"); assert.equal(surface.transport, "local-json"); assert.equal(surface.url, "./fixtures/aetheria-world-surface.json"); assert.equal(surface.surfaceKind, "interactive-world"); assert.equal(surface.worldInteraction.projectionKind, "provider-authored-world-surface"); assert.equal(surface.worldInteraction.commandBoundary, "aetheria.daemon.commands"); assert.equal(surface.worldInteraction.receiptSchema, "aetheria.eve_command_acceptance_status.v1"); assert.equal(provider.localAdvertisement.providerId, "aetheria"); assert.ok(aetheriaAdvertisement.schemas.includes("gamecult.eve.unity_playable_world_asset_manifest.v1")); }); test("loads Aetheria Unity playable world asset manifest as provider-authored data", () => { assert.equal(aetheriaUnityAssetManifest.schema, "gamecult.eve.unity_playable_world_asset_manifest.v1"); assert.equal(aetheriaUnityAssetManifest.providerId, "aetheria"); assert.equal(aetheriaUnityAssetManifest.manifestRef, "cultmesh://aetheria/assets/manifest"); const byKind = new Map(aetheriaUnityAssetManifest.entries.map(entry => [entry.entityKind, entry])); assert.equal(byKind.get("player").assetRef, "cultmesh://aetheria/assets/map/entity/player"); assert.equal(byKind.get("player").resourcesPath, "resources://Aetheria/Entities/Vanguard.prefab"); assert.equal(byKind.get("enemy").prefabKey, "aetheria.raider"); }); test("merges generic world fixture transport with advertised world interaction", () => { const catalogProvider = findProviderCatalogEntry(catalog, "eve.world-smoke"); const provider = mergeProviderAdvertisement(catalogProvider, worldSmokeAdvertisement); const surface = provider.surfaces.find(candidate => candidate.surfaceId === "eve.world-smoke.surface"); assert.equal(surface.transport, "local-json"); assert.equal(surface.url, "./fixtures/eve-world-smoke-surface.json"); assert.equal(surface.surfaceKind, "interactive-world"); assert.equal(surface.worldInteraction.projectionKind, "provider-authored-world-surface"); assert.equal(surface.worldInteraction.commandBoundary, "eve.world-smoke.commands"); assert.equal(surface.worldInteraction.receiptSchema, "eve.world_smoke.command_receipt.v1"); assert.deepEqual(surface.worldInteraction.loweringTargets, ["web-reference", "unity-uitoolkit", "unity-scene", "electron-shell", "tui"]); }); test("preserves Sai required and optional nested plugin requirements from advertisement", () => { const catalogProvider = findProviderCatalogEntry(catalog, "gamecult.home.vn"); const provider = mergeProviderAdvertisement(catalogProvider, saiAdvertisement); const surface = provider.surfaces.find(candidate => candidate.surfaceId === "sai.visual_novel.surface"); const byPlugin = new Map(surface.requiresPlugins.map(requirement => [requirement.pluginId, requirement])); assert.equal(surface.transport, "local-json"); assert.equal(surface.url, "./fixtures/sai-vn-surface.json"); assert.equal(byPlugin.get("sai.vn").availability, "required"); assert.deepEqual(byPlugin.get("sai.vn").requiredCapabilities, [ "vn.stage", "story.choose", "story.continue", "story.jump", ]); assert.equal(byPlugin.get("norn.graph").availability, "optional-nested"); assert.deepEqual(byPlugin.get("norn.graph").requiredCapabilities, []); assert.deepEqual(byPlugin.get("norn.graph").optionalCapabilities, ["embed.norn"]); assert.equal(byPlugin.get("tex.math").availability, "optional-nested"); assert.deepEqual(byPlugin.get("tex.math").requiredCapabilities, []); assert.deepEqual(byPlugin.get("tex.math").optionalCapabilities, ["embed.tex"]); });