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

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

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

Synced Dec 3, 17:00 UTC

test: verify purchase popup visible Persian digits with original data unchanged

davoodmehraban89 committed Oct 11, 2026 at 16:40 UTC f9129f5dc6fc52a78e76aa5e9bfe21b383926efd
1 file changed +32
scripts/taxpayer-print.spec.js
+32
@@ -114,3 +114,35 @@ test('all visible invoice print digits are Persian across formal, informal and t
114 }
115 expect(results.attributes).toEqual({title:'1405',id:'TAX12A340',text:'شماره TAX۱۲A۳۴۰، تاریخ ۱۴۰۵/۰۷/۱۹'});
116 });
117 +
118 +
119 +test('purchase print popup displays Persian digits while keeping purchase master data untouched',async({page})=>{
120 + await page.goto(PRINT_QA_BASE_URL);
121 + await page.waitForFunction(()=>typeof window.purPrint==='function'&&typeof localizePrintTextNodes==='function');
122 + const actual=await page.evaluate(()=>{
123 + const userId='PRINT_QA_ONLY';
124 + currentUser={id:userId};
125 + const purchase={id:'QA-PUR-1',ownerUserId:userId,number:'BUY-14A90',date:'۱۴۰5/٠۷/19',
126 + supplierName:'فروشنده 12',contractNumber:'CON-04',projectName:'پروژه 12',
127 + paymentMethod:'cash',items:[{prodName:'سیمان تیپ 2',unit:'کیسه',qty:3,price:25000,lineTotal:75000}],
128 + subtotal:75000,discount:0,vat:0,grandTotal:75000,description:'تحویل 3 کیسه'};
129 + datastore.purchases=[purchase];
130 + const oldOpen=window.open;
131 + let popupDoc;
132 + window.open=()=>{
133 + popupDoc=document.implementation.createHTMLDocument('purchase print QA');
134 + return {document:popupDoc};
135 + };
136 + try{window.purPrint(purchase.id)}finally{window.open=oldOpen}
137 + const walker=popupDoc.createTreeWalker(popupDoc.body,NodeFilter.SHOW_TEXT);let node,text='';
138 + while((node=walker.nextNode()))if(node.parentElement&&!/^(STYLE|SCRIPT)$/i.test(node.parentElement.tagName))text+=node.nodeValue;
139 + return {text,originalNumber:purchase.number,originalDate:purchase.date,total:purchase.grandTotal};
140 + });
141 + expect(actual.text).toContain('BUY-۱۴A۹۰');
142 + expect(actual.text).toContain('۱۴۰۵/۰۷/۱۹');
143 + expect(actual.text).toContain('۷۵٬۰۰۰');
144 + expect(actual.text).not.toMatch(/[0-9٠-٩]/);
145 + expect(actual.originalNumber).toBe('BUY-14A90');
146 + expect(actual.originalDate).toBe('۱۴۰5/٠۷/19');
147 + expect(actual.total).toBe(75000);
148 +});