import test from 'node:test'; import assert from 'node:assert/strict'; import { createRemoteConfig } from '../../YouleNexus/assets/framework/config/remote-config.ts'; import type { RuntimeConfig } from '../../YouleNexus/assets/framework/config/runtime-config.ts'; import { resolveSharePolicy,sharePayload } from '../../YouleNexus/assets/framework/presentation/share-model.ts'; test('share reads url_download and preserves original friend and timeline payloads',()=>{ const identity={agentid:'a',channelid:'c',gameid:'g',marketid:4,version:1}; const remoteConfig=createRemoteConfig({url_download:'https://example.test/app',sharename:'标题',hall_config:{shareDesc:'描述',shareType:1,shareImgUrl:'https://example.test/share.png'}},identity); const policy=resolveSharePolicy({identity,remoteConfig} as RuntimeConfig); assert.equal(policy.url,'https://example.test/app?agentid=a&channelid=c&gameid=g&marketid=4'); assert.deepEqual(sharePayload(policy,1),{sharefriend:1,type:1,webpageUrl:policy.url,title:'标题',description:'描述',sharetype:0}); assert.deepEqual(sharePayload(policy,2),{sharefriend:2,type:3,webpageUrl:'https://example.test/share.png',title:'标题描述',description:undefined,sharetype:0}); assert.equal(sharePayload({...policy,imageTimeline:false},2),null); });