from pathlib import Path root=Path(__file__).resolve().parent.parent path=root/'tools/portal-consumer-completion-visual-qa.cjs' text=path.read_text(encoding='utf-8') for label in ['Nome do projeto','Descrição e objetivo','Moeda','Valor do investimento']: # The visible required marker is part of the accessible label; retain exact scoped matching. text=text.replace("page.getByLabel('"+label+"',{exact:true})", "page.getByLabel(/^"+label+"(?: \\*)?$/)") text=text.replace('/^ANCUABE$/i','/^ANCUABE(?: \\(|$)/i') text=text.replace('page.getByLabel(/^Descrição e objetivo(?: \\*)?$/)','page.getByLabel(/^Descrição e objetivo \\*/)').replace('page.getByLabel(/^Moeda(?: \\*)?$/)',"page.getByLabel('Moeda *',{exact:true})") text=text.replace("page.getByLabel('Moeda *',{exact:true})",'page.getByLabel(/^Moeda \\*/)').replace("page.getByLabel('Regime declarado',{exact:true})",'page.getByLabel(/^Regime declarado/)') text=text.replace("assert.equal((await pending).status(),302)","assert([302,303].includes((await pending).status()))") text=text.replace("assert(s.replay_input,'Prior submitted request must preserve its exact replay input');", "assert(s.replay_input,'Prior submitted request must preserve its exact replay input');s.protocol??=p.request.protocol;s.version??=p.request.version;q.save();") path.write_text(text,encoding='utf-8') workflow=root/'tools/portal-consumer-workflow-ui-qa.cjs' text=workflow.read_text(encoding='utf-8') for old,new in [('Função da localização','Papel da localização'),('Motivo da operação','Motivo (20–1000 caracteres)'),("getByLabel('Classificação'","getByLabel('Classificação documental'"),("getByLabel('Visibilidade'","getByLabel('Âmbito de consulta'")]: text=text.replace(old,new) text=text.replace("scope.getByLabel(label(key),{exact:true})", "scope.getByLabel(new RegExp('^'+label(key).replace(/[.*+?^${}()|[\\]\\\\]/g,'\\\\$&')))") text=text.replace("getByLabel('Revisão',{exact:true})",'getByLabel(/^Revisão/)').replace("getByLabel('Decisão',{exact:true})",'getByLabel(/^Decisão/)') text=text.replace("getByRole('button',{name:'Editar',exact:true})","getByRole('button',{name:'Ver / editar / restaurar',exact:true})") text=text.replace("publish:'Disponibilizar com acesso restrito'","publish:'Publicar no catálogo público'") text=text.replace("visibility:'internal'};const contract", "visibility:'public'};const contract") text=text.replace("assert.equal(props.publicationState.public_catalog,false)","assert.equal(props.publicationState.public_catalog,true)").replace("public_catalog:false};q.proof.checks", "public_catalog:true};q.proof.checks") if 'if(!w.primary_ensured)' not in text: text=text.replace(' if(!w.contract_saved){', ''' if(!w.primary_ensured){ await open('/minhas-oportunidades/'+w.id+'/resources'); const location=props.resources.locations.find(r=>r.id===w.location);assert(location); if(!location.payload.is_primary){await page.getByRole('button',{name:'Editar',exact:true}).click();await page.getByLabel('Localização principal',{exact:true}).check();await page.getByLabel('Motivo (20–1000 caracteres)',{exact:true}).fill('Identificação explícita da sede sintética QA para o workflow.');const pending=page.waitForResponse(r=>new URL(r.url()).pathname.endsWith('/resources/locations/'+w.location)&&r.request().method()==='POST');await page.getByRole('button',{name:'Guardar recurso',exact:true}).click();assert.equal((await pending).status(),200);await page.waitForLoadState('networkidle');} w.primary_ensured=true;q.save(); } if(!w.contract_saved){''') workflow.write_text(text,encoding='utf-8') print('Harness selectors aligned to observed required markers and official source codes; no application/DB writes.')