import test from 'node:test'; import assert from 'node:assert/strict'; import { publicBusinessOfflineHtml, downloadPublicBusinessOffline, } from '../../resources/js/lib/public-business-offline.ts'; const savedAt = new Date('2026-11-02T15:00:00.000Z'); const record = { slug: 'synthetic', title: 'Negócio sintético', modality: 'company_sale', amount_min: '9007199254740993.25', currency: 'MZN', province: 'Província sintética', payload: { private: 'RESERVED' }, owner_user_id: 73, }; await test('offline fiche is self-contained, preserves exact public values and identifies capture versus publication', () => { const html = publicBusinessOfflineHtml( record, 'Venda da empresa', 'https://portal.example.invalid', savedAt, ); assert.match(html, /9007199254740993\.25 MZN/); assert.match(html, /2026-11-02T15:00:00\.000Z/); assert.match(html, /Publicação no portal<\/dt>
Não indicado/); assert.match(html, /Província sintética/); assert.match( html, /href="https:\/\/portal\.example\.invalid\/negocios\/synthetic"/, ); assert.doesNotMatch( html, /RESERVED|owner_user_id|/); }); await test('untrusted text and slugs cannot create executable markup or an external source link', () => { const html = publicBusinessOfflineHtml( { ...record, slug: '//external.invalid/"', title: '', objective: ' & "value"', }, '"malicious"', 'https://portal.example.invalid', savedAt, ); assert.doesNotMatch(html, /