fix(downloads): harden queue reordering and summary stats

This commit is contained in:
NimBold
2026-07-23 06:23:04 +03:30
parent 3587fb0c0d
commit 3559c69968
13 changed files with 413 additions and 129 deletions
+21
View File
@@ -37,6 +37,27 @@ describe('download summaries', () => {
});
});
it('treats completed downloads as having no remaining bytes despite stale progress', () => {
expect(summarizeDownloads([
item('done', {
status: 'completed',
totalBytes: 40 * 1024 ** 2,
downloadedBytes: 40 * 1024 ** 2,
}),
], {
done: progress('done', {
downloaded_bytes: 40 * 1024 ** 2 - 555 * 1024,
total_bytes: 555 * 1024,
}),
})).toEqual({
itemCount: 1,
activeCount: 0,
downloadedBytes: 40 * 1024 ** 2,
remainingBytes: 0,
remainingIsEstimated: false,
});
});
it('does not present partial byte totals as complete aggregates', () => {
expect(summarizeDownloads([
item('known', { totalBytes: 100, downloadedBytes: 20 }),