Files
yingqing/core/qa/visual-parity/_factory-all.mjs
T

21 lines
1.3 KiB
JavaScript

import { chromium } from "playwright";
const b=await chromium.launch({headless:true});
const p=await (await b.newContext({viewport:{width:1440,height:900}})).newPage();
const errs=[]; p.on("console",m=>{if(m.type()==="error")errs.push(m.text())}); p.on("pageerror",e=>errs.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/asset-factory"); await p.waitForTimeout(1500);
// 量每张卡的内容偏移
const n=await p.locator(".factory-card").count();
const offs=[];
for(let i=0;i<n;i++){
const card=await p.locator(".factory-card").nth(i).boundingBox();
const tag=await p.locator(".factory-card").nth(i).locator(".factory-tag").boundingBox();
const title=await p.locator(".factory-card").nth(i).locator(".factory-title").innerText();
offs.push({card:i+1,title:title.slice(0,8),offset:Math.round(tag.x-card.x)});
}
await p.locator(".factory-hero").screenshot({path:"../../../_qa_shots/factory-all.png"});
console.log(JSON.stringify({cards:n,offsets:offs,consoleErrors:errs},null,2));
await b.close();