feat(app): run rows show the run's path as a small coloured miniature
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
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_path_mini.dart';
|
||||
|
||||
void main() {
|
||||
final run = {
|
||||
'graph_evidence': {
|
||||
'complete': true,
|
||||
'visits': [
|
||||
{'stage': 'plan', 'status': 'completed', 'outcome': 'success'},
|
||||
{'stage': 'build', 'status': 'completed', 'outcome': 'retry'},
|
||||
{
|
||||
'stage': 'build',
|
||||
'status': 'completed',
|
||||
'outcome': 'error',
|
||||
'target': '#failure',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
test('the path keeps first-visit order and each stage latest state', () {
|
||||
final path = runPath(run);
|
||||
expect(path.stages.map((stage) => stage.key), ['plan', 'build']);
|
||||
expect(path.stages.map((stage) => stage.state), ['succeeded', 'failed']);
|
||||
expect(path.end, '#failure');
|
||||
expect(runPath({}).stages, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('the miniature colours each stage by its result', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Center(child: RunPathMini(run: run)),
|
||||
),
|
||||
),
|
||||
);
|
||||
final colors = tester
|
||||
.widgetList<Container>(find.byType(Container))
|
||||
.map((box) => (box.decoration as BoxDecoration?)?.color)
|
||||
.whereType<Color>()
|
||||
.map((color) => color.toARGB32())
|
||||
.toList();
|
||||
expect(colors, contains(CupertinoColors.systemGreen.color.toARGB32()));
|
||||
expect(colors, contains(CupertinoColors.systemRed.color.toARGB32()));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user