'use strict'; // Board Settings / Board View (docs/Features/Board-Sidebar/Board-Settings/Board-View.md): // per board, which Board View menu entries a public / private board offers // and which one it opens in. // // Pins: the menu entry sits in Board Settings directly above Swimlane; the // popup has the five columns in order and hides the two public ones when // Admin Panel hides public boards; every view of the Board View menu has a // row, in the menu's order, with the menu's own label key; the three schema // fields and the two setters exist; the pure module's radio semantics // (one default per side, a default is always shown, hiding the default is // refused); the view menu filters by the board and Utils.boardView() falls // back to the board's default so nobody is stuck on a hidden view; and the // four new column headers are translated in every locale. // // Run: node tests/boardViewSettings.test.cjs const assert = require('assert'); const fs = require('fs'); const path = require('path'); const ROOT = path.join(__dirname, '..'); const read = file => fs.readFileSync(path.join(ROOT, file), 'utf8'); let passed = 0; function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); } console.log('boardViewSettings:'); const bvs = require('../models/lib/boardViewSettings.js'); const sidebarJade = read('client/components/sidebar/sidebar.jade'); const sidebarJs = read('client/components/sidebar/sidebar.js'); const boardHeaderJade = read('client/components/boards/boardHeader.jade'); const boardHeaderJs = read('client/components/boards/boardHeader.js'); const utilsJs = read('client/lib/utils.js'); const boardsJs = read('models/boards.js'); const en = JSON.parse(read('imports/i18n/data/en.i18n.json')); const COLUMN_KEYS = [ 'default-on-public-board', 'show-on-public-board', 'default-on-private-board', 'show-on-private-board', 'description', ]; // ---------------------------------------------------------------- the menu test('Board Settings lists "Board View" directly above "Swimlane", board-admin only', () => { // The Board Settings menu was reordered into Rules / Change color / Change // Background Image, then Board View / Swimlane / List / Card, then Export / // Notifications / Outgoing Webhooks, then Archive (tests/boardMenuOrder. // test.cjs). Board View kept its place directly above Swimlane, so every // assertion here still holds as written. const at = sidebarJade.indexOf('a.js-open-board-view-settings'); const swimlane = sidebarJade.indexOf('a.js-open-board-swimlane-settings'); assert.ok(at !== -1, 'the Board View entry exists'); assert.ok(at < swimlane, 'Board View comes before Swimlane'); const between = sidebarJade.slice(at, swimlane); assert.ok(!/a\.js-open-board-/.test(between.slice(1)), 'nothing else sits between Board View and Swimlane'); const entry = sidebarJade.slice(at, at + 120); assert.ok(entry.includes("{{_ 'board-view'}}"), 'it is labelled with the existing board-view key'); const admin = sidebarJade.lastIndexOf('if currentUser.isBoardAdmin', at); assert.ok(admin !== -1 && at - admin < 500, 'it is inside the isBoardAdmin block'); assert.ok(/'click \.js-open-board-view-settings': Popup\.open\('boardViewSettings', \{ titleKey: 'board-view' \}\)/.test(sidebarJs), 'the click opens boardViewSettings titled with the existing board-view key'); assert.strictEqual(en['board-view'], 'Board View'); }); // --------------------------------------------------------------- the popup const popupAt = sidebarJade.indexOf('template(name="boardViewSettingsPopup")'); const popup = sidebarJade.slice(popupAt, sidebarJade.indexOf('\ntemplate(', popupAt + 1)); test('the popup exists and its header row has the five columns in order', () => { assert.ok(popupAt !== -1, 'boardViewSettingsPopup template exists'); const header = popup.slice(0, popup.indexOf('each boardViewRows')); let last = -1; COLUMN_KEYS.forEach(key => { const at = header.indexOf(`h4 {{_ '${key}'}}`); assert.ok(at !== -1, `header column ${key}`); assert.ok(at > last, `${key} is in order`); last = at; }); assert.ok(/form\.board-view-settings/.test(popup), 'same table pattern as Card Settings (a form of rows)'); }); test('the two public columns are not rendered when Admin Panel hides public boards', () => { // Both the header cells and the row cells sit under `unless // publicBoardsHidden`, and the helper reads the one setting Admin Panel / // Settings / Visibility / "Public boards" writes. const header = popup.slice(0, popup.indexOf('each boardViewRows')); const guardAt = header.indexOf('unless publicBoardsHidden'); assert.ok(guardAt !== -1, 'header public columns are guarded'); assert.ok(header.indexOf("'default-on-public-board'") > guardAt && header.indexOf("'show-on-public-board'") > guardAt); assert.ok(header.indexOf("'default-on-private-board'") > header.indexOf("'show-on-public-board'")); const rows = popup.slice(popup.indexOf('each boardViewRows')); const rowGuard = rows.indexOf('unless ../publicBoardsHidden'); assert.ok(rowGuard !== -1, 'row public cells are guarded'); assert.ok(rows.indexOf('data-visibility="public"') > rowGuard); assert.ok(/publicBoardsHidden\(\) \{[\s\S]*?tableVisibilityMode-allowPrivateOnly/.test(sidebarJs), 'publicBoardsHidden reads tableVisibilityMode-allowPrivateOnly'); assert.ok(/hide-public-columns/.test(popup) && /\.board-view-settings\.hide-public-columns \.board-view-settings-row \{\s*grid-template-columns: 1fr 1fr 2fr;/.test(read('client/components/sidebar/sidebar.css')), 'the table collapses to three columns'); assert.ok(/\.board-view-settings-row \{[\s\S]*?grid-template-columns: 1fr 1fr 1fr 1fr 2fr;/.test(read('client/components/sidebar/sidebar.css')), 'five columns otherwise'); }); test('every row has a Default and a Show checkbox for each side, and the label the menu uses', () => { const rows = popup.slice(popup.indexOf('each boardViewRows')); ['public', 'private'].forEach(side => { assert.ok(rows.includes(`a.flex.js-board-view-default(data-visibility="${side}"`), `Default on ${side}`); assert.ok(rows.includes(`a.flex.js-board-view-show(data-visibility="${side}"`), `Show on ${side}`); }); assert.ok(rows.includes('| {{_ labelKey}}'), 'the Description cell is the view label key'); assert.ok(rows.includes('.board-view-settings-row.js-board-view-row(data-view="{{view}}")')); assert.ok(/boardViewRows\(\) \{[\s\S]*?boardViewSettings\.orderedBoardViews\(board\)/.test(sidebarJs), 'rows come from the shared BOARD_VIEWS table, in the board\'s order'); }); // ------------------------------------------- one row per view, menu order const menu = boardHeaderJade.slice(boardHeaderJade.indexOf('template(name="boardChangeViewPopup")'), boardHeaderJade.indexOf('\n//- The Create Board form')); test('the Board View menu and the popup render the same BOARD_VIEWS table, every view once, Swimlanes first', () => { // The menu is rendered from the table (one `each` loop), so the popup's // rows and the menu's entries are the same list by construction; every // view has a click handler (per-view class), a label key and an icon. assert.ok(bvs.BOARD_VIEWS.length >= 25, `the table has ${bvs.BOARD_VIEWS.length} views`); assert.match(menu, /each boardViewMenuEntries\n\s*if groupLabelKey\n\s*li\.board-view-group-heading \{\{_ groupLabelKey\}\}\n\s*li\n\s*a\.js-board-view-entry\(class="\{\{jsClass\}\}"\)\n\s*i\.fa\(class="\{\{icon\}\}"\)\n\s*\| \{\{_ labelKey\}\}/); bvs.BOARD_VIEWS.forEach(v => { assert.ok(typeof en[v.labelKey] === 'string' && en[v.labelKey], `${v.labelKey} is an English key`); assert.ok(/^fa-[a-z-]+$/.test(v.icon), `${v.view} has an icon`); assert.ok(boardHeaderJs.includes(`'click .${bvs.boardViewJsClass(v.view)}'`), `${v.view} has a click handler`); }); assert.strictEqual(bvs.BOARD_VIEWS[0].view, 'board-view-swimlanes'); assert.strictEqual(bvs.BOARD_VIEWS[0].labelKey, 'swimlanes'); assert.ok(!/with "board-view-/.test(menu), 'no static entry is left beside the loop (negative)'); }); test('a view the menu does not have is not a row, and a duplicate is not either (negative)', () => { assert.ok(!bvs.isKnownBoardView('board-view-nope')); assert.strictEqual(new Set(bvs.BOARD_VIEWS.map(v => v.view)).size, bvs.BOARD_VIEWS.length); }); // ------------------------------------------------------------- the schema test('the board schema has boardViewSettings, defaultPublicBoardView and defaultPrivateBoardView', () => { assert.ok(/boardViewSettings: \{[\s\S]*?type: Object,\s*blackbox: true,\s*optional: true,/.test(boardsJs)); ['defaultPublicBoardView', 'defaultPrivateBoardView'].forEach(field => { const re = new RegExp(`${field}: \\{[\\s\\S]*?type: String,\\s*optional: true,\\s*defaultValue: 'board-view-swimlanes',`); assert.ok(re.test(boardsJs), `${field} defaults to Swimlanes`); }); assert.strictEqual(bvs.DEFAULT_BOARD_VIEW, 'board-view-swimlanes'); }); test('the Board instance setters apply the pure modifiers and write nothing on a refused click', () => { assert.ok(/async setBoardViewShown\(view, visibility, shown\) \{\s*const \$set = boardViewSettings\.showBoardViewModifier\(this, view, visibility, shown\);\s*if \(!\$set\) return false;\s*return await Boards\.updateAsync\(this\._id, \{ \$set \}\);/.test(boardsJs)); assert.ok(/async setDefaultBoardView\(view, visibility\) \{\s*const \$set = boardViewSettings\.defaultBoardViewModifier\(this, view, visibility\);\s*if \(!\$set\) return false;\s*return await Boards\.updateAsync\(this\._id, \{ \$set \}\);/.test(boardsJs)); assert.ok(sidebarJs.includes('board.setBoardViewShown(view, visibility, !board.isBoardViewShown(view, visibility))')); assert.ok(sidebarJs.includes('board.setDefaultBoardView(view, visibility)')); // Who may persist: the same board-admin allow rule as every board setting. assert.ok(/update: allowIsBoardAdminOrSiteAdmin/.test(read('server/permissions/boards.js'))); }); // ------------------------------------------------------ the pure decisions test('a board that never opened the popup shows every view on both sides and opens in Swimlanes', () => { const board = { permission: 'public' }; assert.strictEqual(bvs.visibleBoardViews(board, 'public').length, bvs.BOARD_VIEWS.length); assert.strictEqual(bvs.visibleBoardViews(board, 'private').length, bvs.BOARD_VIEWS.length); assert.strictEqual(bvs.defaultBoardView(board, 'public'), 'board-view-swimlanes'); assert.strictEqual(bvs.defaultBoardView(board, 'private'), 'board-view-swimlanes'); assert.strictEqual(bvs.defaultBoardView({}, 'bogus'), 'board-view-swimlanes'); assert.strictEqual(bvs.resolveBoardView(board, undefined), 'board-view-swimlanes'); assert.strictEqual(bvs.resolveBoardView(board, 'board-view-lists'), 'board-view-lists'); }); test('Show is per side: hiding on public leaves private shown, and vice versa', () => { const set = bvs.showBoardViewModifier({ permission: 'public' }, 'board-view-cal', 'public', false); assert.deepStrictEqual(set, { 'boardViewSettings.board-view-cal.showOnPublic': false }); const board = { boardViewSettings: { 'board-view-cal': { showOnPublic: false } } }; assert.strictEqual(bvs.isBoardViewShown(board, 'board-view-cal', 'public'), false); assert.strictEqual(bvs.isBoardViewShown(board, 'board-view-cal', 'private'), true); assert.strictEqual(bvs.isBoardViewShown(board, 'board-view-lists', 'public'), true); assert.deepStrictEqual(bvs.showBoardViewModifier(board, 'board-view-cal', 'private', false), { 'boardViewSettings.board-view-cal.showOnPrivate': false }); assert.deepStrictEqual(bvs.showBoardViewModifier(board, 'board-view-cal', 'public', true), { 'boardViewSettings.board-view-cal.showOnPublic': true }); }); test('Default is a radio per side: setting one un-sets the previous, and it also shows the view', () => { const board = { defaultPublicBoardView: 'board-view-swimlanes', defaultPrivateBoardView: 'board-view-swimlanes', boardViewSettings: { 'board-view-roadmap': { showOnPublic: false, showOnPrivate: false } }, }; const set = bvs.defaultBoardViewModifier(board, 'board-view-roadmap', 'public'); assert.deepStrictEqual(set, { defaultPublicBoardView: 'board-view-roadmap', 'boardViewSettings.board-view-roadmap.showOnPublic': true, }); // Apply it the way Mongo would and read back: one default, the old one gone. const after = { ...board, defaultPublicBoardView: 'board-view-roadmap', boardViewSettings: { 'board-view-roadmap': { showOnPublic: true, showOnPrivate: false } } }; assert.strictEqual(bvs.defaultBoardView(after, 'public'), 'board-view-roadmap'); assert.strictEqual(bvs.defaultBoardView(after, 'private'), 'board-view-swimlanes', 'the private default is untouched'); assert.strictEqual(bvs.isBoardViewShown(after, 'board-view-roadmap', 'public'), true); assert.strictEqual(bvs.isBoardViewShown(after, 'board-view-roadmap', 'private'), false, 'the private Show is untouched'); const only = bvs.BOARD_VIEWS.filter(v => bvs.defaultBoardView(after, 'public') === v.view); assert.strictEqual(only.length, 1, 'exactly one default on public'); }); test('the default view cannot be hidden, and an unknown view is refused (negative)', () => { const board = { defaultPublicBoardView: 'board-view-lists', defaultPrivateBoardView: 'board-view-swimlanes' }; assert.strictEqual(bvs.showBoardViewModifier(board, 'board-view-lists', 'public', false), null, 'public default stays shown'); assert.strictEqual(bvs.showBoardViewModifier(board, 'board-view-swimlanes', 'private', false), null, 'private default stays shown'); assert.notStrictEqual(bvs.showBoardViewModifier(board, 'board-view-lists', 'private', false), null, 'Lists is not the private default, so it may be hidden there'); assert.strictEqual(bvs.showBoardViewModifier(board, 'board-view-nope', 'public', false), null); assert.strictEqual(bvs.defaultBoardViewModifier(board, 'board-view-nope', 'public'), null); assert.strictEqual(bvs.defaultBoardViewModifier(board, '', 'public'), null); }); test('resolveBoardView never leaves a user on a hidden view: it falls back to that side\'s default, then Swimlanes', () => { const board = { permission: 'public', defaultPublicBoardView: 'board-view-gantt', defaultPrivateBoardView: 'board-view-table', boardViewSettings: { 'board-view-cal': { showOnPublic: false, showOnPrivate: true }, 'board-view-gantt': { showOnPublic: true }, }, }; assert.strictEqual(bvs.resolveBoardView(board, 'board-view-cal'), 'board-view-gantt', 'hidden on public -> public default'); assert.strictEqual(bvs.resolveBoardView({ ...board, permission: 'private' }, 'board-view-cal'), 'board-view-cal', 'shown on private -> kept'); assert.strictEqual(bvs.resolveBoardView({ ...board, permission: 'private' }, undefined), 'board-view-table', 'no choice -> private default'); assert.strictEqual(bvs.resolveBoardView(board, 'not-a-view'), 'board-view-gantt'); // A hand-edited document whose default is itself hidden still renders Swimlanes. const broken = { permission: 'public', defaultPublicBoardView: 'board-view-gantt', boardViewSettings: { 'board-view-gantt': { showOnPublic: false } } }; assert.strictEqual(bvs.resolveBoardView(broken, 'board-view-gantt'), 'board-view-swimlanes'); assert.strictEqual(bvs.resolveBoardView(null, 'board-view-cal'), 'board-view-cal', 'off a board the stored choice is returned'); }); // ------------------------------------------------------- applied in the UI test('the Board View menu lists only the views shown for the board\'s visibility, in the board\'s order', () => { // The viewer is passed too, deliberately: a public board shows its public // views to visitors and its private views to members (boardViewAudience). assert.ok(/boardViewMenuEntries\(\) \{[\s\S]*?return boardViewMenuEntries\(board, Utils\.boardView\(\), allowBoardView, Meteor\.userId\(\)\)/.test(boardHeaderJs), 'the menu also leaves out views the instance disabled (#6736)'); assert.ok(boardHeaderJs.includes("require('/models/lib/boardViewSettings')")); const board = { permission: 'public', boardViewOrder: ['board-view-pulse', 'board-view-lists'], boardViewSettings: { 'board-view-lists': { showOnPublic: false }, 'board-view-cal': { showOnPrivate: false } }, }; const pub = bvs.boardViewMenuEntries(board, 'board-view-pulse'); // Grouped since 2026-11-20: Pulse leads its own group (Overview), the board // group starts with Swimlanes, and Lists is hidden on public. const overview = pub.filter(e => bvs.BOARD_VIEWS.find(v => v.view === e.view).group === 'overview').map(e => e.view); assert.strictEqual(overview[0], 'board-view-pulse', 'the custom order inside its group'); assert.strictEqual(pub[0].view, 'board-view-swimlanes'); assert.ok(!pub.some(e => e.view === 'board-view-lists')); assert.ok(pub.some(e => e.view === 'board-view-cal'), 'Calendar is hidden on private only'); const pulse = pub.find(e => e.view === 'board-view-pulse'); assert.strictEqual(pulse.isCurrent, true); assert.strictEqual(pulse.jsClass, 'js-open-pulse-view'); assert.strictEqual(pulse.groupLabelKey, 'board-view-group-overview', 'the first of its group carries the heading'); const priv = bvs.boardViewMenuEntries({ ...board, permission: 'private' }, 'board-view-cal'); assert.ok(priv.some(e => e.view === 'board-view-lists') && !priv.some(e => e.view === 'board-view-cal')); assert.ok(priv.every(e => !e.isCurrent), 'the hidden current view is ticked nowhere'); }); // ------------------------------------------------------------ reordering // Drag and drop replaced the up/down arrows (2026-10-02), as in Board // Settings / Card: the handle where the arrows were when drag handles are on, // else the icon and label; Up/Down keys on a focused row still move a step. test('each popup row reorders by drag and drop, through a handle or its label, and by the arrow keys', () => { const rows = popup.slice(popup.indexOf('each boardViewRows')); assert.ok(!rows.includes('js-board-view-order-up') && !rows.includes('js-board-view-order-down'), 'no arrows left (negative)'); assert.ok(popup.includes('.board-view-settings-rows.js-board-view-sortable')); assert.ok(rows.includes('if showDragHandles\n a.flex.board-view-order-handle.js-board-view-order-handle(href="#" draggable="false" role="button" title="{{_ \'drag-to-reorder\'}}"')); assert.ok(rows.includes('span(class="{{#unless showDragHandles}}js-board-view-order-handle board-view-drag-label{{/unless}}" tabindex="{{#unless showDragHandles}}0{{/unless}}"')); assert.match(en['drag-to-reorder'], /Drag to reorder/); assert.match(sidebarJs, /Template\.boardViewSettingsPopup\.onRendered\(function \(\) \{\s*reorderOnDrop\(this\.\$\('\.js-board-view-sortable'\), \{\s*items: '> \.js-board-view-row', handle: '\.js-board-view-order-handle',/); assert.match(sidebarJs, /drop: \(view, views\) => Utils\.getCurrentBoard\(\)\?\.setVisibleBoardViewOrder\(views, allowBoardView\)/); assert.match(sidebarJs, /showDragHandles\(\) \{\s*return Utils\.showDragHandles\(\);/); assert.match(sidebarJs, /'keydown \.js-board-view-order-handle'\(evt\) \{[\s\S]*?board\.moveBoardView\(evt\.currentTarget\.closest\('\[data-view\]'\)\.dataset\.view, direction, allowBoardView\)/); assert.match(boardsJs, /async setVisibleBoardViewOrder\(visibleOrder, allowView\) \{[\s\S]*?reorderVisibleBoardViews\(this\.boardViewOrder, visibleOrder, allowView\)/); // The drop's arithmetic: the shown rows take the shown slots, a hidden view keeps its place. const allow = view => view !== 'board-view-table'; const order = bvs.normalizeBoardViewOrder(); const shown = order.filter(allow); const dropped = [shown[1], shown[0], ...shown.slice(2)]; const next = bvs.reorderVisibleBoardViews(order, dropped, allow); assert.strictEqual(next.indexOf('board-view-table'), order.indexOf('board-view-table')); assert.deepStrictEqual(next.filter(allow), dropped); // Negative: a drop that loses or repeats a row changes nothing. assert.deepStrictEqual(bvs.reorderVisibleBoardViews(order, dropped.slice(1), allow), order); assert.deepStrictEqual(bvs.reorderVisibleBoardViews(order, [dropped[0], ...dropped.slice(0, -1)], allow), order); // #6736: rows and moves leave out the views the instance disabled // (models/lib/instanceFeatures.js); tests/instanceFeatures.test.cjs pins why. assert.ok(/boardViewRows\(\) \{[\s\S]*?boardViewSettings\.orderedBoardViews\(board\)\.filter\(v => allowBoardView\(v\.view\)\)/.test(sidebarJs), 'rows follow the board order'); assert.ok(/boardViewOrder: \{[\s\S]*?type: Array,\s*optional: true,\s*\},\s*'boardViewOrder\.\$': \{\s*type: String,/.test(boardsJs), 'the schema field'); assert.ok(/async moveBoardView\(view, direction, allowView\) \{[\s\S]*?boardViewSettings\.moveBoardView\(this\.boardViewOrder, view, direction, allowView\)[\s\S]*?\$set: \{ boardViewOrder: order \}/.test(boardsJs), 'the setter'); }); test('normalizeBoardViewOrder drops unknown keys and duplicates and appends missing views in default order', () => { const all = bvs.DEFAULT_BOARD_VIEW_ORDER; assert.deepStrictEqual(bvs.normalizeBoardViewOrder(undefined), all); assert.deepStrictEqual(bvs.normalizeBoardViewOrder([]), all); assert.deepStrictEqual(bvs.normalizeBoardViewOrder('board-view-lists'), all, 'a non-array is ignored'); const stored = ['board-view-pulse', 'board-view-nope', 'board-view-lists', 'board-view-pulse', 42]; const out = bvs.normalizeBoardViewOrder(stored); assert.deepStrictEqual(out.slice(0, 2), ['board-view-pulse', 'board-view-lists']); assert.deepStrictEqual(out.slice(2), all.filter(v => v !== 'board-view-pulse' && v !== 'board-view-lists')); assert.strictEqual(out.length, all.length, 'every view exactly once'); assert.ok(!out.includes('board-view-nope')); assert.strictEqual(bvs.isDefaultBoardViewOrder(undefined), true); assert.strictEqual(bvs.isDefaultBoardViewOrder(all.slice()), true); assert.strictEqual(bvs.isDefaultBoardViewOrder(['board-view-lists']), false); assert.deepStrictEqual(bvs.orderedBoardViews({ boardViewOrder: ['board-view-cal'] })[0], bvs.BOARD_VIEWS[3]); }); test('moveBoardView moves one step, and the first up / last down / unknown are no-ops (negative)', () => { const all = bvs.DEFAULT_BOARD_VIEW_ORDER; const up = bvs.moveBoardView(undefined, 'board-view-lists', 'up'); assert.deepStrictEqual(up.slice(0, 2), ['board-view-lists', 'board-view-swimlanes']); assert.deepStrictEqual(up.slice(2), all.slice(2)); const down = bvs.moveBoardView(up, 'board-view-lists', 'down'); assert.deepStrictEqual(down, all, 'and back'); assert.deepStrictEqual(bvs.moveBoardView(undefined, 'board-view-swimlanes', 'up'), all, 'first item up'); // #3256 appended the Map view; the Email (#794), Chat, Version Control and // Column sets (#211) views followed it, and the reports of 2026-11-20 after // those, so the Activity Heatmap is the last row now. assert.deepStrictEqual(bvs.moveBoardView(undefined, 'board-view-activity-heatmap', 'down'), all, 'last item down'); assert.notDeepStrictEqual(bvs.moveBoardView(undefined, 'board-view-chat', 'down'), all, 'Chat is no longer last'); assert.notDeepStrictEqual(bvs.moveBoardView(undefined, 'board-view-map', 'down'), all, 'Map is no longer last'); assert.deepStrictEqual(bvs.moveBoardView(undefined, 'board-view-nope', 'up'), all, 'unknown'); // Once the unknown key is dropped Pulse IS the first row, so its up is a no-op. assert.deepStrictEqual(bvs.moveBoardView(['board-view-nope', 'board-view-pulse'], 'board-view-pulse', 'up'), bvs.normalizeBoardViewOrder(['board-view-pulse']), 'first after cleanup'); const input = ['board-view-cal', 'board-view-lists']; bvs.moveBoardView(input, 'board-view-lists', 'up'); assert.deepStrictEqual(input, ['board-view-cal', 'board-view-lists'], 'the input is not mutated'); }); test('Utils.boardView() resolves the stored choice through the current board', () => { assert.ok(/boardView\(\) \{\s*const stored = Utils\.storedBoardView\(\);\s*const board = Utils\.getCurrentBoard\(\);\s*return board \? resolveBoardView\(board, stored, allowBoardView, Meteor\.userId\(\)\) : stored;/.test(utilsJs), 'a view the instance disabled falls back too (#6736); the viewer decides public or private'); // #4906 / #4256: the stored choice is this board's own, else the shared one. assert.ok(/storedBoardView\(\) \{\s*const pendingChoice = pendingBoardView\.get\(\);/.test(utilsJs), 'the previous body is the stored choice'); assert.ok(utilsJs.includes("require('/models/lib/boardViewSettings')")); }); // ---------------------------------------------------------- translations test('the four column headers exist in English and are translated in every non-English locale', () => { const NEW_KEYS = COLUMN_KEYS.slice(0, 4); assert.strictEqual(en['default-on-public-board'], 'Default on Public Board'); assert.strictEqual(en['show-on-public-board'], 'Show on Public Board'); assert.strictEqual(en['default-on-private-board'], 'Default on Private Board'); assert.strictEqual(en['show-on-private-board'], 'Show on Private Board'); const dir = path.join(ROOT, 'imports/i18n/data'); const untranslated = []; fs.readdirSync(dir).forEach(file => { const tag = file.replace('.i18n.json', ''); if (tag === 'en' || /^en[-_]/.test(tag)) return; const j = JSON.parse(fs.readFileSync(path.join(dir, file), 'utf8')); NEW_KEYS.forEach(key => { if (typeof j[key] !== 'string' || !j[key] || j[key] === en[key]) untranslated.push(`${tag}:${key}`); }); }); assert.deepStrictEqual(untranslated, [], 'every locale has its own value'); }); // ----------------------------------------------------- the default order // The DEFAULT order is the order the Board View menu had BEFORE views became // orderable: the 25 static `li` entries (and six `hr`s) of boardChangeViewPopup // in client/components/boards/boardHeader.jade as of commit 525bcab1b, the // parent of the Board Settings / Board View feature commit - read with // git show 525bcab1b:client/components/boards/boardHeader.jade // and transcribed here literally, so the list is pinned to that template // rather than to whatever order BOARD_VIEWS happens to be written in. const PRE_FEATURE_MENU = [ 'board-view-swimlanes', 'board-view-lists', 'board-view-table', 'hr', 'board-view-cal', // #3194: Calendar Mode, below Calendar. 'board-view-calendar-mode', 'board-view-multiboard-cal', 'board-view-time', 'board-view-timeline', 'hr', 'board-view-stats', 'hr', 'board-view-group-by-assignee', 'hr', 'board-view-gantt', 'board-view-gantt-frappe', 'board-view-gantt-dhtmlx', 'hr', // Scrum planning extends the menu beside roadmap. 'board-view-product-backlog', 'board-view-sprints', 'board-view-sprint-report', 'board-view-velocity', 'board-view-roadmap', 'board-view-dashboard', 'board-view-bigboard', 'hr', 'board-view-burndown', 'board-view-burnup', 'board-view-cumulative-flow', 'board-view-control-chart', 'board-view-cycle-time', 'board-view-flow-efficiency', 'board-view-lead-time', 'board-view-throughput-histogram', 'board-view-wip-run', 'board-view-pulse', // Flow analytics extends the original order at its bottom. 'board-view-aging-wip', 'board-view-blocker-analysis', 'board-view-monte-carlo', 'board-view-process-behavior', 'board-view-size-cycle-time', // #3256: the Map view, appended at the bottom too. 'board-view-map', // #794: Email, then Chat - appended after Map, like it. 'board-view-email', 'board-view-chat', // Version Control, appended after Chat. 'board-view-version-control', // #211: Column sets, appended after Version Control. 'board-view-column-sets', // The reports of 2026-11-20 (models/lib/boardReports.js), appended after Column sets. 'board-view-created-resolved', 'board-view-net-flow', 'board-view-time-in-list', 'board-view-average-age', 'board-view-throughput-run', 'board-view-due-date-performance', 'board-view-release-burndown', 'board-view-epic-progress', 'board-view-workload', 'board-view-distribution', 'board-view-dependency-map', 'board-view-activity-heatmap', ]; const bvsSrc = read('models/lib/boardViewSettings.js'); const PRE_FEATURE_ORDER = PRE_FEATURE_MENU.filter(k => k !== 'hr'); const PRE_FEATURE_HR_AFTER = PRE_FEATURE_MENU .map((k, i) => (k === 'hr' ? PRE_FEATURE_MENU[i - 1] : null)) .filter(Boolean); test('#3194: a board that saved the default order before Calendar Mode still has the default order', () => { const before = bvs.DEFAULT_BOARD_VIEW_ORDER.filter(view => view !== 'board-view-calendar-mode'); const out = bvs.normalizeBoardViewOrder(before); assert.deepStrictEqual(out, bvs.DEFAULT_BOARD_VIEW_ORDER, 'Calendar Mode in its place, below Calendar'); assert.strictEqual(bvs.isDefaultBoardViewOrder(before), true, 'and the menu keeps its separators'); // Negative: a custom order is not made the default; the new view goes at // the end of it, and a view other than the ones added later still counts. const custom = before.slice(1).concat(before[0]); assert.deepStrictEqual(bvs.normalizeBoardViewOrder(custom), custom.concat('board-view-calendar-mode')); assert.strictEqual(bvs.isDefaultBoardViewOrder(before.filter(view => view !== 'board-view-table')), false); }); test('the default order is the pre-feature menu order (525bcab1b), literally', () => { assert.deepStrictEqual(bvs.DEFAULT_BOARD_VIEW_ORDER, PRE_FEATURE_ORDER); // 34 before the Map view (#3256) was appended, 35 before Calendar Mode // (#3194), 36 before Email (#794) and Chat, 38 before Version Control, // 39 before Column sets (#211), 40 before the twelve reports of 2026-11-20. assert.strictEqual(PRE_FEATURE_ORDER.length, 52); // The literal in the model is a list of its own, not a slice of the table // (negative: re-sorting BOARD_VIEWS must not be able to change the default). assert.match(bvsSrc, /const DEFAULT_BOARD_VIEW_ORDER = \[\n\s*'board-view-swimlanes',/); assert.ok(!/DEFAULT_BOARD_VIEW_ORDER = VIEW_KEYS/.test(bvsSrc)); // ...but it names exactly the views the table knows - nothing more, nothing missing. assert.deepStrictEqual(bvs.DEFAULT_BOARD_VIEW_ORDER.slice().sort(), bvs.BOARD_VIEWS.map(v => v.view).sort()); }); test('a board with no stored order renders the pre-feature order, grouped under headings', () => { // The pre-feature order decides inside each group; the six separators it // had are group headings since 2026-11-20 (BOARD_VIEW_GROUPS). const preFeature = PRE_FEATURE_MENU.filter(e => e !== 'hr'); const grouped = bvs.groupedBoardViews(preFeature.map(view => bvs.BOARD_VIEWS.find(v => v.view === view))).map(v => v.view); ['public', 'private'].forEach(permission => { [undefined, null, [], 'garbage'].forEach(boardViewOrder => { const entries = bvs.boardViewMenuEntries({ permission, boardViewOrder }); assert.deepStrictEqual(entries.map(e => e.view), grouped, `${permission} / ${JSON.stringify(boardViewOrder)}`); assert.strictEqual(entries.filter(e => e.groupLabelKey).length, bvs.BOARD_VIEW_GROUPS.length); }); }); assert.deepStrictEqual(bvs.SEPARATOR_AFTER, PRE_FEATURE_HR_AFTER); assert.strictEqual(PRE_FEATURE_HR_AFTER.length, 6); }); test('views missing from a stored order follow it in the pre-feature order', () => { // The fallback for keys a stored order lacks is the pre-feature order too: // they are appended after the stored keys, in that order (the mechanics of // normalizeBoardViewOrder are unchanged - a stored order stays a record of // what the admin arranged, and what it never mentioned comes after it). const custom = ['board-view-pulse', 'board-view-lists']; const norm = bvs.normalizeBoardViewOrder(custom); assert.deepStrictEqual(norm.slice(0, 2), custom); assert.deepStrictEqual(norm.slice(2), PRE_FEATURE_ORDER.filter(v => !custom.includes(v))); // A stored order that IS the pre-feature order minus a view WeKan gained // later ends with that view, and is not the default order any more. const stored = PRE_FEATURE_ORDER.filter(v => v !== 'board-view-timeline'); assert.deepStrictEqual(bvs.normalizeBoardViewOrder(stored), stored.concat('board-view-timeline')); assert.strictEqual(bvs.isDefaultBoardViewOrder(stored), false); // Negative: a view the table knows but the literal forgot still reaches the // menu at the end instead of vanishing. assert.match(bvsSrc, /DEFAULT_BOARD_VIEW_ORDER\.concat\(VIEW_KEYS\)\.forEach/); }); // Public settings are for the PUBLIC: on a public board, a visitor who is not // logged in or not a member gets Show on / Default on Public Board, and the // board's own members the private side - so a public board can open read-only // in Version Control or Email for the world, offering only those views, while // its members keep every view. test('a public board shows its public views to visitors and its private views to members', () => { const board = { permission: 'public', members: [{ userId: 'member', isActive: true }, { userId: 'gone', isActive: false }], defaultPublicBoardView: 'board-view-version-control', boardViewSettings: Object.fromEntries(bvs.BOARD_VIEWS.map(v => [v.view, { showOnPublic: ['board-view-version-control', 'board-view-email'].includes(v.view), }])), }; assert.strictEqual(bvs.boardViewAudience(board, undefined), 'public', 'not logged in'); assert.strictEqual(bvs.boardViewAudience(board, 'stranger'), 'public', 'logged in, not a member'); assert.strictEqual(bvs.boardViewAudience(board, 'gone'), 'public', 'a former member'); assert.strictEqual(bvs.boardViewAudience(board, 'member'), 'private'); assert.strictEqual(bvs.boardViewAudience({ ...board, permission: 'private' }, undefined), 'private'); const visitorMenu = bvs.boardViewMenuEntries(board, null, undefined, undefined).map(e => e.view); assert.deepStrictEqual(visitorMenu, ['board-view-email', 'board-view-version-control']); assert.strictEqual(bvs.resolveBoardView(board, undefined, undefined, undefined), 'board-view-version-control', 'a first visit opens in the public default'); assert.strictEqual(bvs.resolveBoardView(board, 'board-view-swimlanes', undefined, 'stranger'), 'board-view-version-control', 'negative: a view not offered to the public falls back to the public default'); assert.strictEqual(bvs.resolveBoardView(board, 'board-view-email', undefined, 'stranger'), 'board-view-email'); const memberMenu = bvs.boardViewMenuEntries(board, null, undefined, 'member').map(e => e.view); assert.strictEqual(memberMenu.length, bvs.BOARD_VIEWS.length, 'members keep every view'); assert.strictEqual(bvs.resolveBoardView(board, 'board-view-swimlanes', undefined, 'member'), 'board-view-swimlanes'); }); test('the client resolves and draws the menu for the person looking', () => { const utils = read('client/lib/utils.js'); const header = read('client/components/boards/boardHeader.js'); assert.match(utils, /resolveBoardView\(board, stored, allowBoardView, Meteor\.userId\(\)\)/); assert.match(header, /boardViewMenuEntries\(board, Utils\.boardView\(\), allowBoardView, Meteor\.userId\(\)\)/); }); // The doc lists every view, in the menu's order, with the menu's own key and // its English label. It once stopped at 25 while BOARD_VIEWS had grown to 40, // so the list is compared with the code rather than trusted. test('Board-View.md lists exactly the views of BOARD_VIEWS, in order', () => { const doc = read('docs/Features/Board-Sidebar/Board-Settings/Board-View.md'); const listed = [...doc.matchAll(/^(\d+)\. (.+) \(`([\w-]+)`\)$/gm)]; assert.deepStrictEqual(listed.map(m => m[3]), bvs.BOARD_VIEWS.map(v => v.labelKey)); listed.forEach((m, i) => { assert.strictEqual(Number(m[1]), i + 1, 'numbered from 1 without gaps'); assert.strictEqual(m[2], en[m[3]], `${m[3]} shows its English label`); }); }); // docs/Features/Board-Header/README.md maps every menu entry to the template // that draws it; a view added to BOARD_VIEWS without a row, or a row naming a // template that is gone, fails here. test('Board-Header/README.md has one row per view, naming a template that exists', () => { const doc = read('docs/Features/Board-Header/README.md'); const rows = [...doc.matchAll(/^\| [^|]+ \| `(board-view-[\w-]+)` \| `(\w+)` in `([^`]+)` \|/gm)]; assert.deepStrictEqual(rows.map(m => m[1]), bvs.BOARD_VIEWS.map(v => v.view)); for (const [, view, template, file] of rows) { assert.ok(read(file).includes(`template(name="${template}")`), `${view}: ${template} in ${file}`); assert.ok(read('client/components/boards/boardBody.jade').includes(`+${template}`), `${view}: boardBody renders ${template}`); } }); // Every Board View entry has a guide of its own. Table, Calendar Mode, Time, // Timeline and Map were described only in Board-View.md until 2026-10-17. test('every Board View entry links a guide that exists', () => { const doc = read('docs/Features/Board-Header/README.md'); const rows = [...doc.matchAll(/^\| [^|]+ \| `(board-view-[\w-]+)` \| [^|]+ \| (.+) \|$/gm)]; assert.strictEqual(rows.length, bvs.BOARD_VIEWS.length); for (const [, view, guide] of rows) { const link = /\]\(([^)]+\.md)\)/.exec(guide); assert.ok(link && !guide.startsWith('only in'), `${view} has a guide of its own`); assert.ok(fs.existsSync(path.join(ROOT, 'docs/Features/Board-Header', link[1])), `${view}: ${link[1]} exists`); } }); console.log(`boardViewSettings: ${passed} passed`);