Files
compras/scripts/received-availability-http.mjs
nala 63d20b10fc
tests / ci (push) Canceled after 0s
commit de armazens
2026-11-04 09:40:26 +02:00

25 lines
1.9 KiB
JavaScript

import fs from 'node:fs/promises';
import assert from 'node:assert/strict';
const source = await fs.readFile('scripts/supplier-evaluation-check.mjs', 'utf8');
const common = source.slice(source.indexOf('const base ='), source.indexOf('const author ='));
await new Function('fs', 'assert', 'return (async()=>{' + common + `
const viewer=client(); await viewer.enter('admin');
assert.equal((await viewer.request('/contexto','POST',{area:'people',option:'people.internal'})).status,302);
const index=await viewer.request('/pessoas'); assert.equal(index.status,200);
let dossiersChecked=0; let availabilityRows=0;
for(const process of index.page.props.processes.data.slice(0,2)) {
const dossier=await viewer.request('/pessoas/'+process.id+'/dossier.json','GET',undefined,false);
assert.equal(dossier.status,200);
assert.equal(dossier.page.schema,'sgc.people.process-dossier.v1');
assert.equal(dossier.page.effect,'preparation_only');
const page=await viewer.request('/pessoas/'+process.id); assert.equal(page.status,200);
assert.deepEqual(dossier.page.candidates,page.page.props.candidates);
availabilityRows+=dossier.page.candidates.filter(row=>row.received_availability).length;
assert.equal(dossier.page.process.tenant_id,undefined);
assert.equal(dossier.page.process.creation_hash,undefined);
dossiersChecked++;
}
await fs.writeFile('docs/proofs/received-availability-http.json',JSON.stringify({checked_at:new Date().toISOString(),environment:base,result:'passed',dossiersChecked,availabilityRows,business_commands:false,visual_review:false,coverage:'Existing visible processes only; positive received-availability cases exercised in disposable tests.'},null,2));
console.log('People page/dossier availability projection checked for existing visible sources only.');
` + '})()')(fs, assert);