fix(app): meaning colours for common outcomes; detail pages fill the pane
Timeline outcomes: success-like words are green, failures red, rejections orange, retries/advisories amber, skips/cancellations grey; a second word of the same family takes the family's next shade and any other word a distinct hue outside the families, so different outcomes still never share a colour. Run detail, stage page and pipeline Summary no longer cap their width at 840: on an unfolded foldable the sections fill the pane. The unused ReadingWidth helper is removed.
This commit is contained in:
@@ -3,29 +3,62 @@ 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);
|
||||
});
|
||||
for (final brightness in Brightness.values) {
|
||||
Color colour(OutcomePalette palette, String name) =>
|
||||
palette.colorForBrightness(name, brightness)!;
|
||||
final dark = brightness == Brightness.dark;
|
||||
Color shade(MaterialColor c) => dark ? c.shade300 : c.shade800;
|
||||
|
||||
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');
|
||||
}
|
||||
test('well-known outcomes take their meaning colour ($brightness)', () {
|
||||
final palette = OutcomePalette([
|
||||
'rejected',
|
||||
'retry',
|
||||
'Success',
|
||||
'error',
|
||||
'skipped',
|
||||
]);
|
||||
expect(colour(palette, 'success'), shade(Colors.green));
|
||||
expect(colour(palette, 'error'), shade(Colors.red));
|
||||
expect(colour(palette, 'rejected'), shade(Colors.deepOrange));
|
||||
expect(colour(palette, 'retry'), shade(Colors.amber));
|
||||
expect(colour(palette, 'skipped'), shade(Colors.blueGrey));
|
||||
// Case and surrounding space do not make a different outcome.
|
||||
expect(colour(palette, ' SUCCESS '), shade(Colors.green));
|
||||
});
|
||||
|
||||
test('different names never share a colour ($brightness)', () {
|
||||
final names = [
|
||||
'success',
|
||||
'approved',
|
||||
'passed',
|
||||
'done',
|
||||
'error',
|
||||
'failed',
|
||||
'fail',
|
||||
'rejected',
|
||||
'blocked',
|
||||
'denied',
|
||||
'retry',
|
||||
'advisory',
|
||||
'warning',
|
||||
'skipped',
|
||||
'canceled',
|
||||
'stopped',
|
||||
for (var i = 0; i < 30; i++) 'custom-$i',
|
||||
];
|
||||
final palette = OutcomePalette(names);
|
||||
final colours = {for (final name in names) colour(palette, name)};
|
||||
expect(colours, hasLength(names.length));
|
||||
// Two success-like words: both green family, but distinct shades.
|
||||
expect(colour(palette, 'approved'), shade(Colors.lightGreen));
|
||||
});
|
||||
}
|
||||
|
||||
test('unseen or blank names have no colour of their own', () {
|
||||
final palette = OutcomePalette(['success', '']);
|
||||
expect(palette.contains('success'), isTrue);
|
||||
expect(palette.contains(''), isFalse);
|
||||
expect(palette.contains('other'), isFalse);
|
||||
expect(palette.colorForBrightness('other', Brightness.light), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user