mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Found by the #6808 browser test: when an opened card really is deleted, its window is destroyed with its data - usually before the server has answered whether the card is gone - and the confirmation was dropped for a destroyed window, so the window closed but the address stayed the card's. The question is asked outside the window now (confirmGoneCard, waiting for a settled connection and login), and the window's end asks it too when the card is missing; the close (closeGoneCard) clears the window, the popup and the address. A card that only left for a reconnect still answers available and stays. Thanks to brlin-tw and xet7 !
50 lines
1.8 KiB
JavaScript
50 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { openCardIsUnavailable } = require('../models/lib/openCardPresence');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
fn();
|
|
passed += 1;
|
|
console.log(' ok -', name);
|
|
}
|
|
|
|
test('an existing card on its original board remains open', () => {
|
|
assert.strictEqual(openCardIsUnavailable({ _id: 'c1', boardId: 'b1' }, 'b1'), false);
|
|
});
|
|
|
|
test('#3114: a remotely removed card closes', () => {
|
|
assert.strictEqual(openCardIsUnavailable(null, 'b1'), true);
|
|
assert.strictEqual(openCardIsUnavailable(undefined, 'b1'), true);
|
|
});
|
|
|
|
test('#3114: a card remotely moved to another board closes', () => {
|
|
assert.strictEqual(openCardIsUnavailable({ _id: 'c1', boardId: 'b2' }, 'b1'), true);
|
|
});
|
|
|
|
test('missing opening context closes defensively', () => {
|
|
assert.strictEqual(openCardIsUnavailable({ _id: 'c1', boardId: 'b1' }, null), true);
|
|
});
|
|
|
|
test('card details clears desktop, mobile route and popup state', () => {
|
|
const source = fs.readFileSync(
|
|
path.join(__dirname, '../client/components/cards/cardDetails.js'),
|
|
'utf8',
|
|
);
|
|
assert.ok(source.includes("ReactiveCache.getCard(openedCardId)"));
|
|
assert.ok(source.includes("Session.get('openCards')"));
|
|
assert.ok(source.includes("Session.set('currentCard', null)"));
|
|
// #6745: cleared to null like every route does, not deleted - a delete then a
|
|
// set(null) is a change that re-ran every minicard's currentBoard helpers.
|
|
assert.ok(source.includes("Session.set('popupCardId', null)"));
|
|
assert.ok(!source.includes("Session.delete('popupCardId')"));
|
|
// #6808: the close is closeGoneCard(cardId, boardId), outside the window
|
|
// so it also runs after the window went with its data.
|
|
assert.ok(source.includes('Utils.goBoardId(boardId)'));
|
|
});
|
|
|
|
console.log(`\nopenCardPresence: ${passed} tests passed`);
|