سامانه صدور فاکتور و حسابداری
test: allow isolated remote invoice print checks on dedicated QA server port
davoodmehraban89 committed
Oct 11, 2026 at 16:36 UTC
9e0c0303c9f796d5416f3fa18d97e8debf591ca0
1 file changed
+5
-4
scripts/taxpayer-print.spec.js
+5
-4
@@ -1,7 +1,8 @@
1
const {test,expect}=require('@playwright/test');
2
+const PRINT_QA_BASE_URL=process.env.FINORA_TEST_BASE_URL||'http://127.0.0.1:4173/';
3
4
test('Taxpayer System print follows the approved official landscape structure',async({page})=>{
4
- await page.goto('http://127.0.0.1:4173/');
5
+ await page.goto(PRINT_QA_BASE_URL);
6
await page.waitForFunction(()=>typeof window.buildElectronicDocPage==='function'&&document.querySelector('script[src*="taxpayer-print.js"]'));
7
const html=await page.evaluate(()=>window.buildElectronicDocPage(
8
{number:'140507',date:'1405/07/08',createdAt:'1405/07/08 08:36:02',items:[{prodName:'اجاره خودروهای سواری/اجاره و تامین خودرو با راننده',qty:1,unit:'ماه',price:31033548841,lineTotal:31033548841}],vat:3103354884,vatRate:10,grandTotal:34136903725,paymentMethod:'cash'},
@@ -43,14 +44,14 @@ test('Taxpayer System print follows the approved official landscape structure',a
44
});
45
46
test('isolated print waits for the supplied image before opening print',async({page})=>{
46
- await page.goto('http://127.0.0.1:4173/');
47
+ await page.goto(PRINT_QA_BASE_URL);
48
await page.waitForFunction(()=>typeof printIsolatedDocument==='function');
49
let release;
50
const gate=new Promise(resolve=>release=resolve);
51
await page.route('**/assets/tax-organization-official.png?delayed',async route=>{await gate;await route.continue();});
52
await page.evaluate(()=>{
53
window.printCalls=0;
53
- const frame=printIsolatedDocument('<img src="http://127.0.0.1:4173/assets/tax-organization-official.png?delayed">',{paper:'A4',orientation:'landscape',widthMm:297,heightMm:210,marginMm:7});
54
+ const frame=printIsolatedDocument('<img src="'+new URL('assets/tax-organization-official.png?delayed',document.baseURI).href+'">',{paper:'A4',orientation:'landscape',widthMm:297,heightMm:210,marginMm:7});
55
frame.contentWindow.print=()=>window.printCalls++;
56
});
57
// Deliberately hold image response beyond the old 80ms print timer.
@@ -62,7 +63,7 @@ test('isolated print waits for the supplied image before opening print',async({p
63
64
65
test('all visible invoice print digits are Persian across formal, informal and taxpayer templates without mutating data',async({page})=>{
65
- await page.goto('http://127.0.0.1:4173/');
66
+ await page.goto(PRINT_QA_BASE_URL);
67
await page.waitForFunction(()=>typeof buildFormalPage==='function'&&typeof buildNonFormalPage==='function'&&typeof buildElectronicDocPage==='function'&&typeof stageInvoicePrint==='function');
68
const results=await page.evaluate(()=>{
69
window.__FINORA_PRINT_TEST_MODE=true;