mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Remove the progressive HTML4/Legacy Omi middleware, cookieless sessions, page controllers, assets, parity refactors, design documents and associated tests. Restore the standard Meteor interface and operations from before the HTML4 work began. Preserve intervening translations, backup screenshots, session upgrades, cryptographic test identifiers, local image storage, document previews and lazy browser loading. Extract the GIF utilities still required by image features into imageGif. Validate the Node suites and add standard-interface and GIF regressions. Two existing failures remain in docsLinksResolve and ruleDetailsLocalization; browser regressions are registered but require a running server. Thanks to xet7 !
68 lines
3.1 KiB
JavaScript
68 lines
3.1 KiB
JavaScript
const assert = require('node:assert');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const test = require('node:test');
|
|
|
|
const root = path.resolve(__dirname, '..');
|
|
const read = file => fs.readFileSync(path.join(root, file), 'utf8');
|
|
const cards = read('models/cards.js');
|
|
const details = read('client/components/cards/cardDetails.js');
|
|
const customFields = read('client/components/cards/cardCustomFields.js');
|
|
const permission = read('server/lib/linkedCardPermission.js');
|
|
const cardPermission = read('server/permissions/cards.js');
|
|
|
|
function methodBody(name) {
|
|
let start = cards.lastIndexOf(` ${name}(`);
|
|
if (start === -1) start = cards.lastIndexOf(` async ${name}(`);
|
|
assert.notStrictEqual(start, -1, `${name} exists`);
|
|
const end = cards.indexOf('\n },', start);
|
|
return cards.slice(start, end);
|
|
}
|
|
|
|
test('every linked-card content mutator writes the source id', () => {
|
|
const contentMutators = [
|
|
'addDependency', 'setDependencyProps', 'removeDependency', 'setColor',
|
|
'assignMember', 'assignAssignee', 'assignRequester', 'assignAssigner',
|
|
'unassignMember', 'unassignAssignee', 'unassignRequester',
|
|
'unassignAssigner', 'assignCustomField', 'unassignCustomField',
|
|
'toggleShowActivities', 'toggleShowChecklistAtMinicard',
|
|
'toggleHideFinishedChecklist', 'setCustomField', 'setCover', 'unsetCover',
|
|
'setOvertime', 'setSpentTime', 'unsetSpentTime', 'setParentId',
|
|
'setVoteQuestion', 'unsetVote', 'setVoteEnd', 'unsetVoteEnd', 'setVote',
|
|
'setPokerQuestion', 'setPokerEstimation', 'unsetPokerEstimation',
|
|
'unsetPoker', 'setPokerEnd', 'unsetPokerEnd', 'setPoker', 'replayPoker',
|
|
];
|
|
for (const name of contentMutators) {
|
|
assert.match(methodBody(name), /getRealId\(\)/, `${name} targets source`);
|
|
}
|
|
|
|
// Placement belongs to the linked representation on the current board.
|
|
assert.match(methodBody('archive'), /Cards\.updateAsync\(this\._id/);
|
|
assert.match(methodBody('move'), /Cards\.updateAsync\(this\._id/);
|
|
});
|
|
|
|
test('opened-card method calls send the source id', () => {
|
|
assert.doesNotMatch(
|
|
details,
|
|
/Meteor\.call\('cards\.(?:vote|pokerVote|setVote|unsetVote|setPoker|unsetPoker)[^\n]*card\._id/,
|
|
);
|
|
assert.match(details, /Meteor\.call\('cards\.vote', card\.getRealId\(\)/);
|
|
assert.match(customFields,
|
|
/setCardCustomFieldAssigned', card\.getRealId\(\)/);
|
|
assert.match(customFields,
|
|
/setCardCustomFieldCheckbox', tpl\.card\.getRealId\(\)/);
|
|
assert.match(details, /Meteor\.call\('watch', 'card', currentCard\.getRealId\(\)/);
|
|
assert.match(details, /Cards\.update\(currentCard\.getRealId\(\), \{ \$set: \{ showListOnMinicard/);
|
|
});
|
|
|
|
test('current-board write access is delegated only through a real live link', () => {
|
|
assert.match(permission, /linkedId: card\._id/);
|
|
assert.match(permission, /type: 'cardType-linkedCard'/);
|
|
assert.match(permission, /archived: \{ \$ne: true \}/);
|
|
assert.match(permission, /allowIsBoardMemberWithWriteAccess\(userId, board\)/);
|
|
assert.match(permission, /canUserSeeBoard\(userId, card\.boardId\)/);
|
|
assert.match(permission, /if \(!userId \|\| !card\) return false/);
|
|
assert.match(cardPermission,
|
|
/canEditCardOrLinkedCard\(userId, doc, board\)/);
|
|
});
|