fix: withhold print action until bid validation finishes

This commit is contained in:
2026-09-06 15:08:56 +03:00
parent 1e36c17487
commit fb2c2b120e
6 changed files with 72 additions and 8 deletions
+19
View File
@@ -0,0 +1,19 @@
import {test} from 'node:test';
import assert from 'node:assert/strict';
import {belgeYazdir} from '../src/services/bidDocs.js';
test('validation window has no print action until replaced by the prepared document',()=>{
let html='',focused=0;
const popup={closed:false,document:{open(){html='';},write(value){html+=value;},close(){}},focus(){focused++;}};
assert.equal(belgeYazdir('Dosya kontrolü','<p role="status">Belgeler kontrol ediliyor…</p>',popup,{pending:true}),popup);
assert.match(html,/Belgeler kontrol ediliyor/);
assert.doesNotMatch(html,/<button|window\.print\(/);
assert.equal(belgeYazdir('Teklif <Cetveli>','<h1>Hazır cetvel</h1>',popup),popup);
assert.match(html,/<title>Teklif &lt;Cetveli&gt;<\/title>/);
assert.match(html,/Hazır cetvel/);
assert.match(html,/<button onclick="window\.print\(\)"/);
assert.doesNotMatch(html,/Belgeler kontrol ediliyor/);
assert.equal(focused,2);
popup.closed=true;
assert.throws(()=>belgeYazdir('Teklif','',popup),/penceresi kapatıldı/);
});