Files
pipelines/app/test/features/runs/ui/run_timeline_row_test.dart
T
alan 8d9a21c310 Merge branch 'worktree-agent-a75e04ded5a42e4fb' into integrate/detail-bodies
# Conflicts:
#	app/lib/features/runs/ui/run_detail_timeline.dart
2026-10-31 12:42:39 +00:00

102 lines
3.5 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_content.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_timeline.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/ui/status/run_status_icon.dart';
final _steps = [
{
'stage': 'plan',
'sequence': 1,
'status': 'completed',
'outcome': 'success',
'target': 'build',
'started_at': '2026-10-21T12:00:00Z',
'finished_at': '2026-10-21T12:02:05Z',
},
{
'stage': 'build',
'sequence': 2,
'status': 'completed',
'outcome': 'error',
'target': '#failure',
},
{'stage': 'review', 'sequence': 3, 'status': 'running'},
];
void main() {
for (final cupertino in [false, true]) {
testWidgets('timeline rows lead with their real status '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
final list = RunTimelineList(
visits: detailTimeline(_steps),
cupertino: cupertino,
onSelected: (_) {},
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: list))
: MaterialApp(home: Scaffold(body: list)),
);
// No placeholder circles: every row has the state's own glyph.
expect(find.byIcon(Icons.circle_outlined), findsNothing);
expect(find.byIcon(CupertinoIcons.circle), findsNothing);
final states = tester
.widgetList<RunStatusIcon>(find.byType(RunStatusIcon))
.map((icon) => icon.state)
.toList();
// A completed step whose outcome is an error reads as failed.
expect(states, ['succeeded', 'failed', 'running']);
expect(find.text('success'), findsOneWidget);
expect(find.text('error'), findsOneWidget);
// The target is the line; the duration is the row's time.
expect(find.text('→ build'), findsOneWidget);
expect(find.text('2m 5s'), findsOneWidget);
expect(find.text('→ #failure'), findsOneWidget);
// The shared flat row, with no grouped card on either host.
expect(find.byType(AppListRow), findsNWidgets(3));
expect(find.byType(CupertinoListSection), findsNothing);
});
}
for (final cupertino in [false, true]) {
testWidgets('outcome chips are coloured by name, not by status '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
// Every step completed: before, all three chips were the success colour.
final steps = [
for (final (i, outcome) in [
'success',
'rejected',
'success',
'approved',
].indexed)
{
'stage': 'stage$i',
'sequence': i + 1,
'status': 'completed',
'outcome': outcome,
},
];
final list = RunTimelineList(
visits: detailTimeline(steps),
cupertino: cupertino,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: list))
: MaterialApp(home: Scaffold(body: list)),
);
Color chip(String text, [int at = 0]) =>
tester.widget<Text>(find.text(text).at(at)).style!.color!;
expect(chip('success'), chip('success', 1));
expect(chip('rejected'), isNot(chip('success')));
expect(chip('approved'), isNot(chip('success')));
expect(chip('approved'), isNot(chip('rejected')));
});
}
}