Files
joywayer 35216f75e7 feat: integrate room framework and isolated subgame bundles
Complete room UI and protocol integration, move game definitions and resources behind bundle entries, publish authoritative version XML, and document single-game builds. Include all current resource changes and experiment artifacts.
2026-09-09 03:13:18 +08:00

34 lines
2.5 KiB
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {readFileSync} from 'node:fs';
import {getGameDefinition} from '../fixtures/game-definitions.ts';
import {createBuildIdentity,WEB_MARKET_ID} from '../../YouleNexus/assets/app/composition/build-identity.ts';
import {parseVersionManifest} from '../../YouleNexus/assets/app/composition/version-manifest.js';
import {resolveRuntimeConfig} from '../../YouleNexus/assets/framework/config/runtime-config.ts';
import {STARTUP_CONFIG} from '../../YouleNexus/assets/framework/config/profiles.ts';
function manifest(key:string,dir:string){
const definition=getGameDefinition(key);
assert.equal(definition.config.versionResource,key+'/version');
return parseVersionManifest(readFileSync(new URL('../../YouleNexus/assets/games/'+dir+'/resources/'+definition.config.versionResource+'.xml',import.meta.url),'utf8'));
}
test('selected game reads identity and both versions from its XML',()=>{
const manifests=[manifest('erqiwang','erqiwang'),manifest('Game_Surface_3','template')];
for(const source of manifests){const identity=createBuildIdentity(source);
assert.equal(identity.gameid,source.gameid);assert.equal(identity.agentid,source.agentid);
assert.equal(identity.channelid,source.channelid);assert.equal(identity.version,source.versionCode);
assert.equal(identity.marketid,WEB_MARKET_ID);assert.ok(Object.isFrozen(identity));
}
assert.notEqual(manifests[0].gameid,manifests[1].gameid);
assert.throws(()=>getGameDefinition('missing'),/Unknown game/);
assert.throws(()=>createBuildIdentity({...manifests[0],gameid:''}),/gameid/);
});
test('XML edits drive Web identity while native channel remains native-owned',async()=>{
const source={...manifest('erqiwang','erqiwang'),gameid:'xml-game',agentid:'xml-agent',channelid:'xml-channel',versionCode:37,version:'3.7'};
const options={buildIdentity:createBuildIdentity(source),startupConfig:{...STARTUP_CONFIG,configSource:'remote' as const},
search:'',fetcher:{async fetch(){return {player_server_tcp:'remote.example:3088'};}}};
const web=await resolveRuntimeConfig({...options,hostKind:'h5',win:{}});
assert.deepEqual(web.identity,{agentid:'xml-agent',channelid:'xml-channel',gameid:'xml-game',version:37,marketid:WEB_MARKET_ID});
const native=await resolveRuntimeConfig({...options,hostKind:'uAgent_3',win:{app_agent:'native-a',app_channel:'native-c',app_market:9} as any});
assert.deepEqual(native.identity,{agentid:'native-a',channelid:'native-c',marketid:9,gameid:'xml-game',version:37});
});