mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 17:45:18 -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 !
71 lines
3.1 KiB
JavaScript
71 lines
3.1 KiB
JavaScript
/* eslint-env mocha */
|
|
import { expect } from 'chai';
|
|
import { isItemHidden, checklistHideState } from '/models/lib/checklistHide';
|
|
|
|
// Issue #5408: the per-checklist "Hide checked items" toggle was reported to
|
|
// (1) behave inverted and (2) be applied to ALL checklists in the card.
|
|
// These tests pin down the correct, non-inverted, per-checklist semantics.
|
|
describe('checklistHide (issue #5408)', function() {
|
|
describe(isItemHidden.name, function() {
|
|
it('hides a checked item when the toggle is on', function() {
|
|
expect(isItemHidden({ isChecked: true, hideChecked: true })).to.equal(true);
|
|
});
|
|
|
|
it('keeps a checked item visible when the toggle is off', function() {
|
|
expect(isItemHidden({ isChecked: true, hideChecked: false })).to.equal(false);
|
|
});
|
|
|
|
it('keeps an unchecked item visible when the toggle is on', function() {
|
|
expect(isItemHidden({ isChecked: false, hideChecked: true })).to.equal(false);
|
|
});
|
|
|
|
it('keeps an unchecked item visible when the toggle is off', function() {
|
|
expect(isItemHidden({ isChecked: false, hideChecked: false })).to.equal(false);
|
|
});
|
|
|
|
it('coerces truthy/falsy inputs to a strict boolean', function() {
|
|
expect(isItemHidden({ isChecked: 1, hideChecked: 'yes' })).to.equal(true);
|
|
expect(isItemHidden({ isChecked: 0, hideChecked: 'yes' })).to.equal(false);
|
|
expect(isItemHidden({})).to.equal(false);
|
|
expect(isItemHidden()).to.equal(false);
|
|
});
|
|
});
|
|
|
|
describe(checklistHideState.name, function() {
|
|
it('reads the field from the specific checklist passed in', function() {
|
|
const checklistA = { _id: 'A', hideCheckedChecklistItems: true };
|
|
const checklistB = { _id: 'B', hideCheckedChecklistItems: false };
|
|
expect(checklistHideState(checklistA)).to.equal(true);
|
|
expect(checklistHideState(checklistB)).to.equal(false);
|
|
});
|
|
|
|
it('does not leak one checklist state onto another', function() {
|
|
// Toggling checklist A on must not change the state read for checklist B.
|
|
const checklists = [
|
|
{ _id: 'A', hideCheckedChecklistItems: true },
|
|
{ _id: 'B', hideCheckedChecklistItems: undefined },
|
|
{ _id: 'C', hideCheckedChecklistItems: false },
|
|
];
|
|
const states = checklists.map(checklistHideState);
|
|
expect(states).to.deep.equal([true, false, false]);
|
|
});
|
|
|
|
it('treats a missing/undefined field as off', function() {
|
|
expect(checklistHideState({ _id: 'X' })).to.equal(false);
|
|
expect(checklistHideState({ _id: 'X', hideCheckedChecklistItems: undefined })).to.equal(false);
|
|
});
|
|
|
|
it('returns false for a missing checklist', function() {
|
|
expect(checklistHideState(undefined)).to.equal(false);
|
|
expect(checklistHideState(null)).to.equal(false);
|
|
});
|
|
|
|
it('combines with isItemHidden for the full per-checklist decision', function() {
|
|
const checklist = { _id: 'A', hideCheckedChecklistItems: true };
|
|
const hideChecked = checklistHideState(checklist);
|
|
expect(isItemHidden({ isChecked: true, hideChecked })).to.equal(true);
|
|
expect(isItemHidden({ isChecked: false, hideChecked })).to.equal(false);
|
|
});
|
|
});
|
|
});
|