Files
wekan/tests/labelDragDroppable.test.cjs
T
Lauri Ojansivu 7c0ae509ac Fix #2769 #1992 #2292 #2494 #1853 #1554 #2306 #1437.
- #2769: refresh drag geometry when the DOM changes mid-drag - cards no
  longer drop into the wrong swimlane while someone adds a card.
- #1992: board import restores all five card date fields (and creator)
  with fallbacks; receivedAt/endAt were never imported at all.
- #2292: archiving a swimlane archives its cards (mirroring lists);
  restore brings back exactly the cards archived with it.
- #2494: client noCache card lookup returned a Promise since the
  Meteor 3 port - multi-select board moves wrote sort: NaN everywhere.
- #1853: subtask "View it" falls back to the subtask's boardId when the
  deposit board is not loaded, instead of silently doing nothing.
- #1554: restore the reactive dependency lost in 7673c77c5 so cards
  added after board render accept sidebar label/member drops.
- #2306: "filter to selection" and every bulk action are board-scoped;
  foreign-board cards can no longer be silently archived.
- #1437: new POST /users/logout API endpoint revokes the presented
  resume token, or all tokens with {"all": true}.

All with positive+negative regression tests (see tests/*.test.cjs).

Closes #1389: already fixed - the standalone pencil edit button
(0cc63b810) plus the wrapped viewer (bf2b3b40c) guarantee an edit target
even when a full-width link fills the description.

Thanks to hever, Cactusbone, Vermeille, Vanclief, Miffe, IcedQuinn,
ppouliot, GhassenRjab and xet7.
2026-07-17 03:34:23 +03:00

48 lines
2.2 KiB
JavaScript

'use strict';
// Plain-Node regression guard (no Meteor) for issue #1554: dragging labels or
// members from the sidebar onto cards stopped working for any minicard
// rendered AFTER the list's initial render (new cards, cards dragged in,
// Blaze re-renders) — it only worked again after leaving and re-entering the
// board. Root cause: commit 7673c77c5 (2023) deleted the reactive dependency
// (`Cards.find({boardId}).fetch()`) from the droppable-initializing autorun in
// client/components/lists/list.js instead of converting it to the
// ReactiveCache, so the autorun ran exactly once per list render.
// Run: node tests/labelDragDroppable.test.cjs
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const repoRoot = path.resolve(__dirname, '..');
const src = fs.readFileSync(path.join(repoRoot, 'client/components/lists/list.js'), 'utf8');
let passed = 0;
function test(name, fn) {
fn();
passed += 1;
console.log(' ok -', name);
}
test('the droppable autorun depends reactively on the board\'s cards (#1554)', () => {
const autorun = src.match(/\/\/ We want to re-run this function any time a card is added\.[\s\S]*?Tracker\.afterFlush/);
assert.ok(autorun, 'droppable autorun found');
assert.ok(autorun[0].includes('ReactiveCache.getCards({ boardId: currentBoardId })'),
'without this dependency the autorun runs once and later-added cards never become droppable');
});
test('negative: the dependency is a reactive read, not wrapped in Tracker.nonreactive', () => {
const autorun = src.match(/\/\/ We want to re-run this function any time a card is added\.[\s\S]*?Tracker\.afterFlush/)[0];
const depIndex = autorun.indexOf('ReactiveCache.getCards');
const nonreactiveBlock = autorun.match(/Tracker\.nonreactive\(\(\) => \{[\s\S]*?\}\);/);
assert.ok(depIndex > autorun.indexOf(nonreactiveBlock[0]) + nonreactiveBlock[0].length,
'the getCards read must be OUTSIDE the nonreactive block or it registers no dependency');
});
test('the droppable still accepts sidebar members and labels', () => {
assert.ok(src.includes("accept: '.js-member,.js-label'"),
'sidebar member/label drags must remain accepted drop payloads');
});
console.log(`labelDragDroppable.test.cjs: ${passed} tests passed`);