You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
1.5 KiB

const test = require('node:test');
const assert = require('node:assert/strict');
const { view } = require('../frontend/web/static/js/firmware-progress.js');
test('upload 100% never claims the firmware update succeeded', () => {
const upload = view({ state: 'receiving', bytes_received: 100, bytes_total: 100 });
assert.equal(upload.percent, 100);
assert.equal(upload.busy, true);
assert.notEqual(upload.tone, 'is-success');
assert.equal(view({ state: 'validating', progress_percent: 85 }).percent, null);
});
test('all active device stages retain a visible busy indicator', () => {
for (const state of ['receiving', 'staged', 'validating', 'apply_pending', 'reboot_pending', 'applying', 'verifying']) {
assert.equal(view({ state }).busy, true, state);
assert.notEqual(view({ state }).tone, 'is-success', state);
}
});
test('only a confirmed succeeded status is shown as completed', () => {
assert.equal(view({ state: 'succeeded' }).tone, 'is-success');
assert.equal(view({ state: 'succeeded' }).busy, false);
assert.notEqual(view({ state: 'validated' }).tone, 'is-success');
assert.notEqual(view({ state: 'unknown' }).tone, 'is-success');
});
test('failure details remain visible and retry is allowed', () => {
const failed = view({ state: 'failed', failure_reason: 'device version is below the package minimum' });
assert.equal(failed.detail, 'device version is below the package minimum');
assert.equal(failed.tone, 'is-error');
assert.equal(failed.busy, false);
});