Files
Azornes-Comfyui-Model-Resolver/tests/test_download_progress_methods.mjs
T
Dariusz L d9286b53d5 Retain interrupted download progress cards and add in-place retry action
- Keep failed or interrupted downloads in active downloads queue instead of dismissing immediately
- Present interrupted state with error tooltip, distinct status chip, and progress percentage
- Add in-place Retry download play action that resumes downloading from existing partial files
- Support dismissing interrupted downloads via cancel button
- Update CSS styling and unit tests for download action handlers and progress states
2026-10-26 16:42:56 +01:00

38 lines
1.8 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { downloadProgressMethods } from '../web/resolver/actions/download_progress_methods.js';
test('download progress labels cover active, paused, checking, and terminal states', () => {
const context = {
...downloadProgressMethods,
formatDownloadPercent: percent => percent.toFixed(1),
};
assert.equal(context.getDownloadProgressStatusLabel('downloading', 42.5), '42.5%');
assert.equal(context.getDownloadProgressStatusLabel('downloading', 42.5, true), 'Finalizing');
assert.equal(context.getDownloadProgressStatusLabel('starting'), 'Starting');
assert.equal(context.getDownloadProgressStatusLabel('paused'), 'Paused');
assert.equal(context.getDownloadProgressStatusLabel('error'), 'Interrupted');
assert.equal(context.getDownloadProgressStatusLabel('refresh_error'), 'Interrupted');
assert.equal(context.getDownloadProgressStatusLabel('completed_checking'), 'Checking');
assert.equal(context.getDownloadProgressStatusLabel('cancelled'), 'cancelled');
assert.equal(context.getDownloadProgressStatusLabel(''), 'Download');
});
test('download progress status distinguishes active and terminal states', () => {
const isActive = downloadProgressMethods.isDownloadProgressStatus;
assert.equal(isActive('starting'), true);
assert.equal(isActive('downloading'), true);
assert.equal(isActive('paused'), true);
assert.equal(isActive('cancelling'), false);
assert.equal(isActive('completed'), false);
assert.equal(isActive('error', true), true);
assert.equal(isActive('error', false), false);
assert.equal(isActive('refresh_error', true), true);
assert.equal(isActive('refresh_error', false), false);
assert.equal(isActive('custom', true), true);
assert.equal(isActive('custom', false), false);
});