wip(app): runs-day-groups (retained from the cancelled overrun lane)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:pipelines_app/features/runs/domain/run_models.dart';
|
||||
|
||||
void main() {
|
||||
group('run day grouping', () {
|
||||
final today = DateTime(2026, 10, 22, 12);
|
||||
|
||||
test('labels local days and invalid dates', () {
|
||||
expect(runDayLabel('2026-10-22T08:00:00', today), 'Today');
|
||||
expect(runDayLabel('2026-10-21T08:00:00', today), 'Yesterday');
|
||||
expect(runDayLabel('2026-10-17T08:00:00', today), '17 Oct 2026');
|
||||
expect(runDayLabel('', today), 'Unknown date');
|
||||
expect(localDayKey(DateTime(2026, 1, 2)), '2026-01-02');
|
||||
});
|
||||
|
||||
test('retains encounter order and groups adjacent equal labels', () {
|
||||
final runs = [
|
||||
{'id': 3, 'created_at': '2026-10-22T09:00:00'},
|
||||
{'id': 2, 'created_at': '2026-10-21T09:00:00'},
|
||||
{'id': 1, 'created_at': '2026-10-21T08:00:00'},
|
||||
{'id': 0, 'created_at': ''},
|
||||
];
|
||||
final groups = groupRunsByDay(runs, today);
|
||||
expect(groups.map((group) => group.label), [
|
||||
'Today',
|
||||
'Yesterday',
|
||||
'Unknown date',
|
||||
]);
|
||||
expect(groups.expand((group) => group.runs).map((run) => run['id']), [
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
0,
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user