Files
pipelines/app/test/features/templates/ui/template_gallery_create_test.dart
T
alan 1db273894c Remove Cupertino template branches
Keep the Material-only template implementation and narrow its tests to the runtime path. Retain public Cupertino parameters for compatibility while removing unreachable hosts, widgets, and test variants.
2026-11-11 02:53:23 +00:00

79 lines
2.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/templates/screen.dart';
import 'package:pipelines_app/features/templates/ui/template_create_wording.dart';
import '../data/template_test_support.dart' show source;
import 'template_gallery_test_support.dart';
Future<void> openRelease(WidgetTester tester) async {
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(templateCreateActionKey));
await tester.pumpAndSettle();
}
void main() {
testWidgets(
'Cancel sends nothing; Create validates and submits the verbatim source '
'once through the existing prompt',
(tester) async {
final gateway = GalleryGateway((type, fields) async {
if (type == 'list_templates') return templatesReply(galleryTemplates);
return acceptedCreate(type, fields);
});
final created = <JsonMap>[];
await pumpGallery(tester, gateway, onCreated: created.add);
await openRelease(tester);
expect(find.byType(AlertDialog), findsOneWidget);
expect(find.text('Create from Release workflow'), findsOneWidget);
await tester.enterText(find.byKey(templateCreateNameKey), 'Café');
await tester.pump();
await tester.tap(find.byKey(templateCreateCancelKey));
await tester.pumpAndSettle();
expect(find.byType(AlertDialog), findsNothing);
expect(gateway.callsOf('validate'), hasLength(2));
expect(gateway.callsOf('submit'), isEmpty);
expect(created, isEmpty);
await tester.tap(find.byKey(templateCreateActionKey));
await tester.pumpAndSettle();
expect(find.byKey(templateCreateNameKey), findsOneWidget);
await tester.enterText(find.byKey(templateCreateNameKey), ' Café ');
await tester.pump();
await tester.tap(find.byKey(templateCreateConfirmKey));
await tester.pumpAndSettle();
expect(gateway.callsOf('validate'), hasLength(3));
expect(gateway.callsOf('validate').last.fields, {'source': source});
expect(gateway.callsOf('submit').single.fields, {
'name': 'Café',
'source': source,
'create_only': true,
});
expect(gateway.callsOf('submit').single.fields.keys, [
'name',
'source',
'create_only',
]);
expect(created, [
{'id': 7, 'name': 'Created release'},
]);
expect(
find.text('Created "Created release". It is in the Pipelines list.'),
findsOneWidget,
);
expect(find.text('Close'), findsOneWidget);
await tester.tap(find.byKey(templateCreateCancelKey));
await tester.pumpAndSettle();
expect(find.byKey(templateDetailKey), findsOneWidget);
expect(created, hasLength(1));
expect(gateway.callsOf('submit'), hasLength(1));
},
);
}