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

test(print): guard browser header suppression and invoice templates

davoodmehraban89 committed Oct 14, 2026 at 10:54 UTC 5e651cf1af98faa6a98b4e74675aa7b1c58653d4
1 file changed +21
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*\{[^}]*margin:\s*0\s*!important\s*;/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 +});