// @requirements REQ-PRODUCT-PROCESSING-LOCALIZATION REQ-PRODUCT-LOCALIZATION REQ-PRODUCT-MOBILE REQ-PRODUCT-A11Y import {test} from 'node:test'; import assert from 'node:assert/strict'; import {readFile} from 'node:fs/promises'; import {JSDOM} from 'jsdom'; import {createConsent,createProcessingChoices,mountControls,mountProcessingChoices,ProcessingChoicesError} from '@notabenda/core'; import {recordLegalRelease,registerProcessingNotice,getProcessingHead,recordProcessingRestriction} from '@notabenda/cloudflare'; import {createSyntheticStorage} from '../../packages/notabenda-cf/examples/synthetic.mjs'; import {createAccessibilityAudit} from '../../scripts/accessibility-audit.mjs'; import {serveHost} from '../host.mjs'; import data from '../dist/server-data.json' with {type:'json'}; const root=new URL('../dist/public/',import.meta.url),file=p=>readFile(new URL(p,root),'utf8'); test('the Portuguese opt-out publishes selected messages, US applicability and independent static legal pages',async()=>{ const html=await file('localization/processing/index.html'),d=new JSDOM(html).window.document,c=JSON.parse(await file('localization/processing/site.json')),notice=JSON.parse(await file('localization/processing/notice.json')); assert.equal(d.documentElement.lang,'pt-BR');assert.ok(d.querySelector('.demo-corner'));assert.equal(notice.schemaVersion,2);assert.equal(notice.scopeId,'privacy-choices-pt');assert.equal(notice.siteId,data.processing.notice.siteId);assert.deepEqual(c.jurisdictions,['US-CA']);assert.deepEqual(notice.localization.processingChoices,c.localization.processingChoices);assert.equal(d.querySelector('#count-interaction').disabled,true);assert.ok(d.querySelector('a[href="/demo/admin/processing"]'));assert.equal(d.querySelectorAll('script[type=module]').length,1); for(const n of d.querySelectorAll('script[src],link[rel=stylesheet]')){const url=n.getAttribute('src')??n.getAttribute('href');assert.ok(url.startsWith('/assets/'));assert.ok((await file(url.slice(1))).length);} assert.ok(new JSDOM(await file('examples/privacy-choices/index.html')).window.document.querySelector('a[href="/localization/processing/"]')); const denied=()=>{throw Error('Static legal pages must not allocate storage');},env={ASSETS:{fetch:async()=>new Response('Policy',{headers:{'Content-Type':'text/html'}})},WORKSPACE:{idFromName:denied,get:denied},DEMO_WORKSPACES:{idFromName:denied,get:denied}}; for(const kind of ['privacy','cookies','terms']){const legal=await file('localization/processing/'+kind+'/index.html');assert.doesNotMatch(legal,/