27 lines
4.9 KiB
JavaScript
27 lines
4.9 KiB
JavaScript
const {start,assert,sanitized,actors,TARGET}=require('./portal-workflow-upgrade-final-browser-lib.cjs');
|
|
const cp=require('node:child_process');
|
|
void(async()=>{const q=await start('workflow-upgrade-fixed-install-chromium-20261011');let ctx,page;try{
|
|
({ctx,page}=await q.context('manager'));await q.login(page,'manager');
|
|
async function post(url,data){const r=await page.evaluate(async({url,data})=>{const token=decodeURIComponent(document.cookie.split('; ').find(v=>v.startsWith('XSRF-TOKEN='))?.slice(11)||'');const r=await fetch(url,{method:'POST',headers:{Accept:'application/json','Content-Type':'application/json','X-XSRF-TOKEN':token},body:JSON.stringify(data)});return {status:r.status,target:r.headers.get('X-Investmoz-QA-Target'),data:r.headers.get('content-type')?.includes('application/json')?await r.json():{redirect_page:true}};},{url,data});assert.equal(r.target,TARGET);return r;}
|
|
q.phase('Authenticated preview from the destination snapshot; 040000 must depend on absent030000');
|
|
const before=await q.json(page,'/management/profile-install');assert.equal(before.status,200);assert(!before.data.installed);if(!q.prior.resources_preview)assert(!before.data.dependencies.resources_030000);assert(!before.data.path_190000_installed);q.proof.before=q.prior.before||before.data;
|
|
const first=await q.json(page,'/management/opportunity-resources-install');assert(first.data.ready);q.proof.resources_preview=q.prior.resources_preview||first.data;
|
|
if(!first.data.installed){
|
|
assert.equal((await post('/management/opportunity-resources-install',{hash:'0'.repeat(64),confirm:true})).status,409);assert(!(await q.json(page,'/management/opportunity-resources-install')).data.installed);q.proof.checks.divergent_030000_plan_denied_without_DDL=true;
|
|
q.phase('030000 authenticated apply, stale repeat refused and renewed repeat without duplicate installation');
|
|
const r=await post('/management/opportunity-resources-install',{hash:first.data.hash,confirm:true});assert.equal(r.status,200);assert((await q.json(page,'/management/opportunity-resources-install')).data.installed);
|
|
assert.equal((await post('/management/opportunity-resources-install',{hash:first.data.hash,confirm:true})).status,409);
|
|
}
|
|
const refreshed=await q.json(page,'/management/opportunity-resources-install');assert(refreshed.data.installed);assert.equal((await post('/management/opportunity-resources-install',{hash:refreshed.data.hash,confirm:true})).status,200);q.proof.checks.resources_installed_with_repetition_no_duplicate=true;
|
|
q.phase('040000 preview, authenticated apply and stable idempotency receipt');
|
|
const p=await q.json(page,'/management/profile-install');assert(p.data.ready&&p.data.consistent&&!p.data.installed);assert(Object.values(p.data.dependencies).every(Boolean));q.proof.profiles_preview=p.data;
|
|
const input={hash:p.data.hash,confirm:true,idempotency_key:require('node:crypto').randomUUID(),reason:'Ensaio isolado QA: atualização autenticada do clone do destino, preservando COUNTRY02 e todos os dados originais.'};
|
|
const installed=await post('/management/profile-install',input);assert.equal(installed.status,200);assert(installed.data.changed&&installed.data.installed);const repeated=await post('/management/profile-install',input);assert.equal(repeated.status,200);assert.deepEqual(repeated.data,installed.data);q.proof.installation_key=input.idempotency_key;
|
|
assert.equal((await post('/management/profile-install',{...input,reason:'Tentativa QA deliberadamente divergente da operação anterior para verificar proteção da chave.'})).status,409);q.proof.checks.profile_installation_idempotent_and_conflict_denied=true;
|
|
const after=await q.json(page,'/management/profile-install');assert(after.data.installed&&after.data.consistent&&!after.data.bootstrap.initialized);assert(!after.data.path_190000_installed);q.proof.after_install=after.data;
|
|
q.phase('Separate explicit bootstrap with two synthetic holders and independent synthetic installer');
|
|
const boot=await post('/management/profile-install/bootstrap',{hash:after.data.hash,confirm:true,idempotency_key:require('node:crypto').randomUUID(),first_user_id:actors.super_first.id,second_user_id:actors.super_second.id,reason:'Cerimónia estritamente sintética QA; nenhuma designação de titulares reais ou alteração de privilégios ativos.'});assert.equal(boot.status,200);assert.equal(boot.data.holders.length,2);q.proof.checks.separate_synthetic_bootstrap=true;
|
|
cp.execFileSync('C:/laragon/bin/php/php-8.5.11-Win32-vs17-x64/php.exe',[require('node:path').join(__dirname,'portal-workflow-upgrade-final-enable-qa.php')],{timeout:60000,stdio:['ignore','pipe','pipe']});
|
|
q.proof.result='passed';q.proof.AB_C37_not_repeated=true;q.save();console.log(JSON.stringify({result:'passed',checks:q.proof.checks,target:TARGET,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}));process.exitCode=1;}finally{if(ctx)await ctx.close();await q.browser.close();}})();
|