فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(A03): seed immutable fixtures transactionally in a03-append-only-full-restore.test.mjs
davoodmehraban89 committed
Oct 19, 2026 at 11:29 UTC
20a6222a4dbd4eb7c95e7a2f314b78bf425023bd
1 file changed
+5
-2
tests/a03-append-only-full-restore.test.mjs
+5
-2
@@ -3,6 +3,9 @@ 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
+
9
test('A03: full restore refuses to mutate prior audit events and rolls back earlier writes', async () => {
10
await StorageService.clearAll();
11
const audit = {
@@ -11,7 +14,7 @@ test('A03: full restore refuses to mutate prior audit events and rolls back earl
14
actorId: 'manager', sourceId: 'journal-1',
15
result: 'committed', safeSummary: { lineCount: 2 }
16
};
14
- await StorageService.put('audit_events', { ...audit });
17
+ await seedHistory('audit_events', { ...audit });
18
const before = await StorageService.get('audit_events', audit.id);
19
await assert.rejects(StorageService.importAll({
20
app: 'Factor-easyPro', version: 7,
@@ -41,7 +44,7 @@ test('A03: full restore preserves document corrections and rejects ID overwrite'
44
idempotencyKey: 'return:invoice-1', sourceId: 'invoice-1',
45
correctionType: 'return', resultId: 'return-1'
46
};
44
- await StorageService.put('document_corrections', { ...correction });
47
+ await seedHistory('document_corrections', { ...correction });
48
const before = await StorageService.get('document_corrections', correction.id);
49
await assert.rejects(StorageService.importAll({
50
app: 'Factor-easyPro', version: 7,