fe24f228fe
Review r2 findings P2-4, P2-5, P3-13: a shared relative-time helper for
every list row's time, formatDuration switches to days past 24h ('9d
16h'), the stage page uses one visit numbering, drops a repeated stage
heading and fixes '1 files', and search run hits read 'Run 1'.
Implemented by pipeline run #205/#207 (Terra); its UIReview blocked on a
fixture without timestamps, verified by the manager.
37 lines
1.1 KiB
Dart
37 lines
1.1 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/ui/text/relative_time.dart';
|
|
|
|
void main() {
|
|
final now = DateTime(2026, 10, 22, 12);
|
|
|
|
test('formats compact past and future list-row times', () {
|
|
expect(formatRelativeTime(now, now: now), 'just now');
|
|
expect(
|
|
formatRelativeTime(now.subtract(const Duration(minutes: 5)), now: now),
|
|
'5m',
|
|
);
|
|
expect(
|
|
formatRelativeTime(now.subtract(const Duration(hours: 3)), now: now),
|
|
'3h',
|
|
);
|
|
expect(
|
|
formatRelativeTime(now.subtract(const Duration(days: 3)), now: now),
|
|
'3d',
|
|
);
|
|
expect(
|
|
formatRelativeTime(now.subtract(const Duration(days: 8)), now: now),
|
|
'14 Oct',
|
|
);
|
|
expect(
|
|
formatRelativeTime(now.add(const Duration(hours: 2)), now: now),
|
|
'in 2h',
|
|
);
|
|
});
|
|
|
|
test('parses timestamps and omits unusable values', () {
|
|
expect(formatRelativeTimestamp('2026-10-22T11:55:00', now: now), '5m');
|
|
expect(formatRelativeTimestamp('', now: now), isNull);
|
|
expect(formatRelativeTimestamp('not a time', now: now), isNull);
|
|
});
|
|
}
|