import assert from 'node:assert/strict'; import { test } from 'node:test'; import { prepareDiagramHtml } from '../src/webviewHtml'; const page = `
`; test('adds one CSP and nonces every inline script', () => { const html = prepareDiagramHtml(page, { cspSource: 'vscode-resource:', nonce: 'N0NCE', theme: 'light' }); const csps = html.match(/Content-Security-Policy/g) ?? []; assert.equal(csps.length, 1); assert.match(html, /script-src ('|')nonce-N0NCE/); const scripts = html.match(/' }, }); assert.ok(!html.includes('