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
@@ -1,10 +1,9 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/templates_destination.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/templates/screen.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../features/pipelines/fixtures.dart';
@@ -13,81 +12,55 @@ import 'templates_wiring_test.dart' show openSettings, openTemplates, pumpApp;
/// The app-level Templates page: one bar (Back + Refresh), the gallery and an
/// open template reach the top edge, start below the bar at rest and scroll
/// behind it. Both hosts draw the shared list rows on the page background.
/// behind it. The shared list rows sit on the page background.
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host: the gallery and detail scroll behind the bar', (
testWidgets('the gallery and detail scroll behind the bar', (tester) async {
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(channelFactory: (_) => channel);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
);
addTearDown(provider.dispose);
await pumpApp(
tester,
) async {
final channel = FakeChannel()..readyCompleter.complete();
final client = PipelinesClient(channelFactory: (_) => channel);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
);
addTearDown(provider.dispose);
await pumpApp(
tester,
channel: channel,
client: client,
provider: provider,
cupertino: cupertino,
);
await replyPipelines(tester, channel, PipelineFixture());
await openSettings(tester, channel, provider);
await openTemplates(tester, channel, provider);
await tester.pumpAndSettle();
channel: channel,
client: client,
provider: provider,
cupertino: false,
);
await replyPipelines(tester, channel, PipelineFixture());
await openSettings(tester, channel, provider);
await openTemplates(tester, channel, provider);
await tester.pumpAndSettle();
final bar = find.ancestor(
of: find.byKey(templatesPageBackKey),
matching: find.byType(SegmentedBar),
);
final barBottom = tester.getRect(bar).bottom;
// One bar: Back and Refresh are its pieces.
expect(
find.descendant(of: bar, matching: find.byKey(templatesRefreshKey)),
findsOneWidget,
);
final bar = find.ancestor(
of: find.byKey(templatesPageBackKey),
matching: find.byType(SegmentedBar),
);
final barBottom = tester.getRect(bar).bottom;
// One bar: Back and Refresh are its pieces.
expect(
find.descendant(of: bar, matching: find.byKey(templatesRefreshKey)),
findsOneWidget,
);
final gallery = find.byKey(templatesGalleryKey);
expect(tester.getTopLeft(gallery).dy, 0);
final row = find.byKey(templateRowKey('release'));
expect(tester.getTopLeft(row).dy, greaterThanOrEqualTo(barBottom - 8));
// Scrolling moves the row up behind the bar.
final before = tester.getTopLeft(row).dy;
await tester.drag(gallery, const Offset(0, -40));
await tester.pump();
expect(tester.getTopLeft(row).dy, lessThanOrEqualTo(before));
final gallery = find.byKey(templatesGalleryKey);
expect(tester.getTopLeft(gallery).dy, 0);
final row = find.byKey(templateRowKey('release'));
expect(tester.getTopLeft(row).dy, greaterThanOrEqualTo(barBottom - 8));
// Scrolling moves the row up behind the bar.
final before = tester.getTopLeft(row).dy;
await tester.drag(gallery, const Offset(0, -40));
await tester.pump();
expect(tester.getTopLeft(row).dy, lessThanOrEqualTo(before));
if (cupertino) {
final scaffold = tester.widget<CupertinoPageScaffold>(
find
.ancestor(
of: gallery,
matching: find.byType(CupertinoPageScaffold),
)
.first,
);
// Plain shared rows on the page background, like the other lists.
expect(scaffold.backgroundColor, AppColors.background);
expect(
find.descendant(
of: gallery,
matching: find.byType(CupertinoListSection),
),
findsNothing,
);
}
await tester.tap(row);
await tester.pumpAndSettle();
final detail = find.byKey(templateDetailKey);
expect(tester.getTopLeft(detail).dy, 0);
expect(
tester.getTopLeft(find.byKey(templateCreateActionKey)).dy,
greaterThanOrEqualTo(barBottom - 8),
);
});
}
await tester.tap(row);
await tester.pumpAndSettle();
final detail = find.byKey(templateDetailKey);
expect(tester.getTopLeft(detail).dy, 0);
expect(
tester.getTopLeft(find.byKey(templateCreateActionKey)).dy,
greaterThanOrEqualTo(barBottom - 8),
);
});
}
+92 -104
View File
@@ -73,16 +73,12 @@ Future<void> pumpApp(
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
if (cupertino) {
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark;
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
}
SharedPreferences.setMockInitialValues({});
await tester.pumpWidget(
PipelinesApp(
server: webServer(),
client: client,
cupertino: cupertino,
cupertino: false,
routeInformationProvider: provider,
),
);
@@ -156,114 +152,106 @@ void main() {
expect(gateway.callsOf('list_templates'), hasLength(1));
});
for (final cupertino in [false, true]) {
testWidgets(
'Settings opens the embedded Templates page and Back restores it '
'($cupertino)',
(tester) async {
final fixture = PipelineFixture();
final channel = FakeChannel()..readyCompleter.complete();
var sockets = 0;
final client = PipelinesClient(
channelFactory: (_) {
sockets++;
return channel;
},
);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(
uri: Uri.parse('/pipelines'),
),
);
addTearDown(provider.dispose);
testWidgets(
'Settings opens the embedded Templates page and Back restores it',
(tester) async {
final fixture = PipelineFixture();
final channel = FakeChannel()..readyCompleter.complete();
var sockets = 0;
final client = PipelinesClient(
channelFactory: (_) {
sockets++;
return channel;
},
);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
);
addTearDown(provider.dispose);
await pumpApp(
tester,
channel: channel,
client: client,
provider: provider,
cupertino: cupertino,
);
await replyPipelines(tester, channel, fixture);
await pumpApp(
tester,
channel: channel,
client: client,
provider: provider,
cupertino: false,
);
await replyPipelines(tester, channel, fixture);
await openSettings(tester, channel, provider);
// An edit that only Settings owns must survive the Templates detour.
await tester.enterText(find.byType(EditableText).first, 'edited url');
await tester.pump();
expect(find.text('edited url'), findsOneWidget);
await openSettings(tester, channel, provider);
// An edit that only Settings owns must survive the Templates detour.
await tester.enterText(find.byType(EditableText).first, 'edited url');
await tester.pump();
expect(find.text('edited url'), findsOneWidget);
await openTemplates(tester, channel, provider);
final screen = tester.widget<TemplatesScreen>(
find.byType(TemplatesScreen),
);
expect(screen.embedded, isTrue);
expect(find.text('Release workflow'), findsOneWidget);
// One visible navigation bar: the Templates page owns it, the shell is
// preserved underneath.
expect(find.byType(SegmentedBar), findsOneWidget);
if (cupertino) {
expect(find.byType(Material), findsNothing);
}
expect(sockets, 1);
expect(requestsOf(channel, 'list_templates'), hasLength(1));
await openTemplates(tester, channel, provider);
final screen = tester.widget<TemplatesScreen>(
find.byType(TemplatesScreen),
);
expect(screen.embedded, isTrue);
expect(find.text('Release workflow'), findsOneWidget);
// One visible navigation bar: the Templates page owns it, the shell is
// preserved underneath.
expect(find.byType(SegmentedBar), findsOneWidget);
expect(sockets, 1);
expect(requestsOf(channel, 'list_templates'), hasLength(1));
// Refresh sits in the bar's actions pill, not in the body.
Finder inBar(Key key) => find.descendant(
of: find.byType(SegmentedBar),
matching: find.byKey(key),
);
expect(inBar(templatesRefreshKey), findsOneWidget);
expect(find.byKey(templatesRefreshKey), findsOneWidget);
expect(inBar(templatesPageBackKey), findsOneWidget);
// Refresh sits in the bar's actions pill, not in the body.
Finder inBar(Key key) => find.descendant(
of: find.byType(SegmentedBar),
matching: find.byKey(key),
);
expect(inBar(templatesRefreshKey), findsOneWidget);
expect(find.byKey(templatesRefreshKey), findsOneWidget);
expect(inBar(templatesPageBackKey), findsOneWidget);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pump();
await tester.pump();
expect(find.text('Definition source'), findsOneWidget);
// One Back at a time, in the bar's round leading piece: the open
// template's Back replaces the page's.
expect(inBar(templateDetailBackKey), findsOneWidget);
expect(find.byKey(templateDetailBackKey), findsOneWidget);
expect(find.byKey(templatesPageBackKey), findsNothing);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pump();
await tester.pump();
expect(find.text('Definition source'), findsOneWidget);
// One Back at a time, in the bar's round leading piece: the open
// template's Back replaces the page's.
expect(inBar(templateDetailBackKey), findsOneWidget);
expect(find.byKey(templateDetailBackKey), findsOneWidget);
expect(find.byKey(templatesPageBackKey), findsNothing);
// Detail Back returns to the gallery, then the page Back restores the
// same Settings state.
await tester.tap(find.byKey(templateDetailBackKey));
await tester.pump();
// The gallery hands the bar back to the page's Back on the next frame.
await tester.pump();
await tester.tap(find.byKey(templatesPageBackKey));
await tester.pumpAndSettle();
// Detail Back returns to the gallery, then the page Back restores the
// same Settings state.
await tester.tap(find.byKey(templateDetailBackKey));
await tester.pump();
// The gallery hands the bar back to the page's Back on the next frame.
await tester.pump();
await tester.tap(find.byKey(templatesPageBackKey));
await tester.pumpAndSettle();
expect(provider.value.uri.path, '/settings');
expect(find.byType(TemplatesScreen), findsNothing);
expect(find.byKey(SettingsKeys.templates), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('edited url'), findsOneWidget);
expect(find.text('Server URL'), findsOneWidget);
expect(sockets, 1);
expect(requestsOf(channel, 'ping'), hasLength(1));
expect(provider.value.uri.path, '/settings');
expect(find.byType(TemplatesScreen), findsNothing);
expect(find.byKey(SettingsKeys.templates), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('edited url'), findsOneWidget);
expect(find.text('Server URL'), findsOneWidget);
expect(sockets, 1);
expect(requestsOf(channel, 'ping'), hasLength(1));
// Browser Back from /templates follows the same close path.
await openTemplates(tester, channel, provider, listRead: 2);
expect(find.byType(TemplatesScreen), findsOneWidget);
await provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse('/settings')),
);
await tester.pumpAndSettle();
expect(provider.value.uri.path, '/settings');
expect(find.byType(TemplatesScreen), findsNothing);
expect(find.byKey(SettingsKeys.templates), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('edited url'), findsOneWidget);
expect(requestsOf(channel, 'list_templates'), hasLength(2));
expect(sockets, 1);
// Browser Back from /templates follows the same close path.
await openTemplates(tester, channel, provider, listRead: 2);
expect(find.byType(TemplatesScreen), findsOneWidget);
await provider.didPushRouteInformation(
RouteInformation(uri: Uri.parse('/settings')),
);
await tester.pumpAndSettle();
expect(provider.value.uri.path, '/settings');
expect(find.byType(TemplatesScreen), findsNothing);
expect(find.byKey(SettingsKeys.templates), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('edited url'), findsOneWidget);
expect(requestsOf(channel, 'list_templates'), hasLength(2));
expect(sockets, 1);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
},
);
}
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
},
);
testWidgets('an accepted create re-reads Pipelines exactly once', (
tester,