/** Execute in Cocos Game View. All input fixtures stay local; no server submission. */ export async function verifyProfilePreview(e,profileId) { const checks=[],assert=(ok,message)=>{if(!ok)throw Error(message);checks.push(message);}; const load=id=>new Promise((resolve,reject)=>e.assetManager.loadAny(id,(err,a)=>err?reject(err):resolve(a))); const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms)); const asset=await load(profileId),root=e.instantiate(asset);root.parent=e.director.getScene(); const host=new e.Node('ProfileFlowVerification');host.parent=e.director.getScene(); try { const view=root.getComponent('ProfileInfoListView'); assert(view,'profile prefab owns ProfileInfoListView'); assert(view.textItemPrefab&&view.authPrefab,'profile owns text-item and auth prefab references'); view.render(['昵称','ID:42','IP:127.0.0.1','积分:0','星星:10','城市','个性签名:'],'短签名'); await sleep(80); const content=view.content,layout=content.getComponent(e.Layout); const checkSpacing=()=>{ const children=content.children.filter(n=>n.active); for(let i=1;in.active).length===4,'removed fields leave no empty rows'); assert(content.children[0].getComponent(e.UITransform).height>30,'long nickname wraps and increases its row height'); assert(view.signatureBox.height>=view.signature.node.getComponent(e.UITransform).height+20,'signature background grows with its text'); assert(content.getComponent(e.UITransform).height>initialHeight&&view.scroll.getMaxScrollOffset().y>0,'long content becomes scrollable'); view.scroll.scrollToBottom(0);await sleep(30); view.render(['昵称','个性签名:'],'短签名');await sleep(60);checkSpacing(); assert(content.getComponent(e.UITransform).heightm).find(m=>m.LobbyPanel)?.LobbyPanel; assert(LobbyPanel,'LobbyPanel is loaded'); const panel=Object.create(LobbyPanel.prototype),tips=[]; panel.assets={profile:asset};panel.disposed=false;panel.modal=null;panel.modalReleases=[]; panel.policy={starName:'星星'};panel.model={nickname:'资料接线测试',playerid:42,ip:'127.0.0.1',score:0,bean:10,sign:'签名测试',canAct:true}; panel.avatarFrame=asset.data.getChildByPath('group-18/Spirit118').getComponent(e.Sprite).spriteFrame; panel.location=()=>null;panel.tip=message=>tips.push(message); panel.close=()=>{for(const off of panel.modalReleases.splice(0))off();panel.modal?.destroy();panel.modal=null;panel.modalKind='';}; panel.open=(prefab,kind)=>{panel.close();panel.modal=e.instantiate(prefab);panel.modal.parent=host;panel.modalKind=kind;return panel.modal;}; panel.openProfile(); const profile=panel.modal,profileView=profile.getComponent('ProfileInfoListView'); assert(profileView.content.children[0].getComponent(e.Label).string==='资料接线测试'&&profileView.signature.string==='签名测试','profile renders data through the new hierarchy'); const auth=()=>{ panel.modal.getChildByPath('group-18/Spirit484').emit(e.Button.EventType.CLICK); assert(panel.modal?.name==='Layer18_Auth'&&panel.modalKind==='auth','real-name button opens the auth prefab'); const group=panel.modal.getChildByName('group-57'); return {group,name:group.getChildByName('NameInput').getComponent(e.EditBox),id:group.getChildByName('IdInput').getComponent(e.EditBox),submit:group.getChildByName('Spirit493')}; }; let inputs=auth();await sleep(40); assert(!e.isValid(profile),'opening auth closes the profile'); assert(inputs.name.string===''&&inputs.id.string==='','auth opens with empty inputs'); assert(inputs.id.inputMode===e.EditBox.InputMode.SINGLE_LINE&&inputs.id.inputFlag===e.EditBox.InputFlag.DEFAULT,'ID input allows the X checksum character'); for(const edit of [inputs.name,inputs.id])for(const label of [edit.textLabel,edit.placeholderLabel]){ const ui=label.node.getComponent(e.UITransform); assert(Math.abs(label.node.position.y+(0.5-ui.anchorY)*ui.height)<0.1&&label.verticalAlign===e.Label.VerticalAlign.CENTER,'input text stays vertically centered inside its hit area'); } inputs.name.string='张';inputs.id.string='11010519491231002X';inputs.submit.emit(e.Button.EventType.CLICK); assert(tips.at(-1)==='姓名不正确!'&&panel.modal!==null,'invalid name shows source tip and keeps auth open'); inputs.name.string='测试';inputs.id.string='110105194912310020';inputs.submit.emit(e.Button.EventType.CLICK); assert(tips.at(-1)==='身份证信息不正确!'&&panel.modal!==null,'invalid ID shows source tip and keeps auth open'); inputs.id.string='11010519491231002X';inputs.submit.emit(e.Button.EventType.CLICK); assert(tips.at(-1)==='认证成功!'&&panel.modal===null,'valid local input closes auth and shows source success tip'); panel.openProfile();inputs=auth(); assert(inputs.name.string===''&&inputs.id.string==='','reopening does not retain identity inputs'); inputs.group.getChildByName('Spirit485').emit(e.Button.EventType.CLICK); assert(panel.modal===null,'auth backdrop closes the panel'); assert(tips.length===3,'flow produced only the three expected validation tips'); return {checks}; } finally {root.destroy();host.destroy();await sleep(50);} }