Files
Investidor-V2/tools/portal-functional-browser-qa.cjs
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

18 lines
2.0 KiB
JavaScript

const {start,assert,fs,path,DIR,sanitized}=require('./portal-functional-qa-lib.cjs');
const mode=process.argv[2]||'inventory';
void(async()=>{
const q=await start('functional-'+mode+'-chromium-20261011');let page,ctx,props;
async function actor(role){if(ctx)await ctx.close();({page,ctx}=await q.context(role));await q.login(page,role);}
async function open(route){const r=await q.open(page,route);const html=await r.text();const attr=html.match(/data-page="([^"]+)"/);
const raw=attr&&attr[1].startsWith('{')?attr[1].replace(/&quot;/g,'"').replace(/&amp;/g,'&').replace(/&#039;/g,"'"):html.match(/<script[^>]*type="application\/json"[^>]*>([\s\S]*?)<\/script>/)?.[1];
props=raw?JSON.parse(raw).props:null;await page.waitForLoadState('networkidle');return r;}
try {
await actor('promoter');q.proof.pages=[];
for(const id of [30,31,32,33,34,35]){const route='/minhas-oportunidades/'+id+'/view';const r=await open(route);assert.equal(r.status(),200);
q.proof.pages.push({id,category:props.record.opportunity_category,state:props.workflowState,actions:props.profileActions,labels:await page.locator('label').allTextContents(),gates:props.canonicalOptions.gates,values_keys:Object.keys(props.values.canonical),completion:props.canonicalResponse.completion});q.save();}
for(const route of ['/minhas-oportunidades/15/edit','/minhas-oportunidades/33/resources','/minhas-oportunidades']){const r=await open(route);q.proof.pages.push({route,status:r.status(),labels:await page.locator('label').allTextContents(),buttons:await page.getByRole('button').allTextContents(),props_keys:props?Object.keys(props):[]});q.save();}
q.proof.result='passed';q.save();console.log(JSON.stringify({result:q.proof.result,pages:q.proof.pages.length,receipt:q.receipt,active_writes:0}));
}catch(e){q.proof.result='failed';q.proof.failure=sanitized(e);q.save();console.log(JSON.stringify({result:'failed',failure:q.proof.failure,active_writes:0}));process.exitCode=1;}
finally{if(ctx)await ctx.close();await q.browser.close();}
})();