سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 18:15 UTC
test: F2 on real formal invoice saves only draft and rejects incomplete form
davoodmehraban89 committed
Oct 12, 2026 at 00:07 UTC
6d0be0fb2b7d85d9e31730c8715e059a66484942
1 file changed
+19
scripts/accounting-document-workflow.spec.js
+19
@@ -131,3 +131,22 @@ test('cannot finalize draft if fiscal posting chart has no required account; dra
131
expect(remoteInvoices(server)[0].accountingStatus).toBe('draft');
132
expect([...server.records.values()].filter(x=>x.collection==='journalVouchers')).toHaveLength(0);
133
});
134
+
135
+
136
+test('F2 validates formal invoice then saves a draft without posting any financial journal',async({page})=>{
137
+ const server=fakeServer();await installHarness(page,server);await authenticatedMockBrowser(page);
138
+ await page.keyboard.press('F2');
139
+ expect(remoteInvoices(server)).toHaveLength(0);
140
+ expect(await page.evaluate(()=>window.__f0Alerts.at(-1))).toMatch(/حداقل یک کالا|خدمت معتبر/);
141
+ await fillInvoice(page,'F2-SAFE-DRAFT-001',2);
142
+ await page.keyboard.press('F2');
143
+ await expect.poll(()=>remoteInvoices(server).length,{timeout:14000}).toBe(1);
144
+ const saved=remoteInvoices(server)[0];
145
+ expect(saved.number).toBe('F2-SAFE-DRAFT-001');
146
+ expect(saved.accountingStatus).toBe('draft');
147
+ expect(saved.documentStatus).toBe('draft');
148
+ expect([...server.records.values()].filter(x=>x.collection==='journalVouchers')).toHaveLength(0);
149
+ await page.keyboard.press('F2');
150
+ expect(remoteInvoices(server)).toHaveLength(1);
151
+ expect([...server.records.values()].filter(x=>x.collection==='journalVouchers')).toHaveLength(0);
152
+});