feat(app): run rows place the run, number, pipeline, duration, time and steps in their corners

This commit is contained in:
2026-10-23 17:19:04 +01:00
parent 9c685eeed0
commit e1c472089e
4 changed files with 217 additions and 29 deletions
@@ -0,0 +1,62 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/domain/run_models.dart';
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
final _finished = {
'id': 42,
'title': 'Ship the release notes',
'name': 'release',
'status': 'succeeded',
'executing': false,
'created_at': '2026-10-21T12:00:00Z',
'finished_at': '2026-10-21T12:02:05Z',
'completed_steps': 3,
};
void main() {
test('row facts: when, how long and how far', () {
final facts = runRowFacts(_finished, DateTime.utc(2026, 10, 22));
expect(facts.when, contains('→'));
expect(facts.duration, '2m 5s');
expect(facts.progress, '3 steps');
final running = runRowFacts({
..._finished,
'executing': true,
'finished_at': '',
'completed_steps': 1,
'current_stage': 'review',
}, DateTime.utc(2026, 10, 21, 12, 0, 45));
expect(running.when, isNot(contains('→')));
expect(running.duration, '45s');
expect(running.progress, '1 step · at review');
});
testWidgets('a run row places its facts in the corners', (tester) async {
tester.view.physicalSize = const Size(800, 400);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunListRow(run: _finished, now: DateTime.utc(2026, 10, 22)),
),
),
);
Rect at(String text) => tester.getRect(find.text(text));
final title = at('Ship the release notes');
final number = at('#42');
final pipeline = at('release');
final duration = at('2m 5s');
final steps = at('3 steps');
// Left column: run, pipeline, time; right column: number, duration, steps.
expect(number.center.dy, moreOrLessEquals(title.center.dy));
expect(duration.center.dy, moreOrLessEquals(pipeline.center.dy));
expect(pipeline.top, greaterThan(title.bottom));
expect(steps.top, greaterThan(duration.bottom));
for (final right in [number, duration, steps]) {
expect(right.right, greaterThan(800 - 32));
}
});
}
@@ -83,7 +83,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('Beta'), findsNWidgets(2));
expect(find.text('Alpha'), findsNothing);
await tester.tap(find.byType(CupertinoListTile));
await tester.tap(find.byKey(const ValueKey('run-row-2')));
expect(selectedRun, 2);
await tester.enterText(find.byType(CupertinoSearchTextField), 'missing');
await tester.pumpAndSettle();