import { test } from 'node:test'; import assert from 'node:assert/strict'; import { ACTIVE_PROFILE, PROFILES, decodeGameConfig, resolveActiveProfile, resolveGameServer, } from '../../YouleNexus/assets/framework/config/profiles.ts'; test('decodeGameConfig:按旧协议把 -/# 解码为远程 txt URL', () => { assert.equal(decodeGameConfig('host-path#8080-config'), 'http://host/path:8080/config.txt'); }); test('resolveGameServer:空 gameconfig 使用配置源,非空值使用解码后的注入源', () => { assert.equal( resolveGameServer({ configured: 'https://default/config.txt', injectedGameConfig: '' }), 'https://default/config.txt', ); assert.equal( resolveGameServer({ configured: 'https://default/config.txt', injectedGameConfig: 'host-path#80-a' }), 'http://host/path:80/a.txt', ); }); test('默认 profile 是 ACTIVE_PROFILE,local 是显式 direct 源', () => { assert.equal(resolveActiveProfile('').name, ACTIVE_PROFILE); const local = resolveActiveProfile('?profile=local'); assert.equal(local.source, 'direct'); assert.deepEqual(local.servers, ['ws://127.0.0.1:3088']); }); test('未知 profile 显式报错,不回退到 ACTIVE_PROFILE', () => { assert.throws(() => resolveActiveProfile('?profile=nope'), /未知 profile/); }); test('正常 build 可达 profile 不含占位调试账号', () => { assert.equal(JSON.stringify(PROFILES).includes('REPLACE_ME'), false); assert.equal(PROFILES.staging.account, undefined); });