feat(task): show a dash for completed tasks without a done time

Tasks completed before this change have no doneAt value; the drawer now
always renders the Completed at row for completed tasks and falls back
to a dash instead of hiding the row.
This commit is contained in:
Levi committed 2026-09-20 09:28:46 +08:00
1 parent 1d8a502ac4
commit 7bc7efed5b
2 files changed
+32 -2

No files matched your search

@@ -319,8 +319,14 @@ class _TaskInfoTab extends StatelessWidget {
_InfoBlock(label: context.l10n.remaining, value: remaining),
if (task.createdAt case final createdAt?)
_InfoBlock(label: context.l10n.createdAt, value: _formatTaskDateTime(createdAt)),
if (task.doneAt case final doneAt?)
_InfoBlock(label: context.l10n.doneAt, value: _formatTaskDateTime(doneAt)),
if (task.status == TaskStatus.completed)
_InfoBlock(
label: context.l10n.doneAt,
value: switch (task.doneAt) {
final doneAt? => _formatTaskDateTime(doneAt),
_ => '—',
},
),
Container(
key: const ValueKey('task-details-info-divider'),
height: 1,
+24
View File
@@ -4267,6 +4267,30 @@ void main() {
expect(find.text('—'), findsOneWidget);
});
testWidgets('completed task details show a dash when no done time is recorded', (WidgetTester tester) async {
await _setTestSize(tester, const Size(900, 700));
final task = _taskRecord(
id: 'done-details',
name: 'done.zip',
status: TaskStatus.completed,
downloadDuration: const Duration(hours: 1, minutes: 2, seconds: 3),
);
await tester.pumpWidget(
ProviderScope(
child: shad.ShadcnApp(
theme: AppTheme.light(),
materialTheme: AppTheme.materialLight(),
home: TaskDetailsView(task: task, mobile: false, onOpenStorage: () {}, onUpdateUrl: (_) async {}),
),
),
);
await tester.pumpAndSettle();
expect(find.text('Completed at'), findsOneWidget);
expect(find.text('—'), findsOneWidget);
});
testWidgets('failed task details omit the unavailable error reason', (WidgetTester tester) async {
await _setTestSize(tester, const Size(900, 700));
final task = TaskRecord(