mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
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,
69 lines
2.5 KiB
JavaScript
69 lines
2.5 KiB
JavaScript
'use strict';
|
|
|
|
// Plain-Node unit test (no Meteor) for the Admin Panel / Attachments / Backup
|
|
// path + schedule helpers. Run: node tests/backupPaths.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const { filesRootFrom, scheduleText } = require('../models/lib/backupPaths');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) {
|
|
fn();
|
|
passed += 1;
|
|
console.log(' ok -', name);
|
|
}
|
|
|
|
// --- filesRootFrom ----------------------------------------------------------
|
|
test('docker/dev base gets /files appended', () => {
|
|
assert.strictEqual(filesRootFrom('/data'), '/data/files');
|
|
assert.strictEqual(filesRootFrom('/srv/wekan'), '/srv/wekan/files');
|
|
});
|
|
test('snap base already ending in /files is left unchanged (no double suffix)', () => {
|
|
assert.strictEqual(filesRootFrom('/var/snap/wekan/common/files'), '/var/snap/wekan/common/files');
|
|
});
|
|
test('Windows base ending in \\files is left unchanged', () => {
|
|
assert.strictEqual(filesRootFrom('C:\\wekan\\files'), 'C:\\wekan\\files');
|
|
});
|
|
test('empty base does not crash', () => {
|
|
assert.strictEqual(filesRootFrom(''), 'files');
|
|
assert.strictEqual(filesRootFrom(undefined), 'files');
|
|
});
|
|
|
|
// --- scheduleText -----------------------------------------------------------
|
|
test('daily', () => {
|
|
assert.strictEqual(scheduleText({ frequency: 'daily', time: '04:00' }), 'at 04:00');
|
|
});
|
|
test('weekly uses the given day', () => {
|
|
assert.strictEqual(
|
|
scheduleText({ frequency: 'weekly', dayOfWeek: 'Monday', time: '01:00' }),
|
|
'on Monday at 01:00',
|
|
);
|
|
});
|
|
test('weekly defaults to Sunday', () => {
|
|
assert.strictEqual(scheduleText({ frequency: 'weekly', time: '02:30' }), 'on Sunday at 02:30');
|
|
});
|
|
test('monthly uses the given day-of-month', () => {
|
|
assert.strictEqual(
|
|
scheduleText({ frequency: 'monthly', dayOfMonth: 15, time: '03:00' }),
|
|
'on the 15 day of the month at 03:00',
|
|
);
|
|
});
|
|
test('monthly defaults to the 1st', () => {
|
|
assert.strictEqual(
|
|
scheduleText({ frequency: 'monthly', time: '03:00' }),
|
|
'on the 1 day of the month at 03:00',
|
|
);
|
|
});
|
|
test('time defaults to 04:00 when missing', () => {
|
|
assert.strictEqual(scheduleText({ frequency: 'daily' }), 'at 04:00');
|
|
});
|
|
|
|
// --- NEGATIVE: unknown / absent frequency falls back to the daily form ------
|
|
test('unknown frequency falls back to daily', () => {
|
|
assert.strictEqual(scheduleText({ frequency: 'off', time: '05:00' }), 'at 05:00');
|
|
assert.strictEqual(scheduleText({ time: '06:00' }), 'at 06:00');
|
|
assert.strictEqual(scheduleText({}), 'at 04:00');
|
|
});
|
|
|
|
console.log(`\nbackupPaths: ${passed} tests passed`);
|