mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
"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,
44 lines
2.4 KiB
JavaScript
44 lines
2.4 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { Random } from 'meteor/random';
|
|
import Boards from '/models/boards';
|
|
import Cards from '/models/cards';
|
|
import Lists from '/models/lists';
|
|
import Swimlanes from '/models/swimlanes';
|
|
|
|
// #3626 against the real collections and hooks: a subtask shared by B and C is
|
|
// not archived or deleted with C - it just loses C - while a subtask that only
|
|
// C has goes with C, as before.
|
|
describe('Cards with several parents', function () {
|
|
this.timeout(30000);
|
|
it('archive and delete take only the children a card is the one parent of', async function () {
|
|
const boardId = Random.id(), owner = Random.id(), listId = Random.id(), swimlaneId = Random.id();
|
|
const card = (id, extra = {}) => ({ _id: id, boardId, listId, swimlaneId, title: id, userId: owner,
|
|
archived: false, sort: 0, type: 'cardType-card', parentId: '', ...extra });
|
|
const b = Random.id(), c = Random.id(), shared = Random.id(), onlyC = Random.id();
|
|
try {
|
|
await Boards.rawCollection().insertOne({ _id: boardId, title: 'Parents', type: 'board', archived: false,
|
|
permission: 'private', members: [{ userId: owner, isActive: true, isAdmin: true }] });
|
|
await Lists.rawCollection().insertOne({ _id: listId, boardId, title: 'List', archived: false, sort: 0 });
|
|
await Swimlanes.rawCollection().insertOne({ _id: swimlaneId, boardId, title: 'Lane', archived: false, sort: 0 });
|
|
await Cards.rawCollection().insertMany([card(b), card(c),
|
|
card(shared, { parentId: b, parentIds: [b, c] }), card(onlyC, { parentId: c, parentIds: [c] })]);
|
|
const read = id => Cards.rawCollection().findOne({ _id: id });
|
|
|
|
await (await Cards.findOneAsync(c)).archive();
|
|
assert.equal((await read(onlyC)).archived, true, "C's own subtask is archived with it");
|
|
assert.equal((await read(shared)).archived, false, 'the shared one is not');
|
|
|
|
await Cards.removeAsync({ _id: c });
|
|
assert.equal(await read(onlyC), null, "C's own subtask is deleted with it");
|
|
const kept = await read(shared);
|
|
assert.ok(kept, 'the shared subtask is kept');
|
|
assert.deepEqual([kept.parentId, kept.parentIds], [b, [b]], 'and just loses C');
|
|
} finally {
|
|
await Cards.rawCollection().deleteMany({ boardId });
|
|
await Lists.rawCollection().deleteMany({ boardId });
|
|
await Swimlanes.rawCollection().deleteMany({ boardId });
|
|
await Boards.rawCollection().deleteMany({ _id: boardId });
|
|
}
|
|
});
|
|
});
|