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.
This commit is contained in:
@@ -56,4 +56,40 @@ void main() {
|
||||
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')));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/status/outcome_palette.dart';
|
||||
|
||||
void main() {
|
||||
test('same outcome names share a colour; different names never do', () {
|
||||
final palette = OutcomePalette([
|
||||
'success',
|
||||
'rejected',
|
||||
'Success',
|
||||
'approved',
|
||||
'',
|
||||
'rejected ',
|
||||
]);
|
||||
expect(palette.indexOf('success'), 0);
|
||||
expect(palette.indexOf('SUCCESS'), 0);
|
||||
expect(palette.indexOf('rejected'), 1);
|
||||
expect(palette.indexOf('approved'), 2);
|
||||
expect(palette.indexOf(''), isNull);
|
||||
expect(palette.indexOf('never seen'), isNull);
|
||||
});
|
||||
|
||||
test('the first fifty outcome colours are all distinct in both themes', () {
|
||||
for (final brightness in Brightness.values) {
|
||||
final colours = {
|
||||
for (var i = 0; i < 50; i++) outcomeColorAt(i, brightness).toARGB32(),
|
||||
};
|
||||
expect(colours, hasLength(50), reason: '$brightness');
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user