Merge commit 'baac6eca9a07c3645e57b3515dcf64bf6a49ae4e' into pipelines/run-20261111-0115-cupertino-out-ui-motion-navigation-input-6491
This commit is contained in:
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/api_gateway.dart';
|
||||
import '../../shell/shell_bar.dart';
|
||||
import '../../ui/adaptive/host.dart';
|
||||
import '../../ui/adaptive/top_bar_notices.dart';
|
||||
import 'data/template_repository.dart';
|
||||
import 'domain/template_entry.dart';
|
||||
@@ -170,7 +169,7 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
|
||||
context: context,
|
||||
template: template,
|
||||
repository: _repository,
|
||||
cupertino: usesCupertinoHost(context),
|
||||
cupertino: false,
|
||||
onCreated: (detail) => widget.onCreated?.call(detail),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'template_create_wording.dart';
|
||||
@@ -13,6 +12,8 @@ class TemplateCreateNameField extends StatelessWidget {
|
||||
required this.onSubmit,
|
||||
});
|
||||
|
||||
/// Retained for callers that still pass it; the field is always the
|
||||
/// Material one whether this is set or not.
|
||||
final bool cupertino;
|
||||
final TextEditingController controller;
|
||||
final bool enabled;
|
||||
@@ -26,24 +27,14 @@ class TemplateCreateNameField extends StatelessWidget {
|
||||
children: [
|
||||
const Text(templateCreateNameLabel),
|
||||
const SizedBox(height: 8),
|
||||
if (cupertino)
|
||||
CupertinoTextField(
|
||||
key: templateCreateNameKey,
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
autofocus: true,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => onSubmit(),
|
||||
)
|
||||
else
|
||||
TextField(
|
||||
key: templateCreateNameKey,
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
autofocus: true,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => onSubmit(),
|
||||
),
|
||||
TextField(
|
||||
key: templateCreateNameKey,
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
autofocus: true,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => onSubmit(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -56,14 +47,6 @@ Widget templateCreateDialogAction({
|
||||
required Widget child,
|
||||
bool primary = false,
|
||||
}) {
|
||||
if (cupertino) {
|
||||
return CupertinoDialogAction(
|
||||
key: key,
|
||||
isDefaultAction: primary,
|
||||
onPressed: onPressed,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
if (primary) {
|
||||
return FilledButton(key: key, onPressed: onPressed, child: child);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
@@ -12,6 +11,9 @@ import 'template_create_controls.dart';
|
||||
/// Cancel send nothing; Create validates the source first and only a passing
|
||||
/// validate submits it create-only. A refusal keeps the typed name; an accepted
|
||||
/// `detail` is delivered through [onCreated] once.
|
||||
///
|
||||
/// [cupertino] is retained for callers that still pass it; the prompt is
|
||||
/// always the Material dialog.
|
||||
Future<void> showTemplateCreateDialog({
|
||||
required BuildContext context,
|
||||
required TemplateEntry template,
|
||||
@@ -22,33 +24,24 @@ Future<void> showTemplateCreateDialog({
|
||||
final dialog = _TemplateCreateDialog(
|
||||
template: template,
|
||||
repository: repository,
|
||||
cupertino: cupertino,
|
||||
onCreated: onCreated,
|
||||
);
|
||||
return cupertino
|
||||
? showCupertinoDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => dialog,
|
||||
)
|
||||
: showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => dialog,
|
||||
);
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => dialog,
|
||||
);
|
||||
}
|
||||
|
||||
class _TemplateCreateDialog extends StatefulWidget {
|
||||
const _TemplateCreateDialog({
|
||||
required this.template,
|
||||
required this.repository,
|
||||
required this.cupertino,
|
||||
required this.onCreated,
|
||||
});
|
||||
|
||||
final TemplateEntry template;
|
||||
final TemplateRepository repository;
|
||||
final bool cupertino;
|
||||
final ValueChanged<JsonMap> onCreated;
|
||||
|
||||
@override
|
||||
@@ -150,15 +143,13 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = widget.cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error;
|
||||
final color = Theme.of(context).colorScheme.error;
|
||||
final content = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
TemplateCreateNameField(
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
controller: _name,
|
||||
enabled: _fieldEnabled,
|
||||
onSubmit: _create,
|
||||
@@ -196,7 +187,7 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
||||
);
|
||||
final actions = [
|
||||
templateCreateDialogAction(
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
key: templateCreateCancelKey,
|
||||
onPressed: _sending ? null : _cancel,
|
||||
child: Text(
|
||||
@@ -206,7 +197,7 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
||||
),
|
||||
),
|
||||
templateCreateDialogAction(
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
key: templateCreateConfirmKey,
|
||||
primary: true,
|
||||
onPressed: _canSubmit ? _create : null,
|
||||
@@ -216,20 +207,10 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
||||
),
|
||||
];
|
||||
final title = Text(templateCreateTitle(widget.template));
|
||||
if (!widget.cupertino) {
|
||||
return PopScope(
|
||||
canPop: !_sending,
|
||||
child: AlertDialog(
|
||||
scrollable: true,
|
||||
title: title,
|
||||
content: content,
|
||||
actions: actions,
|
||||
),
|
||||
);
|
||||
}
|
||||
return PopScope(
|
||||
canPop: !_sending,
|
||||
child: CupertinoAlertDialog(
|
||||
child: AlertDialog(
|
||||
scrollable: true,
|
||||
title: title,
|
||||
content: content,
|
||||
actions: actions,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../domain/template_entry.dart';
|
||||
import 'template_gallery.dart' show templatesColumn;
|
||||
@@ -63,14 +61,13 @@ class TemplateDetail extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final muted = templateMutedStyle(context);
|
||||
final description = entry.description.trim();
|
||||
return ListView(
|
||||
key: templateDetailKey,
|
||||
padding: withBarClearance(context, const EdgeInsets.only(bottom: 24)),
|
||||
children: [
|
||||
if (showBack) _backRow(context, cupertino),
|
||||
if (showBack) _backRow(context),
|
||||
templatesColumn(
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
@@ -91,7 +88,7 @@ class TemplateDetail extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
_createButton(cupertino),
|
||||
_createButton(),
|
||||
const SizedBox(height: 16),
|
||||
// The key and the schedule on one quiet line, not a
|
||||
// label/value document.
|
||||
@@ -136,15 +133,7 @@ class TemplateDetail extends StatelessWidget {
|
||||
|
||||
/// A compact button at its own width: the page's one action, never a bar
|
||||
/// spanning a wide window.
|
||||
Widget _createButton(bool cupertino) {
|
||||
if (cupertino) {
|
||||
return CupertinoButton.filled(
|
||||
key: templateCreateActionKey,
|
||||
sizeStyle: CupertinoButtonSize.medium,
|
||||
onPressed: onCreate,
|
||||
child: const Text(templateCreateActionLabel),
|
||||
);
|
||||
}
|
||||
Widget _createButton() {
|
||||
return FilledButton.icon(
|
||||
key: templateCreateActionKey,
|
||||
onPressed: onCreate,
|
||||
@@ -153,13 +142,13 @@ class TemplateDetail extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _backRow(BuildContext context, bool cupertino) {
|
||||
Widget _backRow(BuildContext context) {
|
||||
// Only without a bar above: the same round Back the bar would show.
|
||||
final back = SegmentedPill(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
child: SegmentedBackButton(
|
||||
key: templateDetailBackKey,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onPressed: onBack,
|
||||
),
|
||||
);
|
||||
@@ -179,35 +168,15 @@ class TemplateDetail extends StatelessWidget {
|
||||
}
|
||||
|
||||
TextStyle? templateTitleStyle(BuildContext context) =>
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).textTheme.navLargeTitleTextStyle
|
||||
: Theme.of(context).textTheme.headlineSmall;
|
||||
Theme.of(context).textTheme.headlineSmall;
|
||||
|
||||
TextStyle? templateSectionStyle(BuildContext context) =>
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
|
||||
: Theme.of(context).textTheme.titleMedium;
|
||||
Theme.of(context).textTheme.titleMedium;
|
||||
|
||||
TextStyle? templateBodyStyle(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
// SelectableText needs an explicit baseline when it inherits no style.
|
||||
return CupertinoTheme.of(
|
||||
context,
|
||||
).textTheme.textStyle.copyWith(inherit: true);
|
||||
}
|
||||
return Theme.of(context).textTheme.bodyMedium;
|
||||
}
|
||||
TextStyle? templateBodyStyle(BuildContext context) =>
|
||||
Theme.of(context).textTheme.bodyMedium;
|
||||
|
||||
TextStyle? templateMutedStyle(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
// The list rows' secondary size, not the tab bar's 10pt caption.
|
||||
// SelectableText needs an explicit baseline when it inherits no style.
|
||||
return CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
inherit: true,
|
||||
fontSize: 15,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
return theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/layout/app_list_avatar.dart';
|
||||
import '../../../ui/layout/app_list_row.dart';
|
||||
import '../domain/template_entry.dart';
|
||||
@@ -70,13 +68,13 @@ class TemplateGallery extends StatelessWidget {
|
||||
onRetry: onRetry,
|
||||
);
|
||||
}
|
||||
return _loadingState(context);
|
||||
return _loadingState();
|
||||
}
|
||||
if (templates.isEmpty) return _emptyState(context);
|
||||
return _list(context);
|
||||
}
|
||||
|
||||
Widget _loadingState(BuildContext context) {
|
||||
Widget _loadingState() {
|
||||
return Center(
|
||||
key: templatesLoadingKey,
|
||||
child: Semantics(
|
||||
@@ -85,9 +83,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
usesCupertinoHost(context)
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 12),
|
||||
const Text(_loadingMessage),
|
||||
],
|
||||
@@ -107,7 +103,6 @@ class TemplateGallery extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _list(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
// The rows scroll behind the bar and the floating tab bar.
|
||||
return ListView.builder(
|
||||
key: templatesGalleryKey,
|
||||
@@ -118,14 +113,14 @@ class TemplateGallery extends StatelessWidget {
|
||||
return templatesColumn(
|
||||
AppListRow(
|
||||
key: templateRowKey(entry.key),
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
divider: index < templates.length - 1,
|
||||
onTap: () => onOpen(entry.key),
|
||||
leading: ExcludeSemantics(
|
||||
child: AppListAvatar.initial(
|
||||
templateDetailName(entry),
|
||||
key: templateAvatarKey(entry.key),
|
||||
color: _avatarColor(context, entry.key, cupertino),
|
||||
color: _avatarColor(context, entry.key),
|
||||
),
|
||||
),
|
||||
title: Text(templateGalleryName(entry)),
|
||||
@@ -138,18 +133,9 @@ class TemplateGallery extends StatelessWidget {
|
||||
|
||||
/// One of the theme's accents, picked by the template key so a row keeps
|
||||
/// its colour across reloads (the Pipelines list's palette).
|
||||
Color _avatarColor(BuildContext context, String key, bool cupertino) {
|
||||
final List<Color> colors;
|
||||
if (cupertino) {
|
||||
colors = [
|
||||
CupertinoTheme.of(context).primaryColor,
|
||||
CupertinoColors.systemIndigo.resolveFrom(context),
|
||||
CupertinoColors.systemTeal.resolveFrom(context),
|
||||
];
|
||||
} else {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
colors = [scheme.primary, scheme.secondary, scheme.tertiary];
|
||||
}
|
||||
Color _avatarColor(BuildContext context, String key) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final colors = [scheme.primary, scheme.secondary, scheme.tertiary];
|
||||
final hash = key.codeUnits.fold<int>(0, (sum, unit) => sum + unit);
|
||||
return colors[hash % colors.length];
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
const templatesErrorKey = ValueKey<String>('templates-error');
|
||||
const templatesRetryKey = ValueKey<String>('templates-retry');
|
||||
const templatesErrorBannerKey = ValueKey<String>('templates-error-banner');
|
||||
@@ -36,7 +33,6 @@ class TemplatesFailureState extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_retryButton(
|
||||
context,
|
||||
buttonKey: templatesRetryKey,
|
||||
retrying: retrying,
|
||||
onRetry: onRetry,
|
||||
@@ -76,15 +72,10 @@ class TemplatesFailureBanner extends StatelessWidget {
|
||||
liveRegion: true,
|
||||
child: Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
color: usesCupertinoHost(context)
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
),
|
||||
_retryButton(
|
||||
context,
|
||||
buttonKey: templatesBannerRetryKey,
|
||||
retrying: retrying,
|
||||
onRetry: onRetry,
|
||||
@@ -95,21 +86,12 @@ class TemplatesFailureBanner extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _retryButton(
|
||||
BuildContext context, {
|
||||
Widget _retryButton({
|
||||
required Key buttonKey,
|
||||
required bool retrying,
|
||||
required VoidCallback onRetry,
|
||||
}) {
|
||||
final onPressed = retrying ? null : onRetry;
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoButton(
|
||||
key: buttonKey,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: const Text('Retry'),
|
||||
);
|
||||
}
|
||||
return TextButton(
|
||||
key: buttonKey,
|
||||
onPressed: onPressed,
|
||||
|
||||
@@ -2,10 +2,8 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../shell/shell_bar.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/navigation/bar_icon_button.dart';
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
|
||||
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
||||
const templatesBackKey = ValueKey<String>('templates-back');
|
||||
@@ -44,7 +42,6 @@ class TemplatesFrame extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
if (embedded) {
|
||||
if (ShellBar.available(context)) {
|
||||
return ShellBar(
|
||||
@@ -70,11 +67,11 @@ class TemplatesFrame extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
leading: canGoBack
|
||||
? SegmentedBackButton(
|
||||
key: templatesBackKey,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onPressed: onBack,
|
||||
)
|
||||
: null,
|
||||
@@ -84,19 +81,12 @@ class TemplatesFrame extends StatelessWidget {
|
||||
);
|
||||
// The body reaches the top edge and scrolls behind the bar.
|
||||
final page = SafeArea(top: false, bottom: false, child: body);
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
// Plain list rows on the page background, like the other lists.
|
||||
backgroundColor: AppColors.background,
|
||||
navigationBar: bar,
|
||||
child: page,
|
||||
);
|
||||
}
|
||||
return Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: page);
|
||||
}
|
||||
|
||||
Widget _refreshButton() => BarIconButton(
|
||||
key: templatesRefreshKey,
|
||||
cupertino: false,
|
||||
icon: Icons.refresh,
|
||||
cupertinoIcon: CupertinoIcons.refresh,
|
||||
label: 'Refresh',
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user