feat(upload): simplify upload file list display and add live speed & ETA (#513)

* feat(upload): simplify upload file list display and add live speed and ETA

* fix(upload): retain authoritative server search results and handle local failed upload state gracefully
This commit is contained in:
Yiling-J
2026-11-01 13:29:52 +08:00
committed by GitHub
parent fbff404b9b
commit 20ad0abeba
14 changed files with 372 additions and 97 deletions
+28 -1
View File
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { formatRemainingTime, getTrashDaysLeft } from './time'
import { formatRemainingTime, formatRemainingTimeSeconds, getTrashDaysLeft } from './time'
describe('formatRemainingTime', () => {
const baseNow = new Date('2026-08-17T12:00:00Z')
@@ -45,6 +45,33 @@ describe('formatRemainingTime', () => {
})
})
describe('formatRemainingTimeSeconds', () => {
it('formats hours and minutes', () => {
expect(formatRemainingTimeSeconds(3 * 3600 + 18 * 60)).toBe('3h 18m')
})
it('formats exact hours', () => {
expect(formatRemainingTimeSeconds(3 * 3600)).toBe('3h')
})
it('formats minutes', () => {
expect(formatRemainingTimeSeconds(8 * 60)).toBe('8m')
expect(formatRemainingTimeSeconds(45 * 60 + 20)).toBe('45m')
})
it('formats seconds', () => {
expect(formatRemainingTimeSeconds(45)).toBe('45s')
expect(formatRemainingTimeSeconds(1)).toBe('1s')
})
it('handles zero, negative, or invalid numbers', () => {
expect(formatRemainingTimeSeconds(0)).toBe('< 1s')
expect(formatRemainingTimeSeconds(-5)).toBe('< 1s')
expect(formatRemainingTimeSeconds(NaN)).toBe('< 1s')
expect(formatRemainingTimeSeconds(Infinity)).toBe('< 1s')
})
})
describe('getTrashDaysLeft', () => {
const now = new Date('2026-08-17T12:00:00Z')