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

31 lines
2.0 KiB
TypeScript

import { BUILD_IDENTITY } from '../fixtures/build-identity.ts';
import { STARTUP_CONFIG as EDITABLE_STARTUP_CONFIG } from '../../YouleNexus/assets/framework/config/profiles.ts';
// 固定测试来源,允许开发者独立切换项目的 local/remote 开关。
const STARTUP_CONFIG = Object.freeze({...EDITABLE_STARTUP_CONFIG, configSource:'remote' as const});
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { resolveBootstrap } from '../../YouleNexus/assets/framework/config/bootstrap.ts';
import type { ConfigFetcher } from '../../YouleNexus/assets/framework/config/remote-config.ts';
test('resolveBootstrap:显式 hostKind 透传严格 RuntimeConfig,并保留 profile 元数据', async () => {
const fetcher: ConfigFetcher = {
async fetch() { return { player_server_tcp: '5.5.5.5:5000' }; },
};
const result = await resolveBootstrap({buildIdentity:BUILD_IDENTITY,
startupConfig:STARTUP_CONFIG, hostKind: 'h5', win: {}, search: '', fetcher,
});
assert.equal(result.source, 'remote');
assert.equal(result.profile.name, 'local');
assert.deepEqual(result.servers, ['ws://127.0.0.1:3088']);
});
test('facade forwards the entire injected source and derives its compatibility label', async () => {
for (const useLocalServer of [true,false]) {
const startupConfig={...STARTUP_CONFIG,mode:'release' as const,useLocalServer,gameserver:'https://fixture.example/config.txt'};
const result=await resolveBootstrap({buildIdentity:BUILD_IDENTITY,startupConfig,isNative:false,win:{},search:'?mode=debug&profile=unknown&profile=local',fetcher:{async fetch(url){assert.equal(url,startupConfig.gameserver);return {player_server_tcp:'remote.example:3088'};}}});
assert.deepEqual(result.startupConfig,startupConfig); assert.equal(result.mode,'release');
assert.equal(result.profile.name,useLocalServer?'local':'prod');
assert.deepEqual(result.servers,useLocalServer?STARTUP_CONFIG.localServers:['ws://remote.example:3088']);
}
});