// @requirements REQ-EU-GUARANTEE-NOTICE REQ-PRODUCT-GUARANTEE-NOTICE import {test} from 'node:test'; import assert from 'node:assert/strict'; import {readFile} from 'node:fs/promises'; import {JSDOM} from 'jsdom'; import {build} from 'esbuild'; import {createElement} from 'react'; import {renderToStaticMarkup} from 'react-dom/server'; import {LegalGuaranteeNotice} from 'notabenda/react/documents'; import {buildLegalGuaranteeNotice,verifyLegalGuaranteeNotice} from 'notabenda/guarantees/content'; import {guaranteeNoticeLanguages,normalizeLegalGuaranteeNotice,renderLegalGuaranteeNotice} from 'notabenda/guarantees'; import {sha256} from 'notabenda/content'; const options={language:'en',reviewStatus:'reviewed'}; const wording={title:'Test title',imageAlt:'Test artwork alternative; full wording alongside.',fullSizeLink:'Full size',informationLink:'More information'}; test('all 24 official colour notices retain original bytes, PDF provenance and language-specific destinations',async()=>{ const manifest=JSON.parse(await readFile(new URL('../assets/guarantees/manifest.json',import.meta.url),'utf8'));assert.equal(guaranteeNoticeLanguages.length,24);assert.equal(Object.keys(manifest.assets).length,24); for(const language of guaranteeNoticeLanguages){const result=await buildLegalGuaranteeNotice({...options,language,wording}),a=manifest.assets[language],bytes=await readFile(new URL('../assets/guarantees/'+language+'.svg',import.meta.url),'utf8');assert.equal(Object.keys(result.files).length,1);assert.equal(Object.values(result.files)[0],bytes);assert.equal(sha256(bytes),a.sha256);assert.equal(new TextEncoder().encode(bytes).length,a.bytes);assert.equal(result.notice.asset.url,'/assets/guarantees/'+a.sha256+'.svg');assert.equal(verifyLegalGuaranteeNotice(result.notice).noticeId,result.notice.noticeId);assert.equal(result.notice.textAlternative,a.textAlternative);assert.match(a.textSourceSha256,/^[a-f0-9]{64}$/);assert.equal(a.textStatus,'pdf-extracted-unreviewed');assert.ok(a.textAlternative.replace(/\s+/gu,'').includes(a.informationUrl.slice(8)));assert.doesNotMatch(bytes,/!/(?:\.svg$|manifest\.json|node:|\/content\.|\/config\.|catalog|react|astro)/u.test(p))); });