فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

fix(print): suppress generated headers and add regression coverage

* fix(print): suppress document title and enforce zero print page margin * test(print): guard browser header suppression and invoice templates * test(print): allow CSS template interpolation in page margin assertion

davoodmehraban89 committed Oct 14, 2026 at 11:07 UTC d5f06c2d8ae8e7080c2e2791c4a419e84748aafb
2 files changed +29 -2
src/utils/InvoicePrint.js
+8 -2
@@ -565,15 +565,21 @@ class InvoicePrintImpl {
565 <html lang="fa" dir="rtl">
566 <head>
567 <meta charset="UTF-8" />
568 - <title>چاپ فاکتور</title>
568 + <!-- Keep the print document title empty: some print engines otherwise
569 + repeat it as a browser-generated page header. -->
570 + <title></title>
571 <!-- Offline-first printing: use bundled/system fonts, no external network dependency. -->
572 <style>
573 /* Zero page margins prevent Chromium/WebView2 from reserving
574 the browser-generated date, document title and page-number
575 header/footer area. The invoice itself already has padding. */
576 + /* Browser header/footer suppression: Chromium only omits its
577 + generated title/date/URL/page number when the print margin
578 + area is zero. Physical printer margins may still apply. */
579 @page {
580 size: ${pageCss};
576 - margin: 0;
581 + margin: 0 !important;
582 + padding: 0;
583 }
584
585 * { box-sizing: border-box; margin: 0; padding: 0; }
tests/invoice-print-header-footer.test.mjs new
+21
@@ -0,0 +1,21 @@
1 +import test from 'node:test';
2 +import assert from 'node:assert/strict';
3 +import { readFileSync } from 'node:fs';
4 +
5 +const source = readFileSync(new URL('../src/utils/InvoicePrint.js', import.meta.url), 'utf8');
6 +
7 +test('print iframe does not expose an application title in browser-generated headers', () => {
8 + assert.match(source, /<title><\/title>/);
9 + assert.doesNotMatch(source, /<title>چاپ فاکتور<\/title>/);
10 +});
11 +
12 +test('print iframe uses zero page margin and keeps invoice layout padding', () => {
13 + assert.match(source, /@page\s*\{[\s\S]*?margin:\s*0\s*!important\s*;/);
14 + assert.match(source, /\.print-doc/);
15 +});
16 +
17 +test('formal, non-formal and thermal invoice templates remain available', () => {
18 + for (const template of ['_formalTemplate(', '_nonFormalTemplate(', '_thermalTemplate(']) {
19 + assert.ok(source.includes(template), `Missing invoice template: ${template}`);
20 + }
21 +});