const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const vm = require('node:vm'); const test = require('node:test'); const read = file => fs.readFileSync(path.join(__dirname, '..', file), 'utf8'); test('new board fields use the shared policy-aware viewer', () => { for (const [file, fields] of [ ['boards/timelineView.jade', ['this.title', 'this.descriptionSnippet', 'this']], ['boards/groupByAssigneeView.jade', ['title']], ['boards/roadmapView.jade', ['label']], ['boards/bigboardView.jade', ['title']], ['sidebar/sidebarOriginalPositions.jade', ['item.title', 'item.originalTitle']], ['boards/tableView.jade', ['row.title', 'row.listTitle', 'row.swimlaneTitle']], ['boards/charts/boardCharts.jade', ['header', 'cell']], ['lists/listHeader.jade', ['title']], ]) { const source = read(`client/components/${file}`); for (const field of fields) { assert.ok(new RegExp(`\\+viewer\\n\\s+= ${field.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?:\\n|$)`).test(source), `${file}: ${field} must use viewer`); } } assert.match(read('client/components/cards/minicard.jade'), /span\.minicard-title-text[\s\S]*?\+viewer\n\s+= getTitle/); const opened = read('client/components/cards/cardDetails.jade'); const titleBlock = opened.slice(opened.indexOf('h2.card-details-title.js-card-title('), opened.indexOf('if isWatching', opened.indexOf('h2.card-details-title.js-card-title('))); assert.match(titleBlock, /\+viewer\n\s+= getTitle/); for (const source of [titleBlock, read('client/components/cards/minicard.jade')]) { assert.doesNotMatch(source, /\+viewer\n\s+if (?:showCardNumber|currentBoard\.allowsCardNumber)/, 'card-number markup must not precede Markdown source inside viewer'); } assert.doesNotMatch(titleBlock, /\{\{\{?\s*(?:getTitle|title)\s*\}\}\}?/); assert.doesNotMatch(read('client/components/boards/timelineView.jade'), /timeline-(?:list|card)-title \{\{/); const editor = read('client/components/main/editor.js'); assert.match(editor, /setting\.renderLinksAsPlainText/); // #3218 added the custom URL-scheme allowlist beside stripLinks; the viewer // still sanitizes with the "render links as plain text" option. assert.match(editor, /sanitizeHTML\(content, \{ stripLinks, urlSchemes \}\)/); }); test('chart title adapter delegates HTML, escapes SVG markup and observes settings', () => { const calls = []; const context = { Blaze: { toHTMLWithData(template, data) { calls.push([template, data.value]); return '
Demo & 👍
'; } }, Template: { chartTitleViewer: 'shared viewer' }, ReactiveCache: { getCurrentSetting() { calls.push('settings'); } }, document: { createElement() { return { textContent: 'Demo & 👍