mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
A board's visibility can now be "Signed-in users" (permission 'instance'): every signed-in user of this WeKan reads it, nobody signed out does, and only its members edit it, as on a public board. One pure rule, models/lib/boardPermission.js, feeds isVisibleBy and the shared selector builder, so the board and card publications, All Boards, search, exports, attachments, backgrounds, watching, filter presets and rule destinations follow it. Anonymous paths - link previews, public avatars, the no-token export branch and archived lists - stay public-only, and a source suite lists every remaining public-only check so a new one is reviewed. The Public page and GET /api/boards list instance boards for a signed-in caller only; "private boards only" refuses them like public ones; a WeKan export keeps the setting on import. New strings are English, pending Transifex. Fixes #3249, Thanks to relikd and xet7 !
43 lines
2.0 KiB
JavaScript
43 lines
2.0 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const read = rel => fs.readFileSync(path.join(__dirname, '..', rel), 'utf8');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
|
console.log('boardsReportFilter:');
|
|
|
|
test('the dropdown offers every stored board permission plus All', () => {
|
|
const ui = read('client/components/settings/adminProblems.js');
|
|
assert.match(ui, /id: 'board-permission'/);
|
|
for (const value of ['all', 'public', 'private']) {
|
|
assert.match(ui, new RegExp(`value: '${value}'`));
|
|
}
|
|
assert.match(ui,
|
|
/'report-boards': \{[^\n]*filter: tmpl\.boardsFilter/);
|
|
});
|
|
|
|
test('filter changes reset page and reload both rows and count', () => {
|
|
const ui = read('client/components/settings/adminProblems.js');
|
|
assert.match(ui,
|
|
/'change \.js-table-page-filter'[\s\S]*cfg\.filter\.set[\s\S]*cfg\.page\.set\(1\)[\s\S]*loadReport\(reportId, \{ recount: true \}\)/);
|
|
});
|
|
|
|
test('publication and count share a validated server-side selector', () => {
|
|
const server = read('server/publications/boards.js');
|
|
assert.match(server, /function boardsReportQuery\(searchTerm = '', permission = 'all'\)/);
|
|
assert.match(server,
|
|
/permission === 'public' \|\| permission === 'private' \|\| permission === 'instance'[\s\S]*query\.permission = permission/);
|
|
assert.match(server,
|
|
/Meteor\.publish\('boardsReport', async function\(searchTerm = '', permission = 'all', limit, skip = 0\)/);
|
|
assert.match(server, /async getBoardsReportCount\(searchTerm = '', permission = 'all'\)/);
|
|
assert.strictEqual((server.match(/boardsReportQuery\(searchTerm, permission\)/g) || []).length, 2);
|
|
// #3249 added 'instance' boards to the filter.
|
|
assert.strictEqual((server.match(/check\(permission, Match\.OneOf\('all', 'public', 'private', 'instance'\)\)/g) || []).length, 2,
|
|
'forged filter values must be rejected in both endpoints');
|
|
});
|
|
|
|
console.log(`\nboardsReportFilter: ${passed} tests passed`);
|