mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 10:48:06 -05:00
Keep FerretDB's bounded card window as a fetched snapshot, but observe the unrestricted indexed selector and diff a fresh window whenever a matching card changes. Publish added, changed and removed DDP messages so remote edits and cross-list moves render without a browser reload. Cover additions, edits, removals, unchanged cards, cleared fields and a forced-lazy browser scenario. Thanks to hmeunier95 and xet7 ! Fixes #6645,
36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const test = require('node:test');
|
|
|
|
const source = fs.readFileSync(
|
|
path.resolve(__dirname, '../server/publications/cardsWindow.js'),
|
|
'utf8',
|
|
);
|
|
|
|
test('the limited card window refreshes snapshots instead of live-observing', () => {
|
|
const start = source.indexOf('// The window\'s cards.');
|
|
const end = source.indexOf('// The window\'s comments', start);
|
|
const child = source.slice(start, end);
|
|
|
|
assert.match(child, /\{ sort: sortOpt, limit: lim \},\s*false/);
|
|
assert.doesNotMatch(child, /\{ sort: sortOpt, limit: lim \},\s*true/);
|
|
assert.match(child, /publication\.added\('cards', _id, fields\)/);
|
|
assert.match(child, /publication\.changed\('cards', card\._id, card\.fields\)/);
|
|
assert.match(child, /publication\.removed\('cards', cardId\)/);
|
|
assert.match(child, /Cards\.find\(windowSel\(board\)\)\.observeChangesAsync/);
|
|
assert.doesNotMatch(child, /setInterval/);
|
|
assert.match(child, /observerHandle\.stop\(\)/);
|
|
assert.match(child, /return null;/);
|
|
});
|
|
|
|
test('the client re-subscribes with limit, filter and sort changes', () => {
|
|
const client = fs.readFileSync(
|
|
path.resolve(__dirname, '../client/components/lists/listBody.js'),
|
|
'utf8',
|
|
);
|
|
assert.match(client, /subscribe\('boardCardsWindow', list\.boardId, mongoSelector, sortBy, limit\)/);
|
|
});
|