feat(task): record and display task completion time (#1536)

This commit is contained in:
Levi authored and GitHub committed 2026-09-25 19:15:31 +08:00
1 parent 7ce4fb7f0e
commit 224b488087
30 files changed
+113 -23

No files matched your search

@@ -4,7 +4,7 @@ import 'package:gopeed/core/icons/gopeed_icons.dart';
import 'package:gopeed/features/tasks/domain/task_record.dart';
void main() {
api.Task buildTask(List<int> selection, int size) => api.Task.fromJson({
api.Task buildTask(List<int> selection, int size, {String? doneAt}) => api.Task.fromJson({
'id': 'bt-selection',
'name': 'bundle',
'protocol': 'bt',
@@ -12,6 +12,7 @@ void main() {
'uploading': false,
'createdAt': '2026-01-01T00:00:00Z',
'updatedAt': '2026-01-01T00:00:00Z',
'doneAt': doneAt,
'meta': {
'req': {'url': 'magnet:?xt=urn:btih:test'},
'opts': {'path': '/downloads', 'selectFiles': selection},
@@ -43,6 +44,13 @@ void main() {
expect(record.totalBytes, 60);
});
test('completion time maps from api and stays null for legacy tasks', () {
final completed = TaskRecord.fromApi(buildTask([], 60, doneAt: '2026-01-02T03:04:05Z'));
expect(completed.doneAt, DateTime.parse('2026-01-02T03:04:05Z'));
final legacy = TaskRecord.fromApi(buildTask([], 60));
expect(legacy.doneAt, isNull);
});
test('file names preserve hash and question mark characters for type detection', () {
expect(
taskFileTypeIcon('Slow English Podcast #2 _ Eating, Talking, and Learning Natural English.mp4'),