d1b05217c9
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.
127 lines
4.7 KiB
Dart
127 lines
4.7 KiB
Dart
import '../features/settings/settings_topic_test_helper.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/application/pipelines_app.dart';
|
|
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
|
import 'package:pipelines_app/features/settings/settings_screen.dart';
|
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import '../bar_action.dart';
|
|
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
|
import '../features/pipelines/fixtures.dart';
|
|
import 'pipelines_app_test.dart' show webServer;
|
|
import 'pipelines_replies.dart';
|
|
|
|
/// Settings is not a tab: it opens as a page from the gear in the Pipelines
|
|
/// bar, keeps its `/settings` route (and deep link), and closes back to
|
|
/// Pipelines. The tab bar keeps Pipelines selected meanwhile.
|
|
void main() {
|
|
Future<PlatformRouteInformationProvider> pumpApp(
|
|
WidgetTester tester, {
|
|
required String location,
|
|
required Size size,
|
|
}) async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
tester.view.physicalSize = size;
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
final channel = FakeChannel()..readyCompleter.complete();
|
|
final provider = PlatformRouteInformationProvider(
|
|
initialRouteInformation: RouteInformation(uri: Uri.parse(location)),
|
|
);
|
|
addTearDown(provider.dispose);
|
|
await tester.pumpWidget(
|
|
PipelinesApp(
|
|
server: webServer(),
|
|
client: PipelinesClient(channelFactory: (_) => channel),
|
|
cupertino: false,
|
|
routeInformationProvider: provider,
|
|
),
|
|
);
|
|
await tester.pump();
|
|
if (location == '/pipelines') {
|
|
await replyPipelines(tester, channel, PipelineFixture());
|
|
}
|
|
return provider;
|
|
}
|
|
|
|
int selectedTab(WidgetTester tester) => tester
|
|
.widget<FloatingDestinationBar>(find.byType(FloatingDestinationBar))
|
|
.currentIndex;
|
|
|
|
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,
|
|
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('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();
|
|
});
|
|
}
|