فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(A07): assert real installed WebView2 exports valid multipage PDF
davoodmehraban89 committed
Oct 16, 2026 at 22:56 UTC
004eb05e6b941193c5f376c7f2704c3d3005a987
1 file changed
+22
tests/windows-vm-installed-tauri-cdp.cjs
+22
@@ -399,6 +399,28 @@ async function connect(url) {
399
measured.timingsMs.snapshotExport >= 0);
400
report.nativePerformance = measured;
401
}
402
+ if (mode === 'fresh') {
403
+ // LAST operation: real installed WebView2 PDF engine, using production
404
+ // RTL formal-invoice renderer with 110 synthetic items only.
405
+ const code = fs.readFileSync(
406
+ path.join(__dirname, 'windows-vm-native-print-pdf-browser.js'), 'utf8');
407
+ const template = await cdp.evaluate(code, 60000);
408
+ assert.equal(template.itemRows, 110);
409
+ const printed = await cdp.command('Page.printToPDF', {
410
+ printBackground: true, preferCSSPageSize: true,
411
+ displayHeaderFooter: false
412
+ }, 90000);
413
+ assert.ok(printed?.data, 'Installed WebView2 returned no PDF');
414
+ const pdf = Buffer.from(printed.data, 'base64');
415
+ assert.ok(pdf.length > 10000 && pdf.subarray(0, 5).toString('ascii') === '%PDF-',
416
+ 'Invalid WebView2 PDF result');
417
+ const pages = [...pdf.toString('latin1').matchAll(/\/Type\s*\/Page\b/g)].length;
418
+ assert.ok(pages >= 2, 'Invoice PDF is not multipage: ' + pages);
419
+ const filename = 'a07-native-rtl-multipage-invoice.pdf';
420
+ fs.writeFileSync(path.join(path.dirname(reportPath), filename), pdf);
421
+ report.nativePrint = { ...template, pages, pdfBytes: pdf.length,
422
+ filename, physicalPrinter: 'not-tested' };
423
+ }
424
report.status = 'PASSED';
425
console.log(JSON.stringify(report, null, 2));
426
} catch (err) {