Files
wekan/tests/visibilityDesc.test.cjs
T
Lauri Ojansivu 5323fdbce6 Add a "Bigboard" board view listing every board at once (#4223).
Add "Bigboard" to the Board View menu, right after Dashboard, matching
the existing 19-entry pattern (menu row in boardHeader.jade, click
handler + boardViewName() entry in boardHeader.js, isViewBigboard()
helper + boardBody.jade branch, the two whitelist arrays in
client/lib/utils.js, and profile.boardView's allowedValues in
models/users.js).

Unlike the other views, Bigboard renders every board the current user
is a member of, not just the open one - the same idea as Kanboard's
BigBoard plugin. The new bigboardView template (bigboardView.jade/js)
queries the user's boards with the same membership selector the All
Boards page uses, subscribes each one's lists/swimlanes/cards through
the existing 'board' composite publication, and stacks each board as
its own section reusing the existing listsGroup/list/card templates -
so editing, dragging and opening a card behave exactly as on a normal
board page.

Rendering several boards' lists on one page at once exposed a bug the
single-board case never could: list drag-and-drop connects via a plain
'.js-swimlane, .js-lists' jQuery UI sortable selector, which would let
a list be dragged out of one board's section into another's now that
more than one board's lists share a page. Added a data-board-id
attribute to the swimlane/listsGroup root elements and a
connectWithSelector() helper (swimlanes.js) that scopes the connect
selector to the dragged list's own board id when one is present -
ordinary single-board views still have exactly one board id on the
page, so their behaviour is unchanged.

Thanks to Jieiku and xet7 !
2026-09-10 19:47:26 +03:00

64 lines
2.9 KiB
JavaScript

'use strict';
// imports/i18n/lib/visibilityDesc.js - the board visibility popup's Private/
// Public sub-name text (client/components/boards/boardHeader.jade,
// template boardVisibilityList). An admin can override it with
// Settings.customPrivateBoardDesc / customPublicBoardDesc (Admin Panel /
// Settings / Visibility), e.g. because their org uses "Public" to mean
// "public within our organization" rather than public on the internet
// (issue #4421). Empty/unset must fall back to the existing i18n text,
// byte-identical to before this setting existed.
// Run: node tests/visibilityDesc.test.cjs
const assert = require('assert');
const path = require('path');
const visibilityDesc = require(path.join(__dirname, '..', 'imports/i18n/lib/visibilityDesc.js'));
let passed = 0;
function test(name, fn) {
fn();
passed += 1;
console.log(' ok -', name);
}
console.log('visibilityDesc:');
test('an unset custom text falls back to the i18n default', () => {
const translate = key => `translated:${key}`;
assert.strictEqual(visibilityDesc(undefined, translate, 'private-desc'), 'translated:private-desc');
assert.strictEqual(visibilityDesc(null, translate, 'public-desc'), 'translated:public-desc');
});
test('an empty or whitespace-only custom text also falls back', () => {
const translate = key => `translated:${key}`;
assert.strictEqual(visibilityDesc('', translate, 'private-desc'), 'translated:private-desc');
assert.strictEqual(visibilityDesc(' ', translate, 'public-desc'), 'translated:public-desc');
});
test('a real custom text is used instead of the i18n default', () => {
const translate = () => { throw new Error('translate must not be called when custom text is set'); };
assert.strictEqual(
visibilityDesc('Public boards are only public within our organization.', translate, 'public-desc'),
'Public boards are only public within our organization.',
);
});
test('a custom text is trimmed', () => {
const translate = () => 'default';
assert.strictEqual(visibilityDesc(' Custom text ', translate, 'private-desc'), 'Custom text');
});
test('an existing user/org that never touched the setting sees byte-identical behavior', () => {
// Settings.customPrivateBoardDesc/customPublicBoardDesc default to '',
// the same shape TAPi18n's own key lookup returns for an unset value -
// so the very first render after this feature ships shows exactly what
// it showed before the feature existed.
const settingsDoc = { customPrivateBoardDesc: '', customPublicBoardDesc: '' };
const translate = key => ({ 'private-desc': 'Default private description.', 'public-desc': 'Default public description.' })[key];
assert.strictEqual(visibilityDesc(settingsDoc.customPrivateBoardDesc, translate, 'private-desc'), 'Default private description.');
assert.strictEqual(visibilityDesc(settingsDoc.customPublicBoardDesc, translate, 'public-desc'), 'Default public description.');
});
console.log(`\nvisibilityDesc: ${passed} tests passed`);