Files
pipelines/app/test/features/runs/ui/run_timeline_row_test.dart
T
alan 9551eceaed Complete Material-only APIs and fixtures
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
2026-11-11 21:55:39 +00:00

83 lines
2.7 KiB
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() {
testWidgets('timeline rows lead with their real status', (tester) async {
final list = RunTimelineList(
visits: detailTimeline(_steps),
onSelected: (_) {},
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: list)));
// No placeholder circles: every row has the state's own glyph.
expect(find.byIcon(Icons.circle_outlined), 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.
expect(find.byType(AppListRow), findsNWidgets(3));
});
testWidgets('outcome chips are coloured by name, not by status', (
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));
await tester.pumpWidget(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')));
});
}