This commit is contained in:
@@ -7,7 +7,22 @@ describe('settings backup snapshot', () => {
|
||||
const input = {
|
||||
hosters: { 'voe.sx': [{ id: 'v1', username: 'user', password: 'secret', enabled: true }] },
|
||||
hosterSettings: { 'voe.sx': { retries: 7 } },
|
||||
globalSettings: { alwaysOnTop: true, pendingQueue: [{ file: 'private.mkv' }] },
|
||||
globalSettings: {
|
||||
language: 'de',
|
||||
autoHealthCheckEnabled: false,
|
||||
alwaysOnTop: true,
|
||||
pendingQueue: [{ file: 'private.mkv' }],
|
||||
uploadRecovery: { jobs: ['private.mkv'] },
|
||||
lastBrowseDirectory: 'Z:\\private',
|
||||
folderMonitor: {
|
||||
enabled: true,
|
||||
folderPath: 'D:\\watch',
|
||||
recursive: true,
|
||||
paused: true,
|
||||
pausedAt: 123,
|
||||
telemetry: { detected: 8 }
|
||||
}
|
||||
},
|
||||
history: [{ file: 'done.mkv' }],
|
||||
rotationCursors: { 'voe.sx': 4 }
|
||||
};
|
||||
@@ -17,13 +32,27 @@ describe('settings backup snapshot', () => {
|
||||
assert.deepEqual(snapshot, {
|
||||
hosters: input.hosters,
|
||||
hosterSettings: input.hosterSettings,
|
||||
globalSettings: { alwaysOnTop: true, pendingQueue: null },
|
||||
globalSettings: {
|
||||
language: 'de',
|
||||
autoHealthCheckEnabled: false,
|
||||
alwaysOnTop: true,
|
||||
pendingQueue: null,
|
||||
uploadRecovery: null,
|
||||
lastBrowseDirectory: '',
|
||||
folderMonitor: {
|
||||
enabled: true,
|
||||
folderPath: 'D:\\watch',
|
||||
recursive: true,
|
||||
paused: false,
|
||||
pausedAt: null
|
||||
}
|
||||
},
|
||||
history: []
|
||||
});
|
||||
assert.notEqual(snapshot.hosters, input.hosters);
|
||||
});
|
||||
|
||||
it('validates imports and clears only source-machine paths that do not exist locally', () => {
|
||||
it('preserves configured paths, disables a missing monitored folder and reports both missing paths', () => {
|
||||
const { prepareImportedSettings } = require('../lib/settings-backup');
|
||||
const snapshot = {
|
||||
hosters: { 'byse.sx': [{ id: 'b1', apiKey: 'secret', enabled: true }] },
|
||||
@@ -36,12 +65,19 @@ describe('settings backup snapshot', () => {
|
||||
}
|
||||
};
|
||||
|
||||
const imported = prepareImportedSettings(snapshot, { pathExists: () => false, pathDirname: (value) => value });
|
||||
const warnings = [];
|
||||
const imported = prepareImportedSettings(snapshot, { pathExists: () => false, pathDirname: (value) => value, warnings });
|
||||
|
||||
assert.equal(imported.globalSettings.logFilePath, '');
|
||||
assert.deepEqual(imported.globalSettings.folderMonitor, { enabled: false, folderPath: '' });
|
||||
assert.equal(imported.globalSettings.logFilePath, 'Z:\\missing\\upload.log');
|
||||
assert.deepEqual(imported.globalSettings.folderMonitor, { enabled: false, folderPath: 'Z:\\missing\\watch', paused: false, pausedAt: null });
|
||||
assert.equal(imported.globalSettings.pendingQueue, null);
|
||||
assert.equal(imported.globalSettings.uploadRecovery, null);
|
||||
assert.equal(imported.globalSettings.lastBrowseDirectory, '');
|
||||
assert.deepEqual(imported.history, []);
|
||||
assert.deepEqual(warnings, [
|
||||
'Log-Dateipfad (Ordner nicht gefunden)',
|
||||
'Ordnerüberwachung (Ordner nicht gefunden und deaktiviert)'
|
||||
]);
|
||||
assert.throws(() => prepareImportedSettings({ hosters: {} }), /ungültige Struktur/i);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user