import test from 'node:test'; import assert from 'node:assert/strict'; import {createDMPaint} from '../control-panel/dmpaint.mjs'; import {templateCatalogue,templateModes,renderPaintTemplate} from '../control-panel/dmpaint-templates.mjs'; import {mountPaintTemplates} from '../control-panel/public/dmpaint/templates.mjs'; const request=path=>new Request('https://cp.dunerealms.com'+path); const route=(staff=false,user={id:'person'})=>createDMPaint({}, {authenticate:async()=>user,authorise:async()=>staff}); test('five curated designs serve clans and companies equally, with fixed POL artwork excluded',()=>{ const ids=new Set(templateModes.flatMap(mode=>templateCatalogue(mode).map(d=>d.id))); assert.equal(ids.size,5);assert.deepEqual(templateCatalogue('clan'),templateCatalogue('company')); assert.deepEqual(templateCatalogue('politics'),[]); for(const mode of templateModes)for(const design of templateCatalogue(mode)){ const svg=renderPaintTemplate({mode,id:design.id,sealData:'data:image/png;base64,AAAA'}); assert.match(svg,/width="512" height="512"/);assert.doesNotMatch(svg,/<(?:script|foreignObject|style)\b|\bon\w+=|(?:https?:)?\/\/[^w]/i); const tags=[...svg.matchAll(/<\/?([a-zA-Z]+)/g)].map(m=>m[1]);assert.ok(tags.every(t=>['svg','title','g','path','circle','image','text'].includes(t))); } }); test('editable labels escape markup and colours cannot inject SVG attributes',()=>{ const options={mode:'clan',id:'desert-crest',title:'