فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(A05): block draft journal and repeated fiscal close in installed native UI
davoodmehraban89 committed
Oct 16, 2026 at 23:44 UTC
71a9680363a3f25e27b67d0681a835af96911d6a
1 file changed
+46
tests/windows-vm-native-functional-matrix.cjs
+46
@@ -602,6 +602,34 @@ async function fiscalCloseGuardrails() {
602
message.querySelector('.toast-close')?.click();
603
check(!document.querySelector('.toast-error'), 'Expected fiscal rejection toast remained');
604
await store.delete('stocktakes', stocktakeId);
605
+
606
+ // A05: another real fiscal-close attempt must still be blocked while
607
+ // there is an unfinished draft ledger in the same isolated period.
608
+ const draftId = 'vm-a05-unposted-draft-journal';
609
+ await store.put('journal_entries', {
610
+ id: draftId, companyId: company.id, periodId: period.id,
611
+ date: '1404/06/15', status: 'draft', sourceType: 'manual',
612
+ description: 'VM-only pending draft prevents closure'
613
+ });
614
+ confirmClose();
615
+ let draftToast = null;
616
+ for (let i = 0; i < 60; i++) {
617
+ draftToast = [...document.querySelectorAll('.toast-error')]
618
+ .find(x => x.textContent.includes('اسناد پیشنویس'));
619
+ if (draftToast) break;
620
+ await wait(100);
621
+ }
622
+ check(draftToast, 'Native fiscal closure ignored the pending draft journal');
623
+ check((await store.get('fiscal_periods', period.id))?.closed === false,
624
+ 'Rejected draft-journal closure changed period state');
625
+ check((await store.getAll('audit_events'))
626
+ .filter(x => x.companyId === company.id &&
627
+ x.eventType === 'period_closed').length === auditCount,
628
+ 'Rejected draft-journal closure wrote a successful close audit');
629
+ draftToast.querySelector('.toast-close')?.click();
630
+ check(!document.querySelector('.toast-error'),
631
+ 'Expected unposted-journal rejection toast remained visible');
632
+ await store.delete('journal_entries', draftId);
633
confirmClose();
634
let closed = null;
635
for (let i = 0; i < 70; i++) {
@@ -617,12 +645,30 @@ async function fiscalCloseGuardrails() {
645
check(closureAudits.length === 1 &&
646
closureAudits[0].actorId === FINORA.Auth.current().id,
647
'Successful fiscal closure did not produce exactly one actor-scoped audit');
648
+ // Already-closed periods must not be closed again via the actual confirmation
649
+ // action, nor silently insert another period_closed audit receipt.
650
+ confirmClose();
651
+ let closedToast = null;
652
+ for (let i = 0; i < 60; i++) {
653
+ closedToast = [...document.querySelectorAll('.toast-error')]
654
+ .find(x => x.textContent.includes('دوره مالی بسته است'));
655
+ if (closedToast) break;
656
+ await wait(100);
657
+ }
658
+ check(closedToast, 'Duplicate native close did not visibly reject');
659
+ check((await store.getAll('audit_events'))
660
+ .filter(x => x.companyId === company.id &&
661
+ x.eventType === 'period_closed' && x.sourceId === period.id).length === 1,
662
+ 'Duplicate fiscal close created a second audit receipt');
663
+ closedToast.querySelector('.toast-close')?.click();
664
check(!document.querySelector('.toast-error') && !document.querySelector('.modal-backdrop'),
665
'Fiscal guardrail test left an unexpected UI error or modal');
666
return {
667
openStocktakeBlocked: true,
668
+ draftJournalBlocked: true,
669
failedCloseRolledBack: true,
670
successfulCloseCommitted: true,
671
+ duplicateCloseRejected: true,
672
singleAuditReceipt: true
673
};
674
}