v0.0.2
This commit is contained in:
1 parent
c7d09077fc
commit
f813441bf0
45 files changed
+938
-334
No files matched your search
+44
-2
@@ -50,11 +50,13 @@ test('settings and device forms never prefill secret values returned by a legacy
|
||||
const app = application();
|
||||
app.state.settingsTab = 'credentials';
|
||||
const secret = 'do-not-render-secret-654321';
|
||||
const settings = app.settingsForm({ global_ssh_key: secret, default_switchos_password: secret, smtp_password: secret, pushover_token: secret, pushover_userkey: secret });
|
||||
const settings = app.settingsForm({ global_ssh_key: secret, default_routeros_username: 'fallback-admin', default_routeros_password: secret, default_switchos_password: secret, smtp_password: secret, pushover_token: secret, pushover_userkey: secret });
|
||||
const device = app.deviceForm({ id: 1, name: 'R1', device_type: 'routeros', host: '127.0.0.1', ssh_password: secret, ssh_key: secret });
|
||||
assert.ok(!settings.includes(secret));
|
||||
assert.ok(!device.includes(secret));
|
||||
assert.ok(settings.includes('clear_global_ssh_key'));
|
||||
assert.ok(settings.includes('name="default_routeros_username"'));
|
||||
assert.ok(settings.includes('clear_default_routeros_password'));
|
||||
assert.ok(device.includes('clear_ssh_password'));
|
||||
});
|
||||
|
||||
@@ -111,10 +113,11 @@ test('binary and SwitchOS backups never offer comparison actions or export tabs'
|
||||
assert.ok(!app.detailBody().includes('name="disable_export_backups"'));
|
||||
app.state.cache.routers = [routeros, switchos];
|
||||
app.state.cache.diffFiles = [
|
||||
{ id: 1, backup_type: 'export', file_name: 'allowed.rsc', device_type: 'routeros' },
|
||||
{ id: 1, router_id: 1, backup_type: 'export', file_name: 'allowed.rsc', device_type: 'routeros' },
|
||||
{ id: 2, backup_type: 'binary', file_name: 'forbidden.backup' },
|
||||
{ id: 3, backup_type: 'export', file_name: 'forbidden.swb', device_type: 'switchos' }
|
||||
];
|
||||
app.state.diffSelection = { mode: 'same', router_id: 1, left: '', right: '' };
|
||||
const diff = app.diffControls();
|
||||
assert.ok(diff.includes('allowed.rsc'));
|
||||
assert.ok(!diff.includes('forbidden.'));
|
||||
@@ -209,3 +212,42 @@ test('a late device response cannot overwrite the state after navigation', async
|
||||
assert.equal(await load, '');
|
||||
assert.equal(app.state.cache.device, undefined);
|
||||
});
|
||||
|
||||
|
||||
test('diff controls support explicit cross-device pairs and full rendering on demand', () => {
|
||||
const app = application();
|
||||
app.state.cache.routers = [
|
||||
{ id: 1, name: 'R1', host: '10.0.0.1', device_type: 'routeros' },
|
||||
{ id: 2, name: 'R2', host: '10.0.0.2', device_type: 'routeros' }
|
||||
];
|
||||
app.state.cache.diffFiles = [
|
||||
{ id: 11, router_id: 1, backup_type: 'export', device_type: 'routeros', file_name: 'r1.rsc', created_at: '2026-01-01T00:00:00Z' },
|
||||
{ id: 22, router_id: 2, backup_type: 'export', device_type: 'routeros', file_name: 'r2.rsc', created_at: '2026-01-02T00:00:00Z' }
|
||||
];
|
||||
app.state.diffSelection = { mode: 'cross', left_router_id: 1, right_router_id: 2, left: 11, right: 22 };
|
||||
const controls = app.diffControls();
|
||||
assert.ok(controls.includes('cross-device'));
|
||||
assert.ok(controls.includes('r1.rsc'));
|
||||
assert.ok(controls.includes('r2.rsc'));
|
||||
|
||||
app.state.diffChangesOnly = false;
|
||||
app.state.diff = {
|
||||
left_backup_id: 11, right_backup_id: 22, left_file_name: 'r1.rsc', right_file_name: 'r2.rsc',
|
||||
stats: { added: 250, removed: 0, modified: 0, context: 0 }, smart: null,
|
||||
lines: Array.from({ length: 250 }, (_, i) => ({ type: 'added', left_number: null, right_number: i + 1, left_text: '', right_text: `line-${i + 1}` }))
|
||||
};
|
||||
assert.ok(app.diffResult().includes('data-action="diff-toggle-all"'));
|
||||
app.state.diffShowAll = true;
|
||||
const full = app.diffResult();
|
||||
assert.ok(full.includes('line-250'));
|
||||
assert.ok(!full.includes('data-action="diff-page-next"'));
|
||||
assert.ok(full.includes('data-action="open-html-diff"'));
|
||||
});
|
||||
|
||||
test('local file upload form is restricted to RouterOS backup script/binary extensions', () => {
|
||||
const app = application();
|
||||
const html = app.uploadFileForm([{ id: 7, name: 'R7', host: '10.0.0.7', device_type: 'routeros' }]);
|
||||
assert.ok(html.includes('id="device-file-upload-form"'));
|
||||
assert.ok(html.includes('accept=".rsc,.backup"'));
|
||||
assert.ok(html.includes('value="7"'));
|
||||
});
|
||||
Reference in new issue
Block a user