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/rv"); 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(2500); await p.locator(".pd-group-card",{hasText:"角色"}).first().click(); await p.waitForTimeout(1200); r.badgeCount=await p.locator(".review-badge").count(); r.badgeText=await p.locator(".review-badge .rv-label").first().innerText().catch(()=>""); r.badgeClickable=await p.locator(".review-badge.clickable").count(); // hover 看气泡 await p.locator(".review-badge").first().hover(); await p.waitForTimeout(400); r.popVisible=await p.locator(".review-pop").first().isVisible().catch(()=>false); await p.screenshot({path:path.join(OUT,"rv-modal.png")}); await b.close(); console.log(JSON.stringify(r,null,2));