mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
- models/cards.js defined assignMember ... toggleAssigner twice in one
Cards.helpers({}); in an object literal the last key wins, so the first
twelve methods (about a hundred lines, with their own linked-board
branches) never ran. models/users.js had two copies of the swimlane-height
storage helpers, and the header's event map an empty
'click .js-open-bookmarks' the real handler replaced. Each first copy is
removed; what runs is unchanged.
- An Admin Panel attachment settings pane: attachmentSettings.jade (four
templates) and about 300 lines of settingBody.js for S3, transfer limits
and storage paths. No menu opened it and no template drew it; Admin Panel /
Attachments (attachments.js) is the one in use.
- Templates drawn by nothing: dateBadge, dateCustomField and
cardCustomFieldDate with its JS, orgAvatar and teamAvatar, the three
*ModalTitle templates of My Cards, Due Cards and Global Search, boardLists,
boardCreateRulePopup, addMemberPopupTest, and subtasksItems with the two
templates only it used.
- CSS repeated word for word: accessibility.css opened with a copy of
myCards.css's first 74 lines; list.css repeated its 768px collapsed-list
block at 1024px and 1200px, which 768px already covers; boardHeader.css
repeated its .mobile-mode rules inside a 801px media query. The later
copies decided nothing, so the result is the same.
tests/noDuplicateObjectKeys.test.cjs parses every app and package file and
fails on an object literal that defines a key twice, and
tests/templatesAreRendered.test.cjs fails on a template nothing draws,
apart from runtime-built names and three listed exceptions. Tests that read
the removed copies now read the code that runs.
Thanks to xet7 !
74 lines
3.6 KiB
JavaScript
74 lines
3.6 KiB
JavaScript
'use strict';
|
|
|
|
// Regression coverage for #2405, #2428 and #3684. A multi-board Sandstorm grain
|
|
// keeps WeKan's normal, permission-checked board-member picker. Beside it, the
|
|
// Powerbox button picks a person through Sandstorm - and, unlike the control
|
|
// #2405 removed, adds them to the board that is open, through the same
|
|
// inviteUserToBoard checks. Redeeming the request itself goes through
|
|
// imports/sandstorm/bridgeClient.mjs (tests/sandstormCapnpRpc.test.cjs).
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const root = path.resolve(__dirname, '..');
|
|
const read = relative => fs.readFileSync(path.join(root, relative), 'utf8');
|
|
const sidebar = read('client/components/sidebar/sidebar.jade');
|
|
const sidebarJs = read('client/components/sidebar/sidebar.js');
|
|
const shared = read('sandstorm.js');
|
|
const server = read('server/sandstorm.js');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
fn();
|
|
passed += 1;
|
|
console.log(' ok -', name);
|
|
}
|
|
|
|
const members = sidebar.slice(
|
|
sidebar.indexOf('template(name="membersWidget")'),
|
|
sidebar.indexOf('template(name="boardOrgGeneral")'),
|
|
);
|
|
|
|
test('Sandstorm keeps the normal permission-checked board member picker', () => {
|
|
assert.match(members, /if currentUser\.canInviteToBoard\s+a\.member\.add-member\.js-manage-board-members/);
|
|
});
|
|
|
|
test('the Powerbox button is back, for Sandstorm and for people who may invite', () => {
|
|
assert.match(members,
|
|
/if currentUser\.canInviteToBoard\s+a\.member\.add-member\.js-manage-board-members[^\n]*\n\s+i\.fa\.fa-plus\n\s+if isSandstorm\n\s+a\.member\.add-member\.sandstorm-powerbox-request-identity/,
|
|
'inside canInviteToBoard, and only when isSandstorm');
|
|
});
|
|
|
|
test('the button names the open board, and the claim invites the person to it', () => {
|
|
assert.match(sidebarJs, /'click \.sandstorm-powerbox-request-identity'\(\) \{\s*window\.sandstormRequestIdentity\(Session\.get\('currentBoard'\)\);/);
|
|
assert.match(shared, /window\.sandstormRequestIdentity = function\(boardId\)/);
|
|
assert.match(shared, /'sandstormClaimIdentityRequest',\s*response\.token,\s*response\.descriptor,\s*boardId,/);
|
|
assert.match(server, /async sandstormClaimIdentityRequest\(token, descriptor, boardId\)/);
|
|
assert.match(server, /check\(boardId, Match\.Maybe\(String\)\)/);
|
|
assert.match(server, /if \(!this\.userId\) throw new Meteor\.Error\('error-notAuthorized'\)/,
|
|
'nobody but a logged-in grain user may redeem a request (negative)');
|
|
assert.match(server, /await Meteor\.callAsync\('inviteUserToBoard', login\.userId, boardId\)/,
|
|
'the same checks as the member picker, not a direct board update');
|
|
const method = server.slice(server.indexOf('async sandstormClaimIdentityRequest('),
|
|
server.indexOf('return { userId: login.userId };'));
|
|
assert.doesNotMatch(method, /Boards\.|members/,
|
|
'the claim must not add members around inviteUserToBoard (negative)');
|
|
});
|
|
|
|
test('Sandstorm cannot create an unusable local email account from the picker', () => {
|
|
const popup = sidebar.slice(
|
|
sidebar.indexOf('template(name="addMemberPopup")'),
|
|
sidebar.indexOf('template(name="changePermissionsPopup")'),
|
|
);
|
|
assert.match(popup, /unless isSandstorm\s+button\.js-email-invite/);
|
|
});
|
|
|
|
test('grain configure permission remains the source of global admin rights', () => {
|
|
assert.match(server, /const isAdmin = permissions\.indexOf\('configure'\) > -1/);
|
|
assert.match(server, /Users\.updateAsync\(userId, \{ \$set: \{ isAdmin \} \}\)/);
|
|
assert.match(server, /'services\.sandstorm\.permissions': 'configure'/);
|
|
});
|
|
|
|
console.log(`\nsandstormMultiBoardMembers: ${passed} tests passed`);
|