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

test(A02): prevent stale approval after switching opening files

davoodmehraban89 committed Oct 16, 2026 at 16:52 UTC 86bb27aa7be28747e0293e1f5ecede8f8d76cfa1
1 file changed +18
tests/a02-opening-ledger-view.test.mjs
+18
@@ -60,3 +60,21 @@ test('A02: JSON preview UI calls only readonly preflight, not commit', async ()
60 AccountingView._openingReview = null;
61 }
62 });
63 +
64 +test('A02: switching input files invalidates an earlier approval', () => {
65 + const originalDocument = globalThis.document;
66 + const reportNode = { textContent: '' };
67 + try {
68 + AccountingView._openingCandidate = { periodId: 'OLD_PERIOD' };
69 + AccountingView._openingReview = { readiness: 'ready-for-review' };
70 + globalThis.document = {
71 + getElementById(id) { return id === 'openingPreviewReport' ? reportNode : null; }
72 + };
73 + AccountingView.resetOpeningPreview();
74 + assert.equal(AccountingView._openingCandidate, null);
75 + assert.equal(AccountingView._openingReview, null);
76 + assert.match(reportNode.textContent, /دوباره بررسی/);
77 + } finally {
78 + globalThis.document = originalDocument;
79 + }
80 +});