import { chromium } from "playwright"; import path from "node:path"; import fs from "node:fs"; const PID="53d7a7c3-2f41-431b-82d3-3acc97900310"; const OUT=path.resolve("../../../_qa_shots/pd"); fs.mkdirSync(OUT,{recursive:true}); const b=await chromium.launch({headless:true}); const r={consoleErrors:[]}; const p=await (await b.newContext({viewport:{width:1440,height:1000}})).newPage(); p.on("console",m=>{if(m.type()==="error")r.consoleErrors.push(m.text())}); p.on("pageerror",e=>r.consoleErrors.push("PE:"+e.message)); await p.goto("http://localhost:5200/login"); await p.waitForTimeout(300); await p.fill("#auth-username","airshelf"); await p.fill("#auth-pwd","Restraint2026"); await p.click("button.btn-cta"); await p.waitForFunction(()=>!location.pathname.startsWith("/login"),{timeout:12000}); await p.goto("http://localhost:5200/products/"+PID); await p.waitForTimeout(3000); // 收集每张素材卡的 类型标签 + 是否有审核态 const cards=await p.locator(".asset-card").count(); const rows=[]; for(let i=0;i""); const status=await c.locator(".meta .pill").innerText().catch(()=>""); rows.push({type, status: status||"(无)"}); } r.cards=cards; r.sample=rows; await p.locator("#asset-grid, .asset-grid").first().screenshot({path:path.join(OUT,"pd-materials.png")}).catch(()=>p.screenshot({path:path.join(OUT,"pd-full.png"),fullPage:true})); await b.close(); console.log(JSON.stringify(r,null,2));