فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

test(A03): seed immutable fixtures transactionally in a03-company-scope-immutable-stores.test.mjs

davoodmehraban89 committed Oct 19, 2026 at 11:29 UTC d8b3676cbbb3293710fe2eaf4955d70a25929d23
1 file changed +7 -4
tests/a03-company-scope-immutable-stores.test.mjs
+7 -4
@@ -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 { DataScope } from '../src/core/DataScope.js';
9 import { Auth } from '../src/core/Auth.js';
10 import { CompanyService } from '../src/core/CompanyService.js';
@@ -13,16 +16,16 @@ test('A03: common scoped reads do not leak another company audit history or corr
16 await StorageService.put('companies', { id: 'c2', name: 'Company Two' });
17 CompanyService.activeCompanyId = 'c1';
18
16 - await StorageService.put('audit_events', {
19 + await seedHistory('audit_events', {
20 id: 'event-c1', companyId: 'c1', commandKey: 'c1:test', eventType: 'journal_posted'
21 });
19 - await StorageService.put('audit_events', {
22 + await seedHistory('audit_events', {
23 id: 'event-c2', companyId: 'c2', commandKey: 'c2:test', eventType: 'journal_posted'
24 });
22 - await StorageService.put('document_corrections', {
25 + await seedHistory('document_corrections', {
26 id: 'cor-c1', companyId: 'c1', idempotencyKey: 'c1:cor'
27 });
25 - await StorageService.put('document_corrections', {
28 + await seedHistory('document_corrections', {
29 id: 'cor-c2', companyId: 'c2', idempotencyKey: 'c2:cor'
30 });
31 assert.deepEqual((await DataScope.list('audit_events')).map(row => row.id), ['event-c1']);