Files
pipelines/app/test/features/runs/ui/run_timeline_row_test.dart
T
alan 1bf2ae41c4 fix(runs): colour timeline outcomes by name, not by status
A completed step's outcome chip took the success colour, so 'rejected'
read green beside 'success'. Outcome chips now get one colour per
distinct outcome name in the run (assigned by first appearance, from a
well-separated hue list that continues by the golden angle), so equal
names match and different names never share a colour. No outcome word
is wired to a colour; the status glyph still shows the step's state.
2026-10-31 12:28:54 +00:00

96 lines
3.1 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/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);
expect(find.text('→ build · 2m 5s'), findsOneWidget);
expect(find.text('→ #failure'), findsOneWidget);
});
}
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')));
});
}
}