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

17 lines
2.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from pathlib import Path
ROOT=Path(__file__).resolve().parent.parent
prefix=(ROOT/'tools/portal-stability-consumers-chromium.cjs').read_text(encoding='utf-8').split('try{\nif(remaining)')[0]
prefix=prefix.replace('portal-stability-consumers-chromium.json','portal-stability-action-diagnosis.json')
body=r'''try{
await actor('promoter');await open('/minhas-oportunidades/53/resources');
if(!process.argv.includes('--room-only')){
proof.resource_before=await page.locator('article').allTextContents();
await page.getByRole('button',{name:'Ver / editar / restaurar',exact:true}).last().click();await page.getByLabel('Título',{exact:true}).fill('Synthetic stability recoverable location edited');await page.getByLabel('Motivo (20–1000 caracteres)').fill('Synthetic QA edit: preserve existing location and increase its version');
const response=page.waitForResponse(r=>r.request().method()==='POST'&&new URL(r.url()).pathname.includes('/53/resources/'));await page.getByRole('button',{name:'Guardar recurso',exact:true}).click();const r=await response;proof.resource_edit_response={status:r.status(),body:await r.json()};save();await page.reload({waitUntil:'networkidle'});proof.resource_visible=await page.locator('article').allTextContents();save();
}
await open('/parcerias/salas/1');for(let n=1;n<=2;n++){const text='Isolated trace for consecutive QA room messages '+n;await page.getByLabel('Mensagem privada',{exact:true}).fill(text);const result=page.waitForResponse(r=>r.request().method()==='POST'&&new URL(r.url()).pathname==='/parcerias/salas/1/mensagens');await page.getByRole('button',{name:'Enviar mensagem',exact:true}).click();const r=await result;const sent=r.request().postDataJSON();proof.checks.push({room_send:n,status:r.status(),body_length:sent.body.length,body_matches_entered:sent.body===text});save();await page.waitForTimeout(1000);proof.checks.at(-1).visible=await page.getByText(text,{exact:true}).count();proof.checks.at(-1).errors=await page.getByRole('alert').allTextContents();save();}
await page.reload({waitUntil:'networkidle'});proof.room_recovery=await page.locator('article').allTextContents();proof.result='diagnosed';save();console.log(JSON.stringify({result:proof.result,resource_status:proof.resource_edit_response?.status,room:proof.checks}));
}catch(e){proof.result='failed';proof.failure=redact(e);if(page&&!page.isClosed())proof.visible_status=await page.getByRole('status').allTextContents();save();console.log(JSON.stringify({result:'failed',failure:proof.failure}));process.exitCode=1;}finally{if(ctx)await ctx.close();await browser.close();}})();
'''
(ROOT/'tools/portal-stability-action-diagnosis.cjs').write_text(prefix+body,encoding='utf-8')