Files
pipelines/app/test/ui/status/outcome_palette_test.dart
T
alan 6b11b136db 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.
2026-10-31 14:36:15 +00:00

65 lines
2.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/status/outcome_palette.dart';
void main() {
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('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);
});
}