Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
dev/v7-production-failclosed-20261021
ci/public-windows-bridge-probe-20261017
ci/windows-dispatch-bootstrap-20261016
ci/windows-dual-app-lab-20261016
dev/v7-production-failclosed-20261021
feature/reconciliation-guard-20261013
main
phase-1-foundation
phase-1-implementation
phase-2-treasury-core
phase-3-banking-reconciliation
phase-4-operations-enterprise-ux
phase-5-hardening-release
phase-6-production-platform
phase-7-production-infrastructure-bank-golive
phase-7-sql-readonly-ux-20261015
transfer-exe-to-drive-20261006
| 1 | import {describe,it,expect} from 'vitest'; |
| 2 | import {createRequire} from 'node:module'; |
| 3 | const require=createRequire(import.meta.url); |
| 4 | const {isExpectedReadiness}=require('./ready-check.cjs') as {isExpectedReadiness:(status:number,body:unknown)=>boolean}; |
| 5 | describe('Electron localhost strict readiness gate',()=>{ |
| 6 | const ready=JSON.stringify({status:'ready',bankAdapter:'disabled',missing:[]}); |
| 7 | it('accepts only authentic expected schema with HTTP 200',()=>{ |
| 8 | expect(isExpectedReadiness(200,ready)).toBe(true); |
| 9 | expect(isExpectedReadiness(201,ready)).toBe(false); |
| 10 | expect(isExpectedReadiness(302,ready)).toBe(false); |
| 11 | expect(isExpectedReadiness(404,ready)).toBe(false); |
| 12 | expect(isExpectedReadiness(503,ready)).toBe(false); |
| 13 | }); |
| 14 | it('rejects stale local servers, non-JSON and bank-enabled responses',()=>{ |
| 15 | for(const body of ['<html>Welcome</html>','not-json','', |
| 16 | '{"status":"not-ready","bankAdapter":"disabled"}', |
| 17 | '{"status":"ready","bankAdapter":"live"}', |
| 18 | '{"status":"ready","bankAdapter":"sandbox"}', |
| 19 | '{"status":"ready"}', |
| 20 | JSON.stringify({status:'ready',bankAdapter:'disabled',junk:'x'.repeat(5000)})]){ |
| 21 | expect(isExpectedReadiness(200,body)).toBe(false); |
| 22 | } |
| 23 | }); |
| 24 | it('never accepts objects supplied as body, arrays or JSON scalar',()=>{ |
| 25 | for(const body of [{status:'ready',bankAdapter:'disabled'},'null','[]','true','4']){ |
| 26 | expect(isExpectedReadiness(200,body)).toBe(false); |
| 27 | } |
| 28 | }); |
| 29 | }); |