import { chromium } from "playwright"; import path from "node:path"; import fs from "node:fs"; const OUT=path.resolve("../../../_qa_shots/gate"); 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/f0eef1aa-5182-438e-b44c-f549326f7fd8"); await p.waitForTimeout(2200); await p.locator('a[data-stage="2"]').first().click().catch(()=>{}); await p.waitForTimeout(2000); r.gateVisible=await p.locator(".extract-gate").count(); r.gateBtns=await p.locator(".extract-gate-btns button, .eg-extract-btn").count(); r.gateBtnText=await p.locator(".eg-extract-btn").innerText().catch(()=>""); await p.screenshot({path:path.join(OUT,"gate-single.png")}); // ② 已提取项目 → 重新提取按钮 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(2000); r.reextractBtn=await p.locator(".pipeline-reextract").count(); r.reextractText=await p.locator(".pipeline-reextract").innerText().catch(()=>""); await p.screenshot({path:path.join(OUT,"reextract.png")}); await b.close(); console.log(JSON.stringify(r,null,2));