@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / d9a898c
Fork 0

سامانه صدور فاکتور و حسابداری

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 4, 13:00 UTC

test(expense): normalize Persian currency assertion and capture scoped DOM save diagnostics

davoodmehraban89 committed Oct 14, 2026 at 11:57 UTC d9a898cf8aa7f11f5e533524a2c34f81662e7e3e
1 file changed +7 -1
scripts/accounting-document-workflow.spec.js
+7 -1
@@ -563,7 +563,7 @@ test('expense same-form correction preserves one row, posted history and project
563 await page.evaluate(()=>navigateShell('accounting','view-journal','documents'));
564 await expect(page.locator('#finora-expense-document-management-body tr')).toHaveCount(1);
565 await page.locator('#finora-expense-document-management-body [data-doc-action="edit"]').click();
566 - await expect(page.locator('#trx-amount-input')).toHaveValue('1000');
566 + await expect.poll(async()=>page.evaluate(()=>parseFormattedNumber(document.getElementById('trx-amount-input').value))).toBe(1000);
567 await expect(page.locator('#trx-kind-input')).toHaveValue('expense');
568 await expect(page.locator('#trx-desc-input')).toHaveValue('ثبت اولیه آزمایشی');
569 await page.evaluate(()=>cancelExpenseEdit());
@@ -575,6 +575,8 @@ test('expense same-form correction preserves one row, posted history and project
575 await page.locator('#trx-desc-input').fill('اصلاح در همان فرم');
576 const rpcAtSave=server.rpcCount;
577 await page.locator('#expense-save-btn').click();
578 + await page.waitForTimeout(900);
579 + console.log('EXPENSE_TEST_DIAGNOSTIC',JSON.stringify(await page.evaluate(()=>({alerts:window.__f0Alerts,editing:expenseEditingId,rows:getMyExpenses().map(x=>({id:x.id,original:x.correctsExpenseId,accountingStatus:x.accountingStatus,amount:x.amount})),sync:{pending:syncPending,running:syncRunning,fail:syncFailCount}}))));
580 await expect.poll(()=>remoteExpenses(server).filter(x=>x.correctsExpenseId===id&&x.accountingStatus==='posted').length,{timeout:20000}).toBe(1);
581 await page.waitForFunction(()=>!syncRunning&&!syncPending);
582 expect(server.rpcCount-rpcAtSave).toBe(1);
@@ -616,6 +618,8 @@ test('income correction and cancellation preserve initial audit and eliminate ac
618 await expect(page.locator('#trx-kind-input')).toHaveValue('income');
619 await page.locator('#trx-amount-input').fill('950');
620 await page.locator('#expense-save-btn').click();
621 + await page.waitForTimeout(900);
622 + console.log('EXPENSE_TEST_DIAGNOSTIC',JSON.stringify(await page.evaluate(()=>({alerts:window.__f0Alerts,editing:expenseEditingId,rows:getMyExpenses().map(x=>({id:x.id,original:x.correctsExpenseId,accountingStatus:x.accountingStatus,amount:x.amount})),sync:{pending:syncPending,running:syncRunning,fail:syncFailCount}}))));
623 await expect.poll(()=>remoteExpenses(server).filter(x=>x.correctsExpenseId===id&&x.accountingStatus==='posted').length,{timeout:20000}).toBe(1);
624 const replacement=remoteExpenses(server).find(x=>x.correctsExpenseId===id);
625 expect(await page.evaluate(()=>getProjectFinancials('').income)).toBe(950);
@@ -644,6 +648,8 @@ test('expense amendment refuses mismatched kind and failed single RPC does not p
648 await page.evaluate(id=>editExpense(id),id);
649 await page.locator('#trx-amount-input').fill('800');
650 await page.locator('#expense-save-btn').click();
651 + await page.waitForTimeout(900);
652 + console.log('EXPENSE_FAIL_DIAGNOSTIC',JSON.stringify(await page.evaluate(()=>({alerts:window.__f0Alerts,editing:expenseEditingId,rows:getMyExpenses().map(x=>({id:x.id,source:x.correctsExpenseId,status:x.accountingStatus})),sync:{pending:syncPending,running:syncRunning,fail:syncFailCount}}))));
653 await expect.poll(async()=>await page.evaluate(()=>window.__f0Alerts.some(x=>x.includes('ثبت اصلاح تأیید نشد'))),{timeout:9000}).toBe(true);
654 expect(server.failCount).toBe(1);
655 expect(remoteExpenses(server)).toEqual([original]);