Files
wekan/server/cards-loading.js
T
xet7 d2ec3ee400 Unit + negative tests for newest features (lazy loading, streaming export, backup)
Extract the pure, security- and correctness-critical logic of the recent features
into Meteor-free models/lib/* modules (so production and tests share one
implementation) and add plain-Node tests with positive AND negative cases, wired
into test:unit:node:

- models/lib/mongoSelectorSafety.js hasWhere() — the windowed card publication
  refuses a client selector carrying $where (server-side JS). Tests: safe
  selectors pass; $where at top level / in $and / deep in arrays / in $elemMatch
  is rejected. (was inline in server/publications/cardsWindow.js)
- models/lib/cardsLoading.js resolveCardsLoadingMode / parseCardsLoadingEnv /
  windowCountId — CARDS_LOADING maps to 'lazy' only for exactly "lazy" (garbage
  never enables the experimental mode); a falsy swimlane id collapses to one
  count-doc id (listBody uses undefined, listHeader uses ''). (used by
  server/cards-loading.js, server/models/settings.js, client/lib/lazyCards.js)
- models/lib/base64Chunk.js encodeAligned/encodeFinal — streaming an attachment
  into the JSON export as base64 in any chunk sizes reconstructs exactly the
  whole-file base64; aligned pieces never carry padding. (used by
  Exporter.buildStream)
- models/lib/backupPaths.js filesRootFrom/scheduleText — WRITABLE_PATH -> files
  root (no double /files suffix, Windows-safe) and the synced-cron schedule text
  (daily/weekly/monthly + defaults, unknown frequency falls back to daily). (used
  by server/methods/backup.js)

41 new assertions across 4 files, all passing; whole test:unit:node suite green.
2026-07-11 00:14:49 +03:00

22 lines
1.2 KiB
JavaScript

// CARDS_LOADING controls how a board loads its cards.
//
// all (default) — the `board` publication ships every non-archived card into
// the client's minimongo. Filtering, search, counts, sorting
// and drag-and-drop all run client-side. Simple and fully
// featured, but a board with thousands of cards pushes a large
// dataset to every viewer.
// lazy — each list loads only the cards currently visible (the
// infinite-scroll window) via a per-list windowed publication,
// and card counts come from a reactive server count. The board
// publication then does NOT ship all cards. Lower memory / less
// data for very large boards. Opt-in / experimental.
//
// Exposed to the client as Meteor.settings.public.cardsLoading so both the
// publications (server) and the board rendering (client) agree on the mode.
const { resolveCardsLoadingMode } = require('/models/lib/cardsLoading');
Meteor.startup(() => {
if (!Meteor.settings.public) Meteor.settings.public = {};
Meteor.settings.public.cardsLoading = resolveCardsLoadingMode(process.env.CARDS_LOADING);
});