12 lines
2.7 KiB
JavaScript
12 lines
2.7 KiB
JavaScript
// Reconcile installed resources/profiles with the actual manager consumers; no reinstall.
|
|
const {start,assert,sanitized}=require('./portal-functional-qa-lib.cjs');
|
|
void(async()=>{const q=await start('functional-joint-chromium-20261011');let page,ctx;
|
|
function parse(html){const a=html.match(/data-page="([^"]+)"/);return JSON.parse(a&&a[1].startsWith('{')?a[1].replace(/"/g,'"').replace(/&/g,'&').replace(/'/g,"'"):html.match(/<script[^>]*type="application\/json"[^>]*>([\s\S]*?)<\/script>/)[1]).props;}
|
|
try{({ctx,page}=await q.context('geo'));await q.login(page,'geo');q.proof.statistics=[];
|
|
for(const route of ['/management/interests?origin=unknown','/management/interests?origin=unknown&country=MZ','/management/interests?origin=PT&country=MZ','/management/interests?origin=PT&country=MZ&q=QA%20NEGATIVE%20ABSENT']){q.phase('Scoped origin statistics '+route);const r=await q.open(page,route);assert.equal(r.status(),200);const p=parse(await r.text());for(const row of p.requests.data){if(p.filters.country)assert.equal(row.country,p.filters.country);assert.equal(row.declaredOrigin.code,p.filters.origin==='unknown'?null:p.filters.origin);}for(const group of Object.values(p.originStatistics))for(const row of group)assert.equal(row.code,p.filters.origin==='unknown'?null:p.filters.origin);if(p.filters.q)assert.equal(p.requests.total,0);q.proof.statistics.push({route,total:p.requests.total,ids:p.requests.data.map(r=>r.id),groups:p.originStatistics,statistics_scope:'origin only; country/search affect list, collections separate'});q.save();}
|
|
assert.deepEqual(q.proof.statistics[0].groups,q.proof.statistics[1].groups);assert.deepEqual(q.proof.statistics[2].groups,q.proof.statistics[3].groups);await q.shot(page,'origin-country-statistics',false);
|
|
const resource=await q.json(page,'/management/opportunity-resources-install');assert.equal(resource.status,200);q.proof.resources_preview=resource.data;assert(resource.data.installed);
|
|
await ctx.close();({ctx,page}=await q.context('super_first'));await q.login(page,'super_first');const profile=await q.json(page,'/management/profile-install');assert.equal(profile.status,200);assert(profile.data.installed);q.proof.profiles_preview=profile.data;
|
|
q.proof.result='passed';q.proof.checks={installed_030000_040000_no_repetition:true,origin_unknown_and_combined_filters:true,collections_not_summed_as_investors:true,ClamD_and_processing_in_separate_real_receipt:true};q.save();console.log(JSON.stringify({result:'passed',checks:q.proof.checks,profile_installed:true,resources_installed:true,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();}})();
|