| 12345678910 |
- const {chromium}=require(process.env.PLAYWRIGHT_MODULE || 'playwright');const fs=require('fs');
- (async()=>{const b=await chromium.launch({headless:true,channel:'chrome'});const results=[];const root='docs/qa/launch-fixes-2026-10-13';
- for(const viewport of [{width:375,height:812},{width:1366,height:900}]){
- for(const [role,port,routes] of [['student',4202,['/pages/home/index','/pages/home/shop','/pages/home/ucenter','/pages/member/passwd']],['teacher',4202,['/pages/home/index','/pages/home/shop']],['admin',4302,['/admin/dashboard','/admin/schedule','/admin/payroll']]]){
- const p=await b.newPage({viewport});const errors=[];p.on('pageerror',e=>errors.push(e.message));await p.addInitScript(({role})=>{localStorage.setItem('xiaoshu.angular.session',JSON.stringify({token:'r:audit-fixture',user:{userId:role==='teacher'?30:20,groupId:role==='teacher'?3:1,honeyName:'本地审查账号'},student:null}));localStorage.setItem('xiaoshu_admin_session_v1',JSON.stringify({objectId:'audit',sessionToken:'r:audit-fixture',username:'local-audit',displayName:'本地审查管理员',roles:['ops-manager'],operationsRole:'ops-manager',company:{objectId:'fixture'}}));},{role});
- await p.route('**/*',async r=>{const u=new URL(r.request().url());if(!['127.0.0.1','localhost'].includes(u.hostname))return r.abort();if(u.pathname.startsWith('/cloud-functions')||u.pathname.startsWith('/ncloud')||u.pathname.startsWith('/backend'))return r.fulfill({status:503,json:{retcode:-1,retmsg:'本地审查:模拟服务暂不可用',success:false,message:'本地审查:模拟服务暂不可用'}});return r.continue()});
- for(const route of routes){await p.goto(`http://127.0.0.1:${port}${route}`);await p.waitForTimeout(2200);const record=await p.evaluate(()=>({runtimeErrors:JSON.parse(sessionStorage.getItem('xiaoshu.safe-diagnostics.v1')||'[]').filter(x=>x.kind==='runtime').length,url:location.pathname,overflow:document.documentElement.scrollWidth>innerWidth,body:document.body.innerText.slice(0,1700),unnamedInputs:[...document.querySelectorAll('input')].filter(e=>!e.labels?.length&&!e.getAttribute('aria-label')&&!e.getAttribute('aria-labelledby')&&e.type!=='hidden').map(e=>({name:e.name,type:e.type,placeholder:e.placeholder}))}));results.push({role,width:viewport.width,route,...record,pageErrors:[...errors]});if(viewport.width===375&&route==='/pages/home/index')await p.screenshot({path:`${root}/${role}-home-unavailable.png`,fullPage:true});}
- await p.close();}
- }
- const p=await b.newPage({viewport:{width:375,height:812}});for(const [port,route] of [[4202,'/pages/shop/get_order?id=901'],[4302,'/admin/payroll']]){await p.goto(`http://127.0.0.1:${port}${route}`);await p.waitForTimeout(200);results.push({case:'unauthenticated',requested:route,actual:new URL(p.url()).pathname,overflow:await p.evaluate(()=>document.documentElement.scrollWidth>innerWidth)});}await b.close();if(results.some(x=>x.runtimeErrors||x.overflow||x.pageErrors?.length))throw Error('Runtime or layout regression: '+JSON.stringify(results));fs.writeFileSync(`${root}/local-page-probes.json`,JSON.stringify(results,null,2));console.log(JSON.stringify(results.map(({body,...r})=>r)));})().catch(e=>{console.error(e);process.exit(1)});
|