import { STARTUP_CONFIG } from '../../YouleNexus/assets/framework/config/profiles.ts'; 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({ 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({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']); } });