import { chromium } from "playwright"; import fs from "node:fs"; import path from "node:path"; const BASE="http://localhost:5200"; const OUT=path.resolve("../../../_qa_shots/lib-v2"); 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:900}})).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(BASE+"/login"); await p.waitForTimeout(400); 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(BASE+"/library"); await p.waitForTimeout(2800); r.tabs=(await p.locator(".tab").allInnerTexts().catch(()=>[])).join(" | "); await p.screenshot({path:path.join(OUT,"lib-default.png"),fullPage:true}); // 视频成品 await p.locator(".tab",{hasText:"视频成品"}).click(); await p.waitForTimeout(2500); r.packCards=await p.locator(".pack-card").count(); await p.screenshot({path:path.join(OUT,"lib-videopacks.png"),fullPage:true}); // 点开包 if(r.packCards>0){ await p.locator(".pack-card").first().click(); await p.waitForTimeout(1800); r.packModalOpen=await p.locator(".pack-modal").count(); r.clipCount=await p.locator(".pack-clip").count(); await p.screenshot({path:path.join(OUT,"lib-pack-modal.png"),fullPage:true}); } await b.close(); console.log(JSON.stringify(r,null,2));