فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(A07): generate 110 synthetic RTL invoice rows via production template
davoodmehraban89 committed
Oct 16, 2026 at 22:56 UTC
09da7d24e131790be7a85db97a7c7ba141d50fdc
1 file changed
+39
tests/windows-vm-native-print-pdf-browser.js
new
+39
@@ -0,0 +1,39 @@
1
+(async () => {
2
+ const ok=(value,msg)=>{if(!value)throw Error(msg);};
3
+ ok(!!globalThis.__TAURI_INTERNALS__?.invoke,'Not installed Windows Tauri WebView2');
4
+ ok(window.InvoicePrint?._formalTemplate,'Production print template is unavailable');
5
+ const original=(await FINORA.Storage.getAll('invoices')).find(x=>x.kind==='sale'&&x.financePosted&&x.items?.length);
6
+ ok(original,'Posted native sales invoice fixture is missing');
7
+ const count=110;
8
+ const lines=Array.from({length:count},(_,i)=>({
9
+ productName:'کالای آزمایشی '+(i+1),qty:1,price:1000,discount:0,unit:'عدد'
10
+ }));
11
+ const invoice={...original,items:lines,kind:'sale',isPreInvoice:false,
12
+ subtotal:110000,totalDiscount:0,vatEnabled:false,vatAmount:0,
13
+ grandTotal:110000,paidAmount:0,remaining:110000,paymentMethod:'credit'};
14
+ InvoicePrint.settings.template='formal';
15
+ InvoicePrint.settings.paperSize='A4';
16
+ InvoicePrint.settings.orientation='portrait';
17
+ InvoicePrint.settings.showBalance='none';
18
+ const rendered=InvoicePrint._formalTemplate(invoice,
19
+ {name:'شرکت ساختگی'}, {name:'مشتری ساختگی'},0);
20
+ ok(rendered.includes('dir="rtl"')&&rendered.includes('<thead>')&&
21
+ rendered.includes('کالای آزمایشی 110'),'RTL template rows/header missing');
22
+ const style=document.createElement('style');
23
+ style.textContent='@page{size:A4 portrait;margin:0 !important;}'
24
+ +'*{box-sizing:border-box;}'
25
+ +'html,body,table,td,th{direction:rtl;text-align:right;}'
26
+ +'html,body{font-family:"Vazirmatn FD",Tahoma,sans-serif;background:white;color:black;}'
27
+ +'body{margin:0;padding:0;}'
28
+ +'thead{display:table-header-group;}'
29
+ +'tfoot{display:table-footer-group;}'
30
+ +'tr,td,th{break-inside:avoid;page-break-inside:avoid;}'
31
+ +'.print-doc{direction:rtl !important;page-break-inside:auto;}'
32
+ +' *{-webkit-print-color-adjust:exact !important;print-color-adjust:exact !important;}';
33
+ document.head.appendChild(style);
34
+ document.body.innerHTML=rendered;
35
+ ok(document.querySelectorAll('.print-doc tbody tr').length>=110,
36
+ 'Rendered native printable invoice lost rows');
37
+ await document.fonts.ready;
38
+ return {engine:'native-WebView2-printToPDF',rtl:true,paper:'A4',itemRows:110};
39
+})()
\ No newline at end of file