Make Settings a top-level navigation destination
Show Back only when Settings is reached through a pushed route, and remove duplicate Settings controls where the shell already provides navigation. Update focused widget coverage and document the destination behavior.
This commit is contained in:
@@ -7,15 +7,16 @@ 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 on a phone, from the rail's foot on a wide window), keeps its
|
||||
/// `/settings` route (and deep link), and closes back to Pipelines. The tab bar keeps Pipelines selected meanwhile.
|
||||
/// Settings is a navigation destination: the phone's bar and the wide rail
|
||||
/// offer it, and the floating tab bar's width (between the list-detail and rail
|
||||
/// widths) keeps the Pipelines bar's gear. Settings reached from a nav control
|
||||
/// has no Back; reached as a pushed page (the gear, the /settings deep link) it
|
||||
/// has Back, which returns to Pipelines.
|
||||
void main() {
|
||||
Future<PlatformRouteInformationProvider> pumpApp(
|
||||
WidgetTester tester, {
|
||||
@@ -50,61 +51,47 @@ void main() {
|
||||
int selectedTab(WidgetTester tester) =>
|
||||
tester.widget<NavigationBar>(find.byType(NavigationBar)).selectedIndex;
|
||||
|
||||
// A phone's Pipelines bar keeps the gear; a wide window's rail offers
|
||||
// Settings instead (see the wide test below).
|
||||
for (final size in [const Size(390, 844)]) {
|
||||
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 and Settings as the bar's last destination.
|
||||
expect(
|
||||
tester
|
||||
.widget<NavigationBar>(find.byType(NavigationBar))
|
||||
.destinations
|
||||
.map((item) => (item as NavigationDestination).label),
|
||||
['Pipelines', 'Runs', 'Chat', 'Search', 'Settings'],
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('shell.destination.settings')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
||||
testWidgets('390: the bar offers Settings and no gear; Settings from the bar '
|
||||
'has no Back and the Pipelines item leaves it', (tester) async {
|
||||
final provider = await pumpApp(
|
||||
tester,
|
||||
location: '/pipelines',
|
||||
size: const Size(390, 844),
|
||||
);
|
||||
// Four tabs and Settings as the bar's last destination.
|
||||
expect(
|
||||
tester
|
||||
.widget<NavigationBar>(find.byType(NavigationBar))
|
||||
.destinations
|
||||
.map((item) => (item as NavigationDestination).label),
|
||||
['Pipelines', 'Runs', 'Chat', 'Search', 'Settings'],
|
||||
);
|
||||
expect(find.byKey(const Key('pipelines-open-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 openSettingsSection(tester, 'Connection');
|
||||
expect(find.text('Server URL'), findsOneWidget);
|
||||
// A page of Pipelines: Back in its bar, Settings selected in the bar.
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
|
||||
expect(selectedTab(tester), 4);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(provider.value.uri.path, '/settings');
|
||||
expect(find.byType(SettingsScreen), findsOneWidget);
|
||||
expect(find.text('Quick switch animation'), findsOneWidget);
|
||||
await openSettingsSection(tester, 'Connection');
|
||||
expect(find.text('Server URL'), findsOneWidget);
|
||||
// A destination: no Back, and Settings is the selected item of the bar.
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
||||
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
|
||||
expect(selectedTab(tester), 4);
|
||||
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();
|
||||
});
|
||||
}
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(provider.value.uri.path, '/pipelines');
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('1200: the rail offers Settings at its foot and no gear is '
|
||||
'left in the Pipelines toolbar; Settings is a page and Back returns', (
|
||||
'left in the Pipelines toolbar; Settings from the rail has no Back', (
|
||||
tester,
|
||||
) async {
|
||||
final provider = await pumpApp(
|
||||
@@ -129,21 +116,19 @@ void main() {
|
||||
}
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await tester.pumpAndSettle();
|
||||
expect(provider.value.uri.path, '/settings');
|
||||
expect(find.byType(SettingsScreen), findsOneWidget);
|
||||
// Settings is a page of Pipelines: the rail marks Settings, not a tab.
|
||||
// Settings is a destination: the rail marks Settings, not a tab.
|
||||
expect(
|
||||
tester.widget<NavigationRail>(find.byType(NavigationRail)).selectedIndex,
|
||||
isNull,
|
||||
);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('shell.back')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(provider.value.uri.path, '/pipelines');
|
||||
expect(find.byKey(const Key('pipelines-open-settings')), findsNothing);
|
||||
expect(
|
||||
@@ -154,8 +139,8 @@ void main() {
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('the /settings deep link opens the Settings page and '
|
||||
'the system Back closes it to Pipelines', (tester) async {
|
||||
testWidgets('the /settings deep link opens Settings as a pushed page with '
|
||||
'Back, and the system Back closes it to Pipelines', (tester) async {
|
||||
final provider = await pumpApp(
|
||||
tester,
|
||||
location: '/settings',
|
||||
@@ -168,8 +153,7 @@ void main() {
|
||||
|
||||
final handled = await tester.binding.handlePopRoute();
|
||||
expect(handled, isTrue, reason: 'Back closes the page, not the app');
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await tester.pumpAndSettle();
|
||||
expect(provider.value.uri.path, '/pipelines');
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'package:pipelines_app/application/pipelines_app.dart';
|
||||
import 'package:pipelines_app/core/transport/pipelines_client.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, requestOf;
|
||||
@@ -45,11 +44,7 @@ void main() {
|
||||
);
|
||||
await replyPipelines(tester, channel, PipelineFixture());
|
||||
|
||||
await tapBarAction(
|
||||
tester,
|
||||
find.byKey(const Key('pipelines-open-settings')),
|
||||
'Settings',
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.settings')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/settings');
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:pipelines_app/features/settings/settings_screen.dart';
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
import 'package:pipelines_app/shell/destination.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;
|
||||
@@ -63,13 +62,10 @@ void main() {
|
||||
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();
|
||||
await tab(tester, 'settings');
|
||||
expect(app.provider.value.uri.path, '/settings');
|
||||
// A destination opened from its nav item: no Back.
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
||||
final settingsState = tester.state(find.byType(SettingsScreen));
|
||||
await tab(tester, 'chat');
|
||||
expect(app.provider.value.uri.path, '/chat');
|
||||
@@ -77,19 +73,12 @@ void main() {
|
||||
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',
|
||||
reason: 'the Pipelines item leaves Settings for its list',
|
||||
);
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
testWidgets(
|
||||
@@ -191,8 +180,8 @@ void main() {
|
||||
await tab(tester, 'pipelines');
|
||||
expect(app.provider.value.uri.path, '/settings');
|
||||
expect(tester.widget<PipelinesScreen>(hidden).initialPipelineId, 1);
|
||||
await tester.tap(find.byKey(const Key('shell.back')));
|
||||
await tester.pumpAndSettle();
|
||||
// Settings has no Back; the Pipelines item returns to the open pipeline.
|
||||
await tab(tester, 'pipelines');
|
||||
expect(app.provider.value.uri.path, '/pipelines/1');
|
||||
expect(tester.state(find.byType(PipelinesScreen)), same(pipelineState));
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user