Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
phase-7-production-infrastructure-bank-golive
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 {afterEach,describe,expect,it} from 'vitest'; |
| 2 | import {mkdtempSync,rmSync} from 'node:fs'; |
| 3 | import {tmpdir} from 'node:os'; |
| 4 | import {join} from 'node:path'; |
| 5 | import {DatabaseSync} from 'node:sqlite'; |
| 6 | import {SqliteStore} from './sqlite-store'; |
| 7 | const dirs:string[]=[]; |
| 8 | const make=()=>{const d=mkdtempSync(join(tmpdir(),'tf-sqlite-'));dirs.push(d);return join(d,'treasuryflow.db')}; |
| 9 | afterEach(()=>dirs.splice(0).forEach(d=>rmSync(d,{recursive:true,force:true}))); |
| 10 | describe('SqliteStore',()=>{ |
| 11 | it('creates normalized SQL tables and persists data',()=>{ |
| 12 | const f=make();const s=new SqliteStore(f);s.update(d=>({...d,accounts:[{id:'a1',tenantId:'t1',name:'اصلی',iban:'IR062960000000100324200001',bankName:'بانک',status:'ACTIVE'}]}));s.close(); |
| 13 | const db=new DatabaseSync(f);const tables=db.prepare("select name from sqlite_master where type='table' order by name").all().map((r:any)=>r.name);expect(tables).toEqual(expect.arrayContaining(['meta','accounts','beneficiaries','payments','audit']));expect(db.prepare('select count(*) as c from accounts').get()).toMatchObject({c:1});db.close(); |
| 14 | const s2=new SqliteStore(f);expect(s2.snapshot().accounts[0].id).toBe('a1');s2.close(); |
| 15 | }); |
| 16 | it('uses SQLite foreign SQL storage rather than JSON serialization',()=>{const f=make();const s=new SqliteStore(f);s.close();const db=new DatabaseSync(f);expect(db.prepare('pragma journal_mode').get()).toBeTruthy();db.close()}); |
| 17 | }); |