Merge commit 'baac6eca9a07c3645e57b3515dcf64bf6a49ae4e' into pipelines/run-20261111-0115-cupertino-out-ui-motion-navigation-input-6491

This commit is contained in:
2026-11-11 03:23:07 +00:00
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,
@@ -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);
});
}