Files
wekan/tests/parentCardFilter1871.test.cjs
T
Lauri Ojansivu a904ca8807 Let a card be a subtask of several parent cards.
"A must be done before B and C can start, so A is a subtask of both." A card
now keeps every parent in parentIds, with parentId still the primary one
(parentIds[0]), so everything that reads one parent keeps working and a card
written before this has its one parent. Picking an existing card as a
subtask adds this card as a further parent instead of replacing the one it
had; Card -> More lists the other parents and removes one, and choosing the
primary parent keeps the others. Children are found under any parent - the
subtask list and counter, the parent filter, rule email Details and the
exports - and the loop guard and the board publication walk every parent.
Archiving or deleting a card takes only the subtasks it is the one parent
of; a shared subtask just loses it. Every parent written must be on a board
the writer can see (GHSA-jvv9-498p-hxrg), and board copy and WeKan import
remap all of them. The old single-parent walker is removed.

Thanks to ikomhoog and xet7 !

Fixes #3626,
2026-09-29 17:59:21 +03:00

39 lines
2.1 KiB
JavaScript

'use strict';
const assert = require('node:assert/strict');
const path = require('node:path');
const { pathToFileURL } = require('node:url');
const { register } = require('node:module');
register(pathToFileURL(path.join(__dirname, 'helpers/meteorStubLoader.mjs')).href, pathToFileURL(__filename).href);
(async () => {
const { Filter } = await import(pathToFileURL(path.join(__dirname, '../client/lib/filter.js')).href);
Filter.reset();
assert.equal(Filter.isActive(), false);
Filter.parentId.add('projectA');
assert.equal(Filter.isActive(), true);
assert.equal(Filter.parentId.isSelected('projectA'), true);
Filter.parentId.add('projectA');
assert.deepEqual(Filter.parentId.list(), ['projectA']);
// #3626: "subtasks of" matches the primary parent or any other parent.
const parentClause = selector => selector.$or.find(c => Array.isArray(c.$and));
let clause = parentClause(Filter._getMongoSelector());
assert.deepEqual(clause.$and[0], { $or: [{ parentId: { $in: ['projectA'] } }, { parentIds: { $in: ['projectA'] } }] });
assert.equal(clause.$and[0].$or[0].parentId.$in.includes('projectB'), false);
assert.equal(clause.$and[0].$or[0].parentId.$in.includes(undefined), false);
Filter.labelIds.add('urgent');
clause = parentClause(Filter._getMongoSelector());
assert.deepEqual(clause.labelIds, { $in: ['urgent'] }, 'normal filters intersect with parent choice');
Filter.parentId.add('projectB');
assert.deepEqual(Filter.parentId.list(), ['projectA', 'projectB']);
Filter.parentId.toggle('projectA');
assert.deepEqual(Filter.parentId.list(), ['projectB']);
Filter.members.add('memberA');
Filter.resetBoardScoped();
assert.deepEqual(Filter.parentId.list(), [], 'parent IDs do not follow the user onto another board');
assert.deepEqual(Filter.members.list(), ['memberA'], 'global member filters retain existing behavior');
Filter.parentId.add('projectC');
Filter.reset();
assert.equal(Filter.isActive(), false);
assert.deepEqual(Filter.parentId.list(), []);
console.log('#1871 parent filter: selection, exclusion, combination, reset and board navigation pass');
})().catch(error => { console.error(error); process.exitCode = 1; });