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.
This commit is contained in:
2026-11-11 02:53:23 +00:00
parent 42cb6a6f2d
commit 1db273894c
16 changed files with 302 additions and 613 deletions
@@ -192,34 +192,28 @@ void main() {
);
});
testWidgets('the name field is labelled for screen readers on both hosts', (
tester,
) async {
testWidgets('the name field is labelled for screen readers', (tester) async {
final handle = tester.ensureSemantics();
for (final cupertino in <bool>[false, true]) {
await tester.pumpWidget(
templateCreateApp(
TemplateCreateHost(
gateway: FakeTemplateCreateGateway(acceptedTemplateCreate),
onCreated: (_) {},
cupertino: cupertino,
),
cupertino: cupertino,
textScale: 2,
await tester.pumpWidget(
templateCreateApp(
TemplateCreateHost(
gateway: FakeTemplateCreateGateway(acceptedTemplateCreate),
onCreated: (_) {},
),
);
await tester.tap(find.byKey(templateCreateOpenKey));
await tester.pumpAndSettle();
await tester.enterText(find.byKey(templateCreateNameKey), 'Scaled');
await tester.pump();
textScale: 2,
),
);
await tester.tap(find.byKey(templateCreateOpenKey));
await tester.pumpAndSettle();
await tester.enterText(find.byKey(templateCreateNameKey), 'Scaled');
await tester.pump();
final data = tester
.getSemantics(find.byKey(templateCreateNameKey))
.getSemanticsData();
expect(data.label, templateCreateNameLabel);
expect(data.value, 'Scaled');
expect(data.flagsCollection.isTextField, isTrue);
}
final data = tester
.getSemantics(find.byKey(templateCreateNameKey))
.getSemanticsData();
expect(data.label, templateCreateNameLabel);
expect(data.value, 'Scaled');
expect(data.flagsCollection.isTextField, isTrue);
handle.dispose();
});
}
@@ -1,13 +1,11 @@
import 'dart:async';
import 'package:flutter/cupertino.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/core/transport/connection_state.dart';
import 'package:pipelines_app/features/templates/ui/template_create_wording.dart';
import '../data/template_test_support.dart' show source;
import 'template_create_test_support.dart';
void main() {
@@ -107,65 +105,4 @@ void main() {
findsOneWidget,
);
});
testWidgets('cupertino prompt uses native controls for the same flow', (
tester,
) async {
final gateway = FakeTemplateCreateGateway(
(type, fields) async => type == 'validate'
? {'graph': {}}
: {
'detail': {'id': 3},
},
);
final created = <JsonMap>[];
await tester.pumpWidget(
templateCreateApp(
TemplateCreateHost(
gateway: gateway,
onCreated: created.add,
cupertino: true,
),
cupertino: true,
),
);
await tester.tap(find.byKey(templateCreateOpenKey));
await tester.pumpAndSettle();
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
expect(find.byType(AlertDialog), findsNothing);
expect(find.byType(CupertinoTextField), findsOneWidget);
expect(find.text(templateCreateNameLabel), findsOneWidget);
expect(cupertinoTemplateName(tester), '');
expect(
tester
.widget<CupertinoDialogAction>(find.byKey(templateCreateConfirmKey))
.onPressed,
isNull,
);
await tester.enterText(find.byKey(templateCreateNameKey), ' Unicode 🚀 ');
await tester.pump();
await tester.tap(find.byKey(templateCreateConfirmKey));
await tester.pumpAndSettle();
expect(gateway.calls.map((call) => call.type), ['validate', 'submit']);
expect(gateway.calls[1].fields, {
'name': 'Unicode 🚀',
'source': source,
'create_only': true,
});
expect(
find.text('Created "Unicode 🚀". It is in the Pipelines list.'),
findsOneWidget,
);
expect(created.single, {'id': 3});
expect(
tester
.widget<CupertinoTextField>(find.byKey(templateCreateNameKey))
.enabled,
isFalse,
);
expect(find.text('Close'), findsOneWidget);
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
@@ -46,11 +45,6 @@ String materialTemplateName(WidgetTester tester) => tester
.controller!
.text;
String cupertinoTemplateName(WidgetTester tester) => tester
.widget<CupertinoTextField>(find.byKey(templateCreateNameKey))
.controller!
.text;
Future<JsonMap> acceptedTemplateCreate(String type, JsonMap fields) async {
if (type == 'validate') {
return {'graph': {}};
@@ -75,6 +69,8 @@ class TemplateCreateHost extends StatelessWidget {
final FakeTemplateCreateGateway gateway;
final ValueChanged<JsonMap> onCreated;
/// Retained for callers that still pass it; the host is always Material.
final bool cupertino;
final TemplateEntry template;
@@ -91,21 +87,12 @@ class TemplateCreateHost extends StatelessWidget {
@override
Widget build(BuildContext context) {
final body = Center(
child: cupertino
? CupertinoButton(
key: templateCreateOpenKey,
onPressed: () => _open(context),
child: const Text('Open'),
)
: FilledButton(
key: templateCreateOpenKey,
onPressed: () => _open(context),
child: const Text('Open'),
),
child: FilledButton(
key: templateCreateOpenKey,
onPressed: () => _open(context),
child: const Text('Open'),
),
);
if (cupertino) {
return CupertinoPageScaffold(child: body);
}
return Scaffold(body: body);
}
}
@@ -121,7 +108,5 @@ Widget templateCreateApp(
).copyWith(textScaler: TextScaler.linear(textScale)),
child: app!,
);
return cupertino
? CupertinoApp(builder: media, home: child)
: MaterialApp(builder: media, home: child);
return MaterialApp(builder: media, home: child);
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
@@ -76,30 +75,4 @@ void main() {
expect(gateway.callsOf('submit'), hasLength(1));
},
);
testWidgets('the callback is optional and Cupertino uses its native prompt', (
tester,
) async {
final gateway = GalleryGateway((type, fields) async {
if (type == 'list_templates') return templatesReply(galleryTemplates);
return acceptedCreate(type, fields);
});
await pumpGallery(tester, gateway, cupertino: true);
await openRelease(tester);
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
expect(find.byType(AlertDialog), findsNothing);
await tester.enterText(find.byKey(templateCreateNameKey), 'Cupertino');
await tester.pump();
await tester.tap(find.byKey(templateCreateConfirmKey));
await tester.pumpAndSettle();
expect(gateway.callsOf('validate'), hasLength(3));
expect(gateway.callsOf('submit'), hasLength(1));
expect(
find.text('Created "Created release". It is in the Pipelines list.'),
findsOneWidget,
);
expect(find.byKey(templateCreateCancelKey), findsOneWidget);
});
}
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
@@ -241,85 +240,54 @@ void main() {
expect(find.byKey(templatesGalleryKey), findsOneWidget);
});
testWidgets('Cupertino host uses its own list, back and detail controls', (
tester,
) async {
final gateway = GalleryGateway(
(type, fields) async => templatesReply(galleryTemplates),
);
await pumpGallery(tester, gateway, cupertino: true);
expect(find.byType(AppListRow), findsNWidgets(2));
expect(find.byType(CupertinoListTile), findsNothing);
expect(find.byType(Scaffold), findsNothing);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
expect(find.byKey(templateDetailKey), findsOneWidget);
expect(selectableSource(source), findsOneWidget);
expect(
tester
.widget<CupertinoButton>(find.byKey(templateCreateActionKey))
.onPressed,
isNotNull,
);
expect(find.byType(BackButton), findsNothing);
await tester.tap(find.byKey(templatesBackKey));
await tester.pumpAndSettle();
expect(find.byType(AppListRow), findsNWidgets(2));
});
testWidgets(
'a failed refresh with a template open is visible and retryable',
(tester) async {
for (final cupertino in [false, true]) {
var mode = 'ok';
final gateway = GalleryGateway((type, fields) async {
if (type != 'list_templates') throw StateError('unexpected $type');
if (mode == 'refuse') throw Exception('refresh unavailable');
return templatesReply(galleryTemplates);
});
var mode = 'ok';
final gateway = GalleryGateway((type, fields) async {
if (type != 'list_templates') throw StateError('unexpected $type');
if (mode == 'refuse') throw Exception('refresh unavailable');
return templatesReply(galleryTemplates);
});
await pumpGallery(tester, gateway, cupertino: cupertino);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
expect(find.byKey(templateDetailKey), findsOneWidget);
await pumpGallery(tester, gateway);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
expect(find.byKey(templateDetailKey), findsOneWidget);
mode = 'refuse';
await tester.tap(find.byKey(templatesRefreshKey));
await tester.pumpAndSettle();
mode = 'refuse';
await tester.tap(find.byKey(templatesRefreshKey));
await tester.pumpAndSettle();
expect(gateway.callsOf('list_templates'), hasLength(2));
expect(find.byKey(templateDetailKey), findsOneWidget);
expect(find.byKey(templatesErrorBannerKey), findsOneWidget);
expect(find.text('refresh unavailable'), findsOneWidget);
expect(find.byKey(templatesBannerRetryKey), findsOneWidget);
expect(find.byKey(templatesErrorKey), findsNothing);
expect(find.text(templateSourceLabel), findsOneWidget);
expect(find.text(templateCreateActionLabel), findsOneWidget);
expect(
tester.widget(find.byKey(templatesBannerRetryKey)),
cupertino ? isA<CupertinoButton>() : isA<TextButton>(),
);
expect(tester.takeException(), isNull);
expect(gateway.callsOf('list_templates'), hasLength(2));
expect(find.byKey(templateDetailKey), findsOneWidget);
expect(find.byKey(templatesErrorBannerKey), findsOneWidget);
expect(find.text('refresh unavailable'), findsOneWidget);
expect(find.byKey(templatesBannerRetryKey), findsOneWidget);
expect(find.byKey(templatesErrorKey), findsNothing);
expect(find.text(templateSourceLabel), findsOneWidget);
expect(find.text(templateCreateActionLabel), findsOneWidget);
expect(
tester.widget(find.byKey(templatesBannerRetryKey)),
isA<TextButton>(),
);
expect(tester.takeException(), isNull);
mode = 'ok';
await tester.tap(find.byKey(templatesBannerRetryKey));
await tester.pumpAndSettle();
mode = 'ok';
await tester.tap(find.byKey(templatesBannerRetryKey));
await tester.pumpAndSettle();
expect(find.text('refresh unavailable'), findsNothing);
expect(find.byKey(templatesErrorBannerKey), findsNothing);
expect(find.byKey(templateDetailKey), findsOneWidget);
expect(find.text(templateSourceLabel), findsOneWidget);
expect(gateway.callsOf('list_templates'), hasLength(3));
expect(find.text('refresh unavailable'), findsNothing);
expect(find.byKey(templatesErrorBannerKey), findsNothing);
expect(find.byKey(templateDetailKey), findsOneWidget);
expect(find.text(templateSourceLabel), findsOneWidget);
expect(gateway.callsOf('list_templates'), hasLength(3));
await tester.tap(find.byKey(templatesBackKey));
await tester.pumpAndSettle();
expect(find.byKey(templatesGalleryKey), findsOneWidget);
expect(find.text('Release workflow'), findsOneWidget);
expect(find.text('(unnamed template)'), findsOneWidget);
}
await tester.tap(find.byKey(templatesBackKey));
await tester.pumpAndSettle();
expect(find.byKey(templatesGalleryKey), findsOneWidget);
expect(find.text('Release workflow'), findsOneWidget);
expect(find.text('(unnamed template)'), findsOneWidget);
},
);
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
@@ -79,7 +78,7 @@ Future<JsonMap> acceptedCreate(String type, JsonMap fields) async {
throw StateError('Unexpected request $type');
}
/// Pumps the gallery in a real Material or Cupertino host without fixed sizes.
/// Pumps the gallery in a real Material host without fixed sizes.
Future<void> pumpGallery(
WidgetTester tester,
GalleryGateway gateway, {
@@ -105,16 +104,8 @@ Future<void> pumpGallery(
embedded: embedded,
onCreated: onCreated,
);
final home = embedded
? (cupertino
? CupertinoPageScaffold(child: screen)
: Scaffold(body: screen))
: screen;
await tester.pumpWidget(
cupertino
? CupertinoApp(builder: media, home: home)
: MaterialApp(builder: media, home: home),
);
final home = embedded ? Scaffold(body: screen) : screen;
await tester.pumpWidget(MaterialApp(builder: media, home: home));
if (settle) await tester.pumpAndSettle();
}
@@ -11,62 +11,52 @@ import 'template_gallery_test_support.dart';
/// Settings reading width, start-aligned; the bar names the open template and
/// the Create action is a compact button, not a full-width bar.
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('rows and detail are capped at 720 on a wide window', (
tester,
) async {
final gateway = GalleryGateway(
(type, fields) async => templatesReply(galleryTemplates),
);
await pumpGallery(tester, gateway, size: const Size(1200, 800));
testWidgets('$host: rows and detail are capped at 720 on a wide window', (
final row = tester.getRect(find.byKey(templateRowKey('release')));
expect(row.left, 0);
expect(row.width, templatesContentMaxWidth);
expect(find.text('Templates'), findsOneWidget);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
final bar = find.byType(SegmentedBar);
expect(
find.descendant(of: bar, matching: find.text('Release workflow')),
findsOneWidget,
);
expect(find.text('Templates'), findsNothing);
final create = tester.getRect(find.byKey(templateCreateActionKey));
expect(create.left, 16);
// Its own width, not stretched across the 688 content column.
expect(create.width, lessThan(templatesContentMaxWidth - 32));
final body = tester.getRect(selectableSource(source));
expect(body.right, lessThanOrEqualTo(templatesContentMaxWidth));
expect(tester.takeException(), isNull);
});
testWidgets('the detail fits 320 at 2x text', (tester) async {
final gateway = GalleryGateway(
(type, fields) async => templatesReply(galleryTemplates),
);
await pumpGallery(
tester,
) async {
final gateway = GalleryGateway(
(type, fields) async => templatesReply(galleryTemplates),
);
await pumpGallery(
tester,
gateway,
cupertino: cupertino,
size: const Size(1200, 800),
);
final row = tester.getRect(find.byKey(templateRowKey('release')));
expect(row.left, 0);
expect(row.width, templatesContentMaxWidth);
expect(find.text('Templates'), findsOneWidget);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
final bar = find.byType(SegmentedBar);
expect(
find.descendant(of: bar, matching: find.text('Release workflow')),
findsOneWidget,
);
expect(find.text('Templates'), findsNothing);
final create = tester.getRect(find.byKey(templateCreateActionKey));
expect(create.left, 16);
// Its own width, not stretched across the 688 content column.
expect(create.width, lessThan(templatesContentMaxWidth - 32));
final body = tester.getRect(selectableSource(source));
expect(body.right, lessThanOrEqualTo(templatesContentMaxWidth));
expect(tester.takeException(), isNull);
});
testWidgets('$host: the detail fits 320 at 2x text', (tester) async {
final gateway = GalleryGateway(
(type, fields) async => templatesReply(galleryTemplates),
);
await pumpGallery(
tester,
gateway,
cupertino: cupertino,
size: const Size(320, 800),
textScale: 2,
);
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
expect(find.byKey(templateCreateActionKey), findsOneWidget);
expect(tester.takeException(), isNull);
});
}
gateway,
size: const Size(320, 800),
textScale: 2,
);
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
expect(find.byKey(templateCreateActionKey), findsOneWidget);
expect(tester.takeException(), isNull);
});
}