mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Ten modules were reached only from tests. Some were copies of production logic kept beside it, so a test passed whatever production did; the rest were re-export files that only tests imported. Copies removed, the test now reading what runs: - models/lib/oauth2ClientSecretJwt.js: wekan-oidc ran its own vendored copy. The package file is now the only one and tests/oauth2ClientSecretJwt drives it; tests/packageAppImportBoundary fails if a second copy returns. - models/lib/scrollbarCss.js (#5439): tests/scrollbarCss reads the rules in client/components/lists/list.css. - models/lib/createListParams.js: tests/createListParams reads the check() pattern of createListAfter in server/models/lists.js and runs it by the rules of Meteor's check, so changing the server pattern fails the test. - server/lib/cardMatch.js (#5910): the search is a Mongo selector in server/publications/cards.js, which tests/boardSearchComments now reads. - server/lib/dueDateEdits.js (#6081): Cards.getDueDateChangeCount() counts the a-dueAt activities itself. Helpers that production now calls: - models/lib/checklistHide.js (was server/lib): the Checklists helpers hideCheckedState() and isItemHidden() call it, with the same strict "checked is true" rule as before. - models/lib/subtaskSettings.js (was server/lib): the Board Settings subtask pickers mark the selected board and list with it. resolveSubtaskLanding(), which nothing called, is removed with its tests. Re-export files removed, the tests importing the real module: server/lib/listColors.js, cardScope.js, announcementVisibility.js, customNumberFormat.js and subtaskHelpers.js. docs/DeveloperDocs/Directory-Structure.md pointed at the migrations/ directory, which no longer exists; it now names server/migrations. Thanks to xet7 !
56 lines
2.1 KiB
JavaScript
56 lines
2.1 KiB
JavaScript
/* eslint-env mocha */
|
|
import { expect } from 'chai';
|
|
import {
|
|
isSelectedSubtaskList,
|
|
isSelectedSubtaskBoard,
|
|
} from '/models/lib/subtaskSettings';
|
|
|
|
/**
|
|
* Unit tests for the board "Subtasks" landing settings helpers
|
|
* (#3414, #3876, #4849, #4947).
|
|
*
|
|
* Bugs:
|
|
* - The "Landing list for subtasks deposited here" setting appeared not to
|
|
* save / showed the wrong selected list, because the selected-option helper
|
|
* compared the list against subtasksDefaultBoardId instead of
|
|
* subtasksDefaultListId.
|
|
*
|
|
* Where a new subtask lands is Boards.getDefaultSubtasksBoardAsync() and
|
|
* getDefaultSubtasksListAsync() in models/boards.js; a resolveSubtaskLanding()
|
|
* helper tested here was never called by them and is removed.
|
|
*/
|
|
describe('subtask landing settings (#3414/#3876/#4849/#4947)', function() {
|
|
describe('isSelectedSubtaskList', function() {
|
|
it('matches the stored subtasksDefaultListId (#3876/#4947)', function() {
|
|
const board = { subtasksDefaultBoardId: 'B1', subtasksDefaultListId: 'L1' };
|
|
expect(isSelectedSubtaskList(board, 'L1')).to.equal(true);
|
|
});
|
|
|
|
it('does not match a different list id', function() {
|
|
const board = { subtasksDefaultListId: 'L1' };
|
|
expect(isSelectedSubtaskList(board, 'L2')).to.equal(false);
|
|
});
|
|
|
|
it('does not match the board id (the original bug)', function() {
|
|
const board = { subtasksDefaultBoardId: 'B1', subtasksDefaultListId: 'L1' };
|
|
// Passing the board id must NOT select a list option.
|
|
expect(isSelectedSubtaskList(board, 'B1')).to.equal(false);
|
|
});
|
|
|
|
it('returns false when no list is configured', function() {
|
|
expect(isSelectedSubtaskList({ subtasksDefaultListId: null }, 'L1')).to.equal(false);
|
|
});
|
|
});
|
|
|
|
describe('isSelectedSubtaskBoard', function() {
|
|
it('matches the stored subtasksDefaultBoardId', function() {
|
|
const board = { subtasksDefaultBoardId: 'B1' };
|
|
expect(isSelectedSubtaskBoard(board, 'B1')).to.equal(true);
|
|
});
|
|
|
|
it('returns false when no board is configured', function() {
|
|
expect(isSelectedSubtaskBoard({ subtasksDefaultBoardId: null }, 'B1')).to.equal(false);
|
|
});
|
|
});
|
|
});
|