feat(app): show template stage counts
This commit is contained in:
@@ -128,6 +128,10 @@ Future<void> openTemplates(
|
||||
},
|
||||
],
|
||||
});
|
||||
await reply(tester, channel, 'validate', listRead, {
|
||||
'type': 'graph',
|
||||
'graph': {'stages': <dynamic>[]},
|
||||
});
|
||||
}
|
||||
|
||||
void main() {
|
||||
@@ -279,7 +283,7 @@ void main() {
|
||||
await tester.tap(find.byKey(templateCreateConfirmKey));
|
||||
await tester.pump();
|
||||
|
||||
await reply(tester, channel, 'validate', 1, {
|
||||
await reply(tester, channel, 'validate', 2, {
|
||||
'type': 'graph',
|
||||
'graph': {'stages': <dynamic>[]},
|
||||
});
|
||||
@@ -334,7 +338,8 @@ void main() {
|
||||
// again adds no request.
|
||||
expect(requestsOf(channel, 'list_pipelines'), hasLength(2));
|
||||
expect(requestsOf(channel, 'list_runs'), hasLength(2));
|
||||
expect(requestsOf(channel, 'validate'), hasLength(1));
|
||||
// One validation derives the gallery count; the other belongs to Create.
|
||||
expect(requestsOf(channel, 'validate'), hasLength(2));
|
||||
expect(requestsOf(channel, 'submit'), hasLength(1));
|
||||
expect(sockets, 1);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(AlertDialog), findsNothing);
|
||||
expect(gateway.callsOf('validate'), isEmpty);
|
||||
expect(gateway.callsOf('validate'), hasLength(2));
|
||||
expect(gateway.callsOf('submit'), isEmpty);
|
||||
expect(created, isEmpty);
|
||||
|
||||
@@ -48,7 +48,8 @@ void main() {
|
||||
await tester.tap(find.byKey(templateCreateConfirmKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(gateway.callsOf('validate').single.fields, {'source': source});
|
||||
expect(gateway.callsOf('validate'), hasLength(3));
|
||||
expect(gateway.callsOf('validate').last.fields, {'source': source});
|
||||
expect(gateway.callsOf('submit').single.fields, {
|
||||
'name': 'Café',
|
||||
'source': source,
|
||||
@@ -93,7 +94,7 @@ void main() {
|
||||
await tester.tap(find.byKey(templateCreateConfirmKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(gateway.callsOf('validate'), hasLength(1));
|
||||
expect(gateway.callsOf('validate'), hasLength(3));
|
||||
expect(gateway.callsOf('submit'), hasLength(1));
|
||||
expect(
|
||||
find.text('Created "Created release". It is in the Pipelines list.'),
|
||||
|
||||
@@ -31,10 +31,31 @@ void main() {
|
||||
expect(find.byKey(templatesGalleryKey), findsOneWidget);
|
||||
expect(find.text('Release workflow'), findsOneWidget);
|
||||
expect(find.text('Ship a version'), findsOneWidget);
|
||||
expect(find.text('2 stages'), findsNWidgets(2));
|
||||
expect(find.text('(unnamed template)'), findsOneWidget);
|
||||
expect(find.byKey(templatesLoadingKey), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('stage count is unavailable when server parsing refuses', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway =
|
||||
GalleryGateway((type, fields) async => templatesReply(galleryTemplates))
|
||||
..validationHandler = (type, fields) async {
|
||||
throw Exception('invalid definition');
|
||||
};
|
||||
|
||||
await pumpGallery(tester, gateway);
|
||||
|
||||
expect(find.text('stage count unavailable'), findsNWidgets(2));
|
||||
expect(find.text('0 stages'), findsNothing);
|
||||
expect(gateway.callsOf('validate'), hasLength(2));
|
||||
expect(
|
||||
gateway.callsOf('validate').first.fields['source'],
|
||||
galleryTemplates.first['source'],
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('an empty catalogue states it without inventing rows', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -148,7 +169,11 @@ void main() {
|
||||
expect(selectableSource(source), findsOneWidget);
|
||||
expect(selectableSource('release'), findsOneWidget);
|
||||
expect(find.text(templateCreateActionLabel), findsOneWidget);
|
||||
expect(gateway.callsOf('validate'), isEmpty);
|
||||
expect(gateway.callsOf('validate'), hasLength(2));
|
||||
expect(
|
||||
gateway.callsOf('validate').map((call) => call.fields['source']),
|
||||
everyElement(source),
|
||||
);
|
||||
expect(gateway.callsOf('submit'), isEmpty);
|
||||
|
||||
await tester.tap(find.byKey(templatesBackKey));
|
||||
|
||||
@@ -17,11 +17,22 @@ class GalleryGateway implements ApiGateway {
|
||||
|
||||
final GalleryHandler handler;
|
||||
final List<({String type, JsonMap fields})> calls = [];
|
||||
GalleryHandler? validationHandler;
|
||||
|
||||
@override
|
||||
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
|
||||
final copy = Map<String, dynamic>.from(fields);
|
||||
calls.add((type: type, fields: copy));
|
||||
if (type == 'validate' && validationHandler != null) {
|
||||
return validationHandler!(type, copy);
|
||||
}
|
||||
if (type == 'validate') {
|
||||
return {
|
||||
'graph': {
|
||||
'stages': [{}, {}],
|
||||
},
|
||||
};
|
||||
}
|
||||
return handler(type, copy);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user