Files
wekan/tests/backupValidation.test.cjs
T
Lauri Ojansivu 58d8563637 Fix scheduled full-instance backups and validate Admin Panel features
Start the shared scheduler and use valid daily expressions. Preserve all
application collections, BSON types, indexes and selected file versions in
portable archives, validate content before restore, and report failures.

Document every Admin Panel implementation and its validation limits. Add
real-database round trips, failure cases and browser coverage for scheduling,
restore, file downloads, every pane route and permission boundaries.

Thanks to markusst1982 and xet7 !

Fixes #6683,
2026-09-23 19:10:24 +03:00

24 lines
1.3 KiB
JavaScript

'use strict';
const { test } = require('node:test');
const assert = require('node:assert/strict');
const { validateBackupOptions, validateBackupSchedule } = require('../models/lib/backupPaths');
const full = { attachments: true, avatars: true, data: true, storage: 'filesystem',
enabled: true, frequency: 'daily', time: '04:00', dayOfWeek: 'Monday', dayOfMonth: 1 };
test('daily, weekly and monthly full backups are valid', () => {
for (const frequency of ['daily', 'weekly', 'monthly']) {
assert.doesNotThrow(() => validateBackupSchedule({ ...full, frequency }));
}
});
test('invalid schedules and empty enabled backups are refused before saving', () => {
for (const override of [{ time: '24:00' }, { time: '04:99' }, { dayOfWeek: 'Moonday' },
{ dayOfMonth: 29 }, { frequency: 'hourly' }, { storage: 'unknown' },
{ data: 'true' }, { attachments: false, avatars: false, data: false }, { enabled: false }]) {
assert.throws(() => validateBackupSchedule({ ...full, ...override }));
}
assert.throws(() => validateBackupOptions({}, 'filesystem'));
});
test('turning scheduling off is allowed even when nothing is selected', () => {
assert.doesNotThrow(() => validateBackupSchedule({ ...full, enabled: false, frequency: 'off',
attachments: false, avatars: false, data: false }));
});