Remove Cupertino pipeline branches

Keep the pipeline feature on its existing Material path because the app runs under MaterialApp and never selects Cupertino hosts. Preserve public cupertino parameters and required Cupertino icon values for later cleanup and shared controls.
This commit is contained in:
2026-11-11 04:53:12 +00:00
parent 03915fbb35
commit d1b05217c9
31 changed files with 557 additions and 1469 deletions
@@ -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/application/pipelines_app.dart';
@@ -12,83 +11,66 @@ import 'pipelines_replies.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
void main() {
for (final cupertino in [false, true]) {
testWidgets(
'the /pipelines route renders real rows, detail and source ($cupertino)',
(tester) async {
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
if (cupertino) {
tester.platformDispatcher.platformBrightnessTestValue =
Brightness.dark;
addTearDown(
tester.platformDispatcher.clearPlatformBrightnessTestValue,
);
}
testWidgets('the /pipelines route renders real rows, detail and source', (
tester,
) async {
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
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 tester.pumpWidget(
PipelinesApp(
server: webServer(),
client: client,
cupertino: cupertino,
routeInformationProvider: provider,
),
);
await tester.pump();
await replyPipelines(tester, channel, fixture);
await tester.pump();
expect(find.text('Alpha review'), findsOneWidget);
expect(find.text('2 stages · 1 schedule'), findsOneWidget);
expect(find.text('Pipelines — Not implemented'), findsNothing);
expect(sockets, 1);
// The shell owns the only navigation bar; the embedded screen adds no
// second bar.
expect(find.byType(SegmentedBar), findsOneWidget);
if (cupertino) {
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
expect(find.byType(Material), findsNothing);
} else {
expect(find.byType(Scaffold), findsOneWidget);
}
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pump();
await replyPipelineDetail(tester, channel, fixture);
await tester.pump();
expect(find.text('hash-alpha'), findsOneWidget);
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pump();
expect(
selectableText(
'name: Alpha review\nstages:\n review:\n type: model',
),
findsOneWidget,
);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
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 tester.pumpWidget(
PipelinesApp(
server: webServer(),
client: client,
cupertino: false,
routeInformationProvider: provider,
),
);
await tester.pump();
await replyPipelines(tester, channel, fixture);
await tester.pump();
expect(find.text('Alpha review'), findsOneWidget);
expect(find.text('2 stages · 1 schedule'), findsOneWidget);
expect(find.text('Pipelines — Not implemented'), findsNothing);
expect(sockets, 1);
// The shell owns the only navigation bar; the embedded screen adds no
// second bar.
expect(find.byType(SegmentedBar), findsOneWidget);
expect(find.byType(Scaffold), findsOneWidget);
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pump();
await replyPipelineDetail(tester, channel, fixture);
await tester.pump();
expect(find.text('hash-alpha'), findsOneWidget);
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pump();
expect(
selectableText(
'name: Alpha review\nstages:\n review:\n type: model',
),
findsOneWidget,
);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
+59 -66
View File
@@ -1,5 +1,4 @@
import '../features/settings/settings_topic_test_helper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/pipelines_app.dart';
@@ -20,7 +19,6 @@ import 'pipelines_replies.dart';
void main() {
Future<PlatformRouteInformationProvider> pumpApp(
WidgetTester tester, {
required bool cupertino,
required String location,
required Size size,
}) async {
@@ -37,7 +35,7 @@ void main() {
PipelinesApp(
server: webServer(),
client: PipelinesClient(channelFactory: (_) => channel),
cupertino: cupertino,
cupertino: false,
routeInformationProvider: provider,
),
);
@@ -52,82 +50,77 @@ void main() {
.widget<FloatingDestinationBar>(find.byType(FloatingDestinationBar))
.currentIndex;
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final size in [const Size(390, 844), const Size(1200, 800)]) {
testWidgets('$host ${size.width}: the Pipelines bar gear opens Settings '
'as a page and Back returns', (tester) async {
final provider = await pumpApp(
tester,
cupertino: cupertino,
location: '/pipelines',
size: size,
);
// Four tabs; Settings is none of them.
expect(
tester
.widget<FloatingDestinationBar>(
find.byType(FloatingDestinationBar),
)
.items
.map((item) => item.label),
['Pipelines', 'Runs', 'Chat', 'Search'],
);
expect(
find.byKey(const ValueKey('shell.destination.settings')),
findsNothing,
);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.text('Quick switch animation'), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('Server URL'), findsOneWidget);
// A page of Pipelines: Back in its bar, Pipelines still selected.
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
expect(selectedTab(tester), 0);
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/pipelines');
expect(find.byKey(const Key('pipelines-open-settings')), findsWidgets);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
testWidgets('$host: the /settings deep link opens the Settings page and '
'the system Back closes it to Pipelines', (tester) async {
for (final size in [const Size(390, 844), const Size(1200, 800)]) {
testWidgets('${size.width}: the Pipelines bar gear opens Settings '
'as a page and Back returns', (tester) async {
final provider = await pumpApp(
tester,
cupertino: cupertino,
location: '/settings',
size: const Size(390, 844),
location: '/pipelines',
size: size,
);
// Four tabs; Settings is none of them.
expect(
tester
.widget<FloatingDestinationBar>(
find.byType(FloatingDestinationBar),
)
.items
.map((item) => item.label),
['Pipelines', 'Runs', 'Chat', 'Search'],
);
expect(
find.byKey(const ValueKey('shell.destination.settings')),
findsNothing,
);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.text('Quick switch animation'), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('Server URL'), findsOneWidget);
// A page of Pipelines: Back in its bar, Pipelines still selected.
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
expect(selectedTab(tester), 0);
expect(tester.takeException(), isNull);
final handled = await tester.binding.handlePopRoute();
expect(handled, isTrue, reason: 'Back closes the page, not the app');
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/pipelines');
expect(find.byKey(const Key('pipelines-open-settings')), findsWidgets);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
testWidgets('the /settings deep link opens the Settings page and '
'the system Back closes it to Pipelines', (tester) async {
final provider = await pumpApp(
tester,
location: '/settings',
size: const Size(390, 844),
);
await tester.pump();
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
expect(selectedTab(tester), 0);
final handled = await tester.binding.handlePopRoute();
expect(handled, isTrue, reason: 'Back closes the page, not the app');
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/pipelines');
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
@@ -1,7 +1,6 @@
import '../features/settings/settings_topic_test_helper.dart';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/pipelines_app.dart';
@@ -16,89 +15,73 @@ import 'pipelines_replies.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
void main() {
for (final cupertino in [false, true]) {
testWidgets('Settings shares socket and one native bar ($cupertino)', (
tester,
) async {
SharedPreferences.setMockInitialValues({});
if (cupertino) {
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark;
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
}
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 tester.pumpWidget(
PipelinesApp(
server: webServer(),
client: client,
cupertino: cupertino,
routeInformationProvider: provider,
),
);
await tester.pump();
expect(
requestOf(channel, 'ping'),
isNull,
reason: 'Unvisited settings must not issue hidden requests',
);
await replyPipelines(tester, channel, PipelineFixture());
testWidgets('Settings shares socket and one native bar', (tester) async {
SharedPreferences.setMockInitialValues({});
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 tester.pumpWidget(
PipelinesApp(
server: webServer(),
client: client,
cupertino: false,
routeInformationProvider: provider,
),
);
await tester.pump();
expect(
requestOf(channel, 'ping'),
isNull,
reason: 'Unvisited settings must not issue hidden requests',
);
await replyPipelines(tester, channel, PipelineFixture());
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
expect(find.text('Quick switch animation'), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('Server URL'), findsOneWidget);
if (cupertino) {
final title = tester.widget<Text>(find.text('Connection').last);
expect(
title.style!.color!.computeLuminance(),
greaterThan(0.5),
reason: 'Cupertino dark host must not inherit light Material text',
);
}
expect(find.text('Settings — Not implemented'), findsNothing);
expect(sockets, 1);
expect(find.byType(SegmentedBar), findsOneWidget);
final ping = requestOf(channel, 'ping')!;
channel.incoming.add(
jsonEncode({
'id': ping['id'],
'type': 'pong',
'build': {'version': 'settings-fixture'},
'time': 'fixture time',
'protocol': 2,
}),
);
await tester.pump();
await tester.pump();
expect(find.textContaining('settings-fixture'), findsOneWidget);
expect(
find.text(
'Protocol mismatch: this page speaks protocol 1, '
'the server reports 2.',
),
findsOneWidget,
reason: 'a mismatched server must stay visibly flagged in Settings',
);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
expect(find.text('Quick switch animation'), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('Server URL'), findsOneWidget);
expect(find.text('Settings — Not implemented'), findsNothing);
expect(sockets, 1);
expect(find.byType(SegmentedBar), findsOneWidget);
final ping = requestOf(channel, 'ping')!;
channel.incoming.add(
jsonEncode({
'id': ping['id'],
'type': 'pong',
'build': {'version': 'settings-fixture'},
'time': 'fixture time',
'protocol': 2,
}),
);
await tester.pump();
await tester.pump();
expect(find.textContaining('settings-fixture'), findsOneWidget);
expect(
find.text(
'Protocol mismatch: this page speaks protocol 1, '
'the server reports 2.',
),
findsOneWidget,
reason: 'a mismatched server must stay visibly flagged in Settings',
);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
@@ -22,7 +22,6 @@ Future<({PlatformRouteInformationProvider provider, FakeChannel channel})>
mount(
WidgetTester tester, {
String route = '/pipelines',
bool cupertino = false,
TabLocationsStore? store,
}) async {
tester.view.physicalSize = const Size(560, 1000);
@@ -39,7 +38,7 @@ mount(
PipelinesApp(
server: webServer(),
client: client,
cupertino: cupertino,
cupertino: false,
serverId: 'navigation-test',
routeInformationProvider: provider,
tabLocationsStore: store,
@@ -58,44 +57,41 @@ Future<void> tab(WidgetTester tester, String name) async {
void main() {
setUp(() => SharedPreferences.setMockInitialValues({}));
for (final cupertino in [false, true]) {
testWidgets(
'Settings is retained inside Pipelines across tab switches ($cupertino)',
(tester) async {
final app = await mount(tester, cupertino: cupertino);
await replyPipelines(tester, app.channel, PipelineFixture());
await tester.pumpAndSettle();
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pumpAndSettle();
expect(app.provider.value.uri.path, '/settings');
final settingsState = tester.state(find.byType(SettingsScreen));
await tab(tester, 'chat');
expect(app.provider.value.uri.path, '/chat');
await tab(tester, 'pipelines');
expect(app.provider.value.uri.path, '/settings');
expect(tester.state(find.byType(SettingsScreen)), same(settingsState));
await tab(tester, 'pipelines');
expect(
app.provider.value.uri.path,
'/settings',
reason: 'tab retap is not Back',
);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(
app.provider.value.uri.path,
'/pipelines',
reason: 'explicit Back still exits Settings',
);
expect(tester.takeException(), isNull);
},
testWidgets('Settings is retained inside Pipelines across tab switches', (
tester,
) async {
final app = await mount(tester);
await replyPipelines(tester, app.channel, PipelineFixture());
await tester.pumpAndSettle();
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
}
await tester.pumpAndSettle();
expect(app.provider.value.uri.path, '/settings');
final settingsState = tester.state(find.byType(SettingsScreen));
await tab(tester, 'chat');
expect(app.provider.value.uri.path, '/chat');
await tab(tester, 'pipelines');
expect(app.provider.value.uri.path, '/settings');
expect(tester.state(find.byType(SettingsScreen)), same(settingsState));
await tab(tester, 'pipelines');
expect(
app.provider.value.uri.path,
'/settings',
reason: 'tab retap is not Back',
);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(
app.provider.value.uri.path,
'/pipelines',
reason: 'explicit Back still exits Settings',
);
expect(tester.takeException(), isNull);
});
testWidgets(
'per-tab locations survive app recreation; an explicit deep link wins',
(tester) async {
@@ -209,24 +205,19 @@ void main() {
);
expect(tester.takeException(), isNull);
});
for (final cupertino in [false, true]) {
testWidgets('ordinary root with query restores its tab ($cupertino)', (
tester,
) async {
final store = MemoryTabLocationsStore()
..value = const TabLocationsSnapshot(
routes: {AppDestination.pipelines: AppRoute.settings},
);
final app = await mount(
tester,
route: '/?appearance=cupertino',
cupertino: cupertino,
store: store,
testWidgets('ordinary root with query restores its tab', (tester) async {
final store = MemoryTabLocationsStore()
..value = const TabLocationsSnapshot(
routes: {AppDestination.pipelines: AppRoute.settings},
);
await tester.pumpAndSettle();
expect(app.provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
expect(tester.takeException(), isNull);
});
}
final app = await mount(
tester,
route: '/?appearance=cupertino',
store: store,
);
await tester.pumpAndSettle();
expect(app.provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
expect(tester.takeException(), isNull);
});
}
@@ -1,5 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
@@ -52,19 +50,13 @@ FakeGateway archiveGateway(PipelineFixture fixture, {String? refusal}) {
});
}
Future<void> pump(
WidgetTester tester,
FakeGateway gateway, {
bool cupertino = false,
}) async {
Future<void> pump(WidgetTester tester, FakeGateway gateway) async {
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = PipelinesScreen(gateway: gateway);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: screen) : MaterialApp(home: screen),
);
await tester.pumpWidget(MaterialApp(home: screen));
await tester.pumpAndSettle();
}
@@ -161,24 +153,4 @@ void main() {
await tester.pumpAndSettle();
expect(rowNamed('Alpha review'), findsOneWidget);
});
testWidgets('Cupertino archives through the action sheet and alert', (
tester,
) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
try {
final gateway = archiveGateway(PipelineFixture());
await pump(tester, gateway, cupertino: true);
await tester.tap(rowNamed('Beta deploy'));
await tester.pumpAndSettle();
await openMenuItem(tester, 'pipeline-archive');
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
await tester.tap(find.byKey(const Key('pipeline-archive-confirm')));
await tester.pumpAndSettle();
expect(gateway.callsOf('archive_pipeline'), hasLength(1));
expect(rowNamed('Beta deploy'), findsNothing);
} finally {
debugDefaultTargetPlatformOverride = null;
}
});
}
@@ -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';
@@ -21,44 +20,31 @@ class _Gateway implements ApiGateway {
Stream<JsonMap> get frames => const Stream.empty();
}
Widget _host(
_Gateway gateway, {
bool cupertino = false,
String source = '# stage build',
}) {
Widget _host(_Gateway gateway, {String source = '# stage build'}) {
final body = Column(
children: [
const Text('Pipeline source remains available'),
PipelineDefinitionValidation(gateway: gateway, source: source),
],
);
return cupertino
? CupertinoApp(
home: CupertinoPageScaffold(child: SafeArea(child: body)),
)
: MaterialApp(home: Scaffold(body: body));
return MaterialApp(home: Scaffold(body: body));
}
void main() {
for (final cupertino in [false, true]) {
testWidgets(
'definition warnings stay visible on ${cupertino ? 'Cupertino' : 'Material'}',
(tester) async {
final gateway = _Gateway()
..answer = () async => {
'type': 'validated',
'warnings': ['Review prompt exceeds 2000 bytes.', '', 42],
};
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
await tester.pumpAndSettle();
expect(find.text('Definition warnings'), findsOneWidget);
expect(find.text('Review prompt exceeds 2000 bytes.'), findsOneWidget);
expect(find.text('42'), findsNothing);
expect(gateway.calls.single, {'source': '# stage build'});
expect(tester.takeException(), isNull);
},
);
}
testWidgets('definition warnings stay visible', (tester) async {
final gateway = _Gateway()
..answer = () async => {
'type': 'validated',
'warnings': ['Review prompt exceeds 2000 bytes.', '', 42],
};
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(find.text('Definition warnings'), findsOneWidget);
expect(find.text('Review prompt exceeds 2000 bytes.'), findsOneWidget);
expect(find.text('42'), findsNothing);
expect(gateway.calls.single, {'source': '# stage build'});
expect(tester.takeException(), isNull);
});
testWidgets(
'loading validation never hides detail and a source is checked once',
@@ -1,7 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
@@ -211,34 +209,4 @@ void main() {
);
expect(tester.takeException(), isNull);
});
testWidgets('Cupertino keeps the shared row with the same row identity', (
tester,
) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
try {
await tester.pumpWidget(
CupertinoApp(
home: PipelinesScreen(gateway: gatewayFor(PipelineFixture())),
),
);
await tester.pumpAndSettle();
expect(
tester
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
.cupertino,
isTrue,
);
expect(find.text('2 stages · 1 schedule'), findsOneWidget);
expect(find.textContaining('v2 · #'), findsNothing);
expect(find.byKey(const Key('pipeline-avatar-1')), findsOneWidget);
expect(find.byKey(const Key('pipeline-status-1')), findsOneWidget);
} finally {
debugDefaultTargetPlatformOverride = null;
}
});
}
@@ -1,45 +1,35 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_scope_control.dart';
void main() {
for (final cupertino in [false, true]) {
for (final width in [120.0, 500.0]) {
testWidgets(
'native scope remains usable at $width, Cupertino=$cupertino',
(tester) async {
var scope = PipelineScope.all;
final control = StatefulBuilder(
builder: (context, setState) => Center(
child: SizedBox(
width: width,
child: PipelineScopeControl(
scope: scope,
onSelected: (value) => setState(() => scope = value),
),
),
for (final width in [120.0, 500.0]) {
testWidgets('native scope remains usable at $width', (tester) async {
var scope = PipelineScope.all;
final control = StatefulBuilder(
builder: (context, setState) => Center(
child: SizedBox(
width: width,
child: PipelineScopeControl(
scope: scope,
onSelected: (value) => setState(() => scope = value),
),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: control))
: MaterialApp(home: Scaffold(body: control)),
);
await tester.pumpAndSettle();
if (width == 120) {
await tester.tap(find.byKey(const Key('pipeline-scope')));
await tester.pumpAndSettle();
await tester.tap(find.text('Scheduled').last);
} else {
await tester.tap(find.text('Scheduled'));
}
await tester.pumpAndSettle();
expect(scope, PipelineScope.scheduled);
expect(tester.takeException(), isNull);
},
),
),
);
}
await tester.pumpWidget(MaterialApp(home: Scaffold(body: control)));
await tester.pumpAndSettle();
if (width == 120) {
await tester.tap(find.byKey(const Key('pipeline-scope')));
await tester.pumpAndSettle();
await tester.tap(find.text('Scheduled').last);
} else {
await tester.tap(find.text('Scheduled'));
}
await tester.pumpAndSettle();
expect(scope, PipelineScope.scheduled);
expect(tester.takeException(), isNull);
});
}
testWidgets('wide scope control hugs its labels', (tester) async {
@@ -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/features/pipelines/screen.dart';
@@ -8,68 +7,62 @@ import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'fixtures.dart';
/// The pipeline Summary is flat on both hosts: facts in the shared grid,
/// Schedules with Add as its heading's only action (no body Refresh), and
/// versions as the shared list row.
/// The pipeline Summary is flat: facts in the shared grid, Schedules with Add
/// as its heading's only action (no body Refresh), and versions as the shared
/// list row.
void main() {
for (final cupertino in [false, true]) {
testWidgets('pipeline Summary is a facts grid with flat sections '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
final gateway = FakeGateway((type, fields) {
return switch (type) {
'list_pipelines' => pipelineListReply([
pipelineSummary(id: 1, name: 'Alpha review', version: 3),
]),
'list_runs' => runListReply([]),
'get_pipeline' => pipelineDetailReply(
pipelineDetail(
id: 1,
name: 'Alpha review',
version: 3,
latestVersion: 3,
versions: [versionSummary(2), versionSummary(3)],
),
testWidgets('pipeline Summary is a facts grid with flat sections', (
tester,
) async {
final gateway = FakeGateway((type, fields) {
return switch (type) {
'list_pipelines' => pipelineListReply([
pipelineSummary(id: 1, name: 'Alpha review', version: 3),
]),
'list_runs' => runListReply([]),
'get_pipeline' => pipelineDetailReply(
pipelineDetail(
id: 1,
name: 'Alpha review',
version: 3,
latestVersion: 3,
versions: [versionSummary(2), versionSummary(3)],
),
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
_ => errorReply('unexpected $type'),
};
});
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = PipelinesScreen(gateway: gateway);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
: MaterialApp(home: screen),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
expect(find.byKey(pipelineSummaryFactsKey), findsOneWidget);
// Short facts share a line instead of one label/value row each.
final latest = tester.getRect(
find.byKey(const ValueKey('pipeline-summary-latest-version')),
);
final versionCreated = tester.getRect(
find.byKey(const ValueKey('pipeline-summary-version-created')),
);
expect(versionCreated.top, moreOrLessEquals(latest.top));
expect(versionCreated.left, greaterThan(latest.right));
expect(find.text('Refresh'), findsNothing);
expect(find.text(scheduleAddLabel), findsNothing);
expect(find.byKey(scheduleAddKey), findsOneWidget);
expect(find.byType(CupertinoListSection), findsNothing);
expect(find.byType(ListTile), findsNothing);
final row = tester.widget<AppListRow>(
find.byKey(const Key('pipeline-version-3')),
);
expect(row.selected, isTrue);
expect(row.cupertino, cupertino);
expect(tester.takeException(), isNull);
),
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
_ => errorReply('unexpected $type'),
};
});
}
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = PipelinesScreen(gateway: gateway);
await tester.pumpWidget(MaterialApp(home: screen));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
expect(find.byKey(pipelineSummaryFactsKey), findsOneWidget);
// Short facts share a line instead of one label/value row each.
final latest = tester.getRect(
find.byKey(const ValueKey('pipeline-summary-latest-version')),
);
final versionCreated = tester.getRect(
find.byKey(const ValueKey('pipeline-summary-version-created')),
);
expect(versionCreated.top, moreOrLessEquals(latest.top));
expect(versionCreated.left, greaterThan(latest.right));
expect(find.text('Refresh'), findsNothing);
expect(find.text(scheduleAddLabel), findsNothing);
expect(find.byKey(scheduleAddKey), findsOneWidget);
expect(find.byType(ListTile), findsNothing);
final row = tester.widget<AppListRow>(
find.byKey(const Key('pipeline-version-3')),
);
expect(row.selected, isTrue);
expect(row.cupertino, isFalse);
expect(tester.takeException(), isNull);
});
}
@@ -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/features/pipelines/widgets/pipeline_tabs.dart';
@@ -26,64 +25,52 @@ void main() {
);
});
for (final cupertino in [false, true]) {
for (final width in [320.0, 390.0, 720.0, 1200.0]) {
testWidgets('floating tabs at $width, 2x, Cupertino=$cupertino', (
tester,
) async {
tester.view.physicalSize = Size(width, 640);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
PipelineDetailTab? selected;
final body = Align(
alignment: Alignment.bottomCenter,
child: PipelineDetailTabs(
selected: PipelineDetailTab.summary,
onSelected: (value) => selected = value,
),
for (final width in [320.0, 390.0, 720.0, 1200.0]) {
testWidgets('floating tabs at $width, 2x', (tester) async {
tester.view.physicalSize = Size(width, 640);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
PipelineDetailTab? selected;
final body = Align(
alignment: Alignment.bottomCenter,
child: PipelineDetailTabs(
selected: PipelineDetailTab.summary,
onSelected: (value) => selected = value,
),
);
Widget scaled(BuildContext context, Widget? child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(2)),
child: child!,
);
await tester.pumpWidget(
MaterialApp(builder: scaled, home: Scaffold(body: body)),
);
await tester.pumpAndSettle();
// One floating bar of separate round tab buttons.
expect(find.byType(FloatingDestinationBar), findsOneWidget);
final pill = tester.getRect(find.byKey(FloatingDestinationBar.rowKey));
// Sized to its three tabs at the right edge, on a phone as when wide.
expect(pill.right, width - 16);
expect(
pill.width,
FloatingDestinationBar.rowWidth(
cupertino: false,
tabs: PipelineDetailTab.values.length,
),
);
for (final tab in PipelineDetailTab.values) {
final rect = tester.getRect(
find.byKey(ValueKey('pipeline-detail-tab-${tab.name}')),
);
Widget scaled(BuildContext context, Widget? child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(2)),
child: child!,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
builder: scaled,
home: CupertinoPageScaffold(child: body),
)
: MaterialApp(
builder: scaled,
home: Scaffold(body: body),
),
);
await tester.pumpAndSettle();
// One floating bar of separate round tab buttons.
expect(find.byType(FloatingDestinationBar), findsOneWidget);
final pill = tester.getRect(find.byKey(FloatingDestinationBar.rowKey));
// Sized to its three tabs at the right edge, on a phone as when wide.
expect(pill.right, width - 16);
expect(
pill.width,
FloatingDestinationBar.rowWidth(
cupertino: cupertino,
tabs: PipelineDetailTab.values.length,
),
);
for (final tab in PipelineDetailTab.values) {
final rect = tester.getRect(
find.byKey(ValueKey('pipeline-detail-tab-${tab.name}')),
);
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
}
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pumpAndSettle();
expect(selected, PipelineDetailTab.source);
expect(tester.takeException(), isNull);
});
}
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
}
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pumpAndSettle();
expect(selected, PipelineDetailTab.source);
expect(tester.takeException(), isNull);
});
}
}
@@ -1,15 +1,11 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import '../../native_back.dart';
import 'package:pipelines_app/features/graph/widgets/definition_graph_view.dart';
import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_panel.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'fixtures.dart';
import 'test_helpers.dart';
@@ -110,66 +106,6 @@ void main() {
expect(find.byKey(const Key('pipeline-detail')), findsOneWidget);
});
testWidgets('iOS uses Cupertino scaffolds, list tiles and segmented tabs', (
tester,
) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final fixture = PipelineFixture();
try {
await tester.pumpWidget(
CupertinoApp(home: PipelinesScreen(gateway: gatewayFor(fixture))),
);
await tester.pumpAndSettle();
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
// The shared list row, in its Cupertino form.
expect(
tester
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
.cupertino,
isTrue,
);
expect(find.byType(CupertinoActionSheet), findsNothing);
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
// The tabs are the floating glass Cupertino tab bar.
expect(
find.descendant(
of: find.byKey(const Key('pipeline-detail-tabs')),
matching: find.byType(FloatingDestinationBar),
),
findsOneWidget,
);
// Versions are the shared row in its Cupertino form, flat on the page.
expect(
tester
.widget<AppListRow>(find.byKey(const Key('pipeline-version-1')))
.cupertino,
isTrue,
);
expect(find.byType(CupertinoListSection), findsNothing);
await tester.tap(find.byKey(const Key('pipeline-version-1')));
await tester.pumpAndSettle();
expect(find.text('Viewing v1 (latest v2).'), findsOneWidget);
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pump();
expect(
selectableText(
'name: Alpha review\nstages:\n review:\n type: model\n'
'# selected version 1',
),
findsOneWidget,
);
} finally {
debugDefaultTargetPlatformOverride = null;
}
});
testWidgets('3x text in a very short panel keeps the tabs reachable', (
tester,
) async {
@@ -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/features/pipelines/screen.dart';
@@ -136,21 +135,15 @@ void main() {
expect(find.text('Beta deploy'), findsOneWidget);
});
for (final cupertino in [false, true]) {
testWidgets('Schedules opens from the bar (cupertino: $cupertino)', (
tester,
) async {
var opened = 0;
final screen = PipelinesScreen(
gateway: gatewayFor(PipelineFixture()),
onOpenSchedules: () => opened++,
);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: screen) : MaterialApp(home: screen),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipelines-open-schedules')));
expect(opened, 1);
});
}
testWidgets('Schedules opens from the bar', (tester) async {
var opened = 0;
final screen = PipelinesScreen(
gateway: gatewayFor(PipelineFixture()),
onOpenSchedules: () => opened++,
);
await tester.pumpWidget(MaterialApp(home: screen));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipelines-open-schedules')));
expect(opened, 1);
});
}
@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -53,17 +52,14 @@ JsonMap noRun() => {'type': 'run', 'run_detail': null};
Future<void> pumpScreen(
WidgetTester tester,
FakeGateway gateway,
List<int> navigated, {
bool cupertino = false,
}) async {
List<int> navigated,
) async {
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = PipelinesScreen(gateway: gateway, onRunStarted: navigated.add);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: screen) : MaterialApp(home: screen),
);
await tester.pumpWidget(MaterialApp(home: screen));
await tester.pumpAndSettle();
}
@@ -582,74 +578,6 @@ void main() {
expect(navigated, [86]);
});
testWidgets('the Cupertino host shows the same native prompt and words', (
tester,
) async {
final fixture = PipelineFixture();
final navigated = <int>[];
final gateway = launchGateway(
fixture,
onLaunch: (fields) => acceptedRun(84),
);
await pumpScreen(tester, gateway, navigated, cupertino: true);
await openDetail(tester);
await tester.tap(find.byKey(runPipelineActionKey));
await tester.pumpAndSettle();
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
expect(find.byType(AlertDialog), findsNothing);
expect(find.text('Run Alpha review'), findsOneWidget);
expect(find.text(runPipelinePromptLabel), findsOneWidget);
expect(find.text(runPipelineWorkspaceLabel), findsOneWidget);
expect(find.text(runPipelineNotifyLabel), findsOneWidget);
expect(
find.descendant(
of: find.byType(CupertinoAlertDialog),
matching: find.text(runPipelineConfirmLabel),
),
findsOneWidget,
);
expect(find.text(runPipelineCancelLabel), findsOneWidget);
expect(gateway.callsOf('run_pipeline'), isEmpty);
await tester.tap(find.byKey(runPipelineCancelKey));
await tester.pumpAndSettle();
expect(find.byType(CupertinoAlertDialog), findsNothing);
expect(gateway.callsOf('run_pipeline'), isEmpty);
});
testWidgets('Cupertino field labels and helper use theme label roles', (
tester,
) async {
final fixture = PipelineFixture();
final gateway = launchGateway(
fixture,
onLaunch: (fields) => acceptedRun(87),
);
await pumpScreen(tester, gateway, <int>[], cupertino: true);
await openDetail(tester);
await tester.tap(find.byKey(runPipelineActionKey));
await tester.pumpAndSettle();
final context = tester.element(find.byType(CupertinoAlertDialog));
final theme = CupertinoTheme.of(context);
final labelStyle = theme.textTheme.textStyle;
for (final label in [
runPipelinePromptLabel,
runPipelineWorkspaceLabel,
runPipelineNotifyLabel,
]) {
final style = tester.widget<Text>(find.text(label)).style;
expect(style?.color, labelStyle.color, reason: label);
expect(style?.fontSize, labelStyle.fontSize, reason: label);
}
final helper = tester
.widget<Text>(find.text(runPipelineWorkspaceHelper))
.style;
expect(helper?.color, CupertinoColors.secondaryLabel.resolveFrom(context));
expect(helper?.fontSize, theme.textTheme.tabLabelTextStyle.fontSize);
});
testWidgets('Schedule… leaves the run dialog for the schedule editor', (
tester,
) async {
@@ -55,6 +55,8 @@ void main() {
for (final cupertino in [false, true]) {
final name = cupertino ? 'Cupertino' : 'Material';
for (final MapEntry(key: label, value: (bar, tabs)) in bars.entries) {
// The pipeline detail bar is Material on every host.
if (cupertino && label == 'pipeline detail') continue;
testWidgets('$name $label tabs are icons named for assistive '
'technology', (tester) async {
final semantics = tester.ensureSemantics();