import { chromium } from "playwright"; import path from "node:path"; import fs from "node:fs"; const OUT=path.resolve("../../../_qa_shots/adopt"); 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("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/pipeline/bdbf39d3-1a89-4135-b1b7-26d3331a7021"); await p.waitForTimeout(2200); await p.locator('a[data-stage="2"]').first().click().catch(()=>{}); await p.waitForTimeout(2200); r.adoptToggles=await p.locator(".adopt-toggle").count(); r.toggleTexts=await p.locator(".adopt-toggle").allInnerTexts().catch(()=>[]); // hover 第一张角色卡看删除按钮 const card=p.locator(".asset-card-2[data-asset-kind='person']").first(); if(await card.count()){ await card.hover(); await p.waitForTimeout(500); r.delBtnVisible=await card.locator(".asset-card-del").isVisible().catch(()=>false); } await p.screenshot({path:path.join(OUT,"adopt-del.png"),fullPage:true}); await b.close(); console.log(JSON.stringify(r,null,2));