Files
SGF/scripts/sgf-stock-inactive-http.mjs
2026-11-11 09:00:17 +02:00

9 lines
2.5 KiB
JavaScript

import fs from 'node:fs';import assert from 'node:assert/strict';import {session} from './sgf-single-http.mjs';
const checks=[];const ok=(v,n)=>{assert(v,n);checks.push(n);};const s=await session('purchasing:validator','stock');ok(s.identity.context.stock.inactive_report===true,'selected Stock report exposed');
const query={view:'inactive',as_of:'2026-12-10',days:30,per_page:25};const get=async(extra={})=>{const r=await s.get('/api/stock-read?'+new URLSearchParams({...query,...extra}));return{status:r.status,data:await r.json(),cache:r.headers.get('cache-control')};};
const first=await get();ok(first.status===200&&first.data.status==='available','actual SELECT-only composed source');ok(first.cache.includes('no-store'),'response not cached');ok(first.data.rows.length>0,'known QA physical pairs available at explicit future cut');ok(first.data.capabilities.write===false&&first.data.capabilities.valuation===false,'no writer or valuation offered');ok(first.data.rows.every(r=>r.days_without_record>=30&&typeof r.physical_quantity_milli==='string'),'UTC ages and exact quantities');
const hundred=await get({per_page:100});ok(hundred.status===200&&hundred.data.pagination.total===first.data.pagination.total,'page sizes have same filtered universe');ok((await get({warehouse_id:2147483647})).status===403,'unmapped warehouse refused');ok((await get({days:29,snapshot:first.data.snapshot})).status===409,'filter change invalidates old reference');ok((await get({snapshot:'invalid'})).status===409,'tampered reference refused');ok((await get({as_of:'2026-02-30'})).status===422,'invalid date refused');ok((await get({days:0})).status===422,'zero interval refused');ok((await get({per_page:500})).status===422,'excessive page refused');
const now=await get({as_of:'2026-11-10',days:3650});ok(now.status===200&&now.data.rows.length===0,'empty known-history conclusion does not invent zeros');
const denied=await session('purchasing:actor','purchasing');const r=await denied.get('/api/stock-read?'+new URLSearchParams(query));ok([403,409].includes(r.status),'Purchasing actor cannot bypass Stock module or right');
const run=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json'));const path=run.root+'/private/receipt-composition-cc50a276c10c/stock-inactive-http-20261110.json';fs.writeFileSync(path,JSON.stringify({passed:true,checks,business_posts:0,context_selection_only:true,new_demo:false,browser_visual_review:false},null,2));console.log(JSON.stringify({passed:true,checks:checks.length,proof:path}));