فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(A03): seed immutable fixtures transactionally in a02-opening-posting-integration.test.mjs
davoodmehraban89 committed
Oct 19, 2026 at 11:29 UTC
a5409e4149385713bee50e70cfbbc553a8585181
1 file changed
+4
-1
tests/a02-opening-posting-integration.test.mjs
+4
-1
@@ -2,6 +2,9 @@ import test from 'node:test';
2
import assert from 'node:assert/strict';
3
import 'fake-indexeddb/auto';
4
import { StorageService } from '../src/core/StorageService.js';
5
+
6
+// Seed historical fixtures atomically; standalone history writes are forbidden.
7
+const seedHistory = (store, row) => StorageService.transaction(store, tx => tx.put(store, row));
8
import { OpeningBalanceService } from '../src/core/OpeningBalanceService.js';
9
import { AccountingService } from '../src/core/AccountingService.js';
10
import { CompanyService } from '../src/core/CompanyService.js';
@@ -144,7 +147,7 @@ test('A02: failed audit insert at transaction end rolls back already inserted jo
147
const { period, input } = await setup();
148
// This unique command index simulates an audit record already committed
149
// outside of this posting; the late constraint failure must roll back all.
147
- await StorageService.put('audit_events', {
150
+ await seedHistory('audit_events', {
151
id: 'existing-opening-key', companyId: C,
152
commandKey: C + ':opening-ledger:' + period.id,
153
eventType: 'opening_posted', sourceId: 'prior-event'