Files
wekan/tests/scrumLifecycleSize.test.cjs
T
Lauri Ojansivu 7837f3d9c9 Preflight Scrum lifecycle and recovery document sizes
Reject oversized rollover, compound History and recovery payloads before the first lifecycle write using BSON byte counts. Cover multibyte data, complete 10000-card plans and large-metadata rejection/retry in Chromium.

Thanks to xet7 !
2026-09-28 01:15:43 +03:00

27 lines
1.5 KiB
JavaScript

const { test } = require('node:test');
const assert = require('node:assert/strict');
const { assertScrumLifecycleSize, SCRUM_DOCUMENT_BUDGET: budget } = require('../server/lib/scrumLifecycleSize');
const before = { _id: 's', boardId: 'b', state: 'planned' };
test('normal lifecycle plans and complete ten-thousand-card history fit', () => {
const rows = Array.from({ length: 10000 }, (_, i) => ({ cardId: `c${i}`, revision: 1,
before: { sprintId: 's' }, after: { sprintId: null, pastSprintIds: ['s'] } }));
assert.doesNotThrow(() => assertScrumLifecycleSize(before,
{ ...before, state: 'closed', rolloverPending: rows }));
});
test('BSON size includes multibyte text and rejects oversized rollover before copying History', () => {
const text = '漢'.repeat(Math.ceil(budget / 3));
assert.ok(text.length < budget);
assert.throws(() => assertScrumLifecycleSize(before,
{ ...before, rolloverPending: [{ cardId: 'c', before: { acceptanceCriteria: text }, after: {} }] }),
/sprint\/rollover plan exceeds/);
});
test('compound History size is checked even when each sprint document fits', () => {
const text = 'x'.repeat(budget / 2);
assert.throws(() => assertScrumLifecycleSize({ ...before, goal: text }, { ...before, goal: text }),
/compound History exceeds/);
});
test('asymmetric History reserves enough room for restoration and its journal', () => {
assert.throws(() => assertScrumLifecycleSize(before,
{ ...before, goal: 'x'.repeat(budget / 2) }), /History recovery exceeds/);
});