mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Reported directly: clicking a newly created label did not enlarge it or apply it to the card. The browser console showed "Exception in Template.cardFlowtime canControlFlow" and the same for Template.cardPomodoro canControlPomodoro - both call Utils.canModifyCard() but never import Utils (a plain ES export from client/lib/utils.js, not a Meteor global), so the helper threw a ReferenceError the moment either template's reactive computation ran, which broke the surrounding card render along with it. Searching the whole tree for the same shape (a client file calling Utils.<method>() or ReactiveCache.<method>() without importing it) found two more real, independent instances: - client/components/settings/notificationSettingsPopup.js's currentBoard() called Utils.getCurrentBoardId() unimported. - client/components/main/bookmarks.js's four helpers/events called ReactiveCache.getCurrentUser() unimported - the header bookmarks/Starred feature. - client/lib/tests/Utils.tests.js did `import '../utils';` (a bare side-effect import) and then used the bare `Utils` global throughout - never actually reached by the fast Node suite (a mocha/browser test), but would have thrown the same way if run. None of this is caught by rspack's build (it does not type-check or cross-check imports app-wide) or by tests/run-node-suites.cjs (nothing exercises these code paths with the name deliberately left undefined) - only the browser, live, the moment that render actually runs. tests/clientSingletonImports.test.cjs sweeps every client/**/*.js file for a call to Utils.<method>( or ReactiveCache.<method>( with no matching import, so this shape cannot reappear anywhere else undetected. Verified against a real Meteor boot (`meteor run`) in-sandbox. Thanks to xet7 !
186 lines
4.8 KiB
JavaScript
186 lines
4.8 KiB
JavaScript
/* eslint-env mocha */
|
|
import sinon from 'sinon';
|
|
import { expect } from 'chai';
|
|
import { Random } from 'meteor/random';
|
|
import { Utils } from '../utils';
|
|
|
|
|
|
describe('Utils', function () {
|
|
beforeEach(function () {
|
|
sinon.stub(Utils, 'reload').callsFake(() => { });
|
|
});
|
|
|
|
afterEach(function () {
|
|
window.localStorage.removeItem(boardView);
|
|
sinon.restore();
|
|
});
|
|
|
|
const boardView = 'boardView';
|
|
|
|
describe(Utils.setBoardView.name, function () {
|
|
it('sets the board view if the user exists', function (done) {
|
|
const viewId = Random.id();
|
|
const user = {
|
|
setBoardView: (view) => {
|
|
expect(view).to.equal(viewId);
|
|
done();
|
|
},
|
|
};
|
|
sinon.stub(Meteor, 'user').callsFake(() => user);
|
|
Utils.setBoardView(viewId);
|
|
|
|
expect(window.localStorage.getItem(boardView)).to.equal(viewId);
|
|
});
|
|
|
|
it('sets a specific view if no user exists but a view is defined', function () {
|
|
const views = [
|
|
'board-view-swimlanes',
|
|
'board-view-lists',
|
|
'board-view-cal'
|
|
];
|
|
|
|
sinon.stub(Meteor, 'user').callsFake(() => { });
|
|
|
|
views.forEach(viewName => {
|
|
Utils.setBoardView(viewName);
|
|
expect(window.localStorage.getItem(boardView)).to.equal(viewName);
|
|
});
|
|
});
|
|
|
|
it('sets a default view if no user and no view are given', function () {
|
|
sinon.stub(Meteor, 'user').callsFake(() => { });
|
|
Utils.setBoardView();
|
|
expect(window.localStorage.getItem(boardView)).to.equal('board-view-swimlanes');
|
|
});
|
|
});
|
|
|
|
describe(Utils.unsetBoardView.name, function () {
|
|
it('removes the boardview from localStoage', function () {
|
|
window.localStorage.setItem(boardView, Random.id());
|
|
window.localStorage.setItem('collapseSwimlane', Random.id());
|
|
|
|
Utils.unsetBoardView();
|
|
|
|
expect(window.localStorage.getItem(boardView)).to.equal(null);
|
|
expect(window.localStorage.getItem('collapseSwimlane')).to.equal(null);
|
|
});
|
|
});
|
|
|
|
describe(Utils.boardView.name, function () {
|
|
it('returns the user\'s board view if a user exists', function () {
|
|
const viewId = Random.id();
|
|
const user = {};
|
|
sinon.stub(Meteor, 'user').callsFake(() => user);
|
|
expect(Utils.boardView()).to.equal(undefined);
|
|
|
|
const boardView = Random.id();
|
|
user.profile = { boardView };
|
|
|
|
expect(Utils.boardView()).to.equal(boardView);
|
|
});
|
|
it('returns the current defined view', function () {
|
|
const views = [
|
|
'board-view-swimlanes',
|
|
'board-view-lists',
|
|
'board-view-cal'
|
|
];
|
|
|
|
sinon.stub(Meteor, 'user').callsFake(() => { });
|
|
|
|
views.forEach(viewName => {
|
|
window.localStorage.setItem(boardView, viewName);
|
|
expect(Utils.boardView()).to.equal(viewName);
|
|
});
|
|
});
|
|
it('returns a default if nothing is set', function () {
|
|
sinon.stub(Meteor, 'user').callsFake(() => { });
|
|
expect(Utils.boardView()).to.equal('board-view-swimlanes');
|
|
expect(window.localStorage.getItem(boardView)).to.equal('board-view-swimlanes');
|
|
});
|
|
});
|
|
|
|
describe(Utils.myCardsSort.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.myCardsSortToggle.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.setMyCardsSort.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.archivedBoardIds.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.dueCardsView.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.setDueCardsView.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.goBoardId.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.goCardId.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.processUploadedAttachment.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.shrinkImage.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.capitalize.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.isMiniScreen.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.isShowDesktopDragHandles.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.isTouchScreenOrShowDesktopDragHandles.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.calculateIndexData.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.calculateIndex.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.manageCustomUI.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.setCustomUI.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.setMatomo.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.manageMatomo.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
|
|
describe(Utils.getTriggerActionDesc.name, function () {
|
|
it('has no tests yet');
|
|
});
|
|
});
|