// @requirements REQ-GOOGLE-MODE 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,mountControls} from 'notabenda'; import {registerGoogleBasic} from 'notabenda/google'; import {serveHost} from '../host.mjs'; const root=new URL('../dist/public/',import.meta.url); test('Google Basic simulator publishes only local scripts with four explicit signals and static policy links',async()=>{ for(const prefix of ['','dark/']){const html=await readFile(new URL(prefix+'google-basic/index.html',root),'utf8'),dom=new JSDOM(html);assert.match(html,/nb-demo-google/);assert.match(html,/Local simulator/);assert.match(html,/no live Google tag/);assert.equal(dom.window.document.querySelectorAll('[data-google-signal]').length,4);assert.equal(dom.window.document.querySelectorAll('script[src^="https:"],link[href^="https:"]').length,0);assert.ok(dom.window.document.querySelector('.nb-legal-links'));assert.equal(dom.window.document.querySelector('[data-google-event]').disabled,true);const response=await serveHost(new Request('https://example.test/'+prefix+'google-basic/'),{ASSETS:{fetch:()=>new Response(html,{headers:{'Content-Type':'text/html'}})}});assert.match(response.headers.get('Content-Security-Policy'),/script-src 'self'; connect-src 'self'/);assert.equal(response.headers.get('Set-Cookie'),null);for(const kind of ['privacy','cookies','terms'])assert.doesNotMatch(await readFile(new URL(prefix+'google-basic/'+kind+'/index.html',root),'utf8'),/