26bb583f10
Keep Settings navigation independent while preserving shell actions and destination-specific state. Add the reviewed chat, run-entry, layout, and regression-test updates needed by the destination behavior.
74 lines
2.8 KiB
Dart
74 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/pipelines/screen.dart';
|
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
|
|
|
import 'fixtures.dart';
|
|
import 'test_helpers.dart';
|
|
|
|
/// The Pipelines bar's Settings gear inside the shell: it is kept only where the
|
|
/// floating tab bar is the shell's sole navigation (between the list-detail and
|
|
/// rail widths), because only there Settings has no nav entry. Elsewhere the
|
|
/// phone's bar or the rail offers Settings, so the bar has no gear.
|
|
void main() {
|
|
// Returns how many times the gear opened Settings.
|
|
Future<int Function()> pumpInShell(WidgetTester tester, Size size) async {
|
|
tester.view.physicalSize = size;
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
var opened = 0;
|
|
final gateway = gatewayFor(PipelineFixture());
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: AdaptiveShell(
|
|
destination: AppDestination.pipelines,
|
|
destinationBodies: {
|
|
// The app's Pipelines destination embeds the screen in the shell.
|
|
AppDestination.pipelines: (_) => PipelinesScreen(
|
|
gateway: gateway,
|
|
embedded: true,
|
|
onOpenSettings: () => opened++,
|
|
),
|
|
},
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
return () => opened;
|
|
}
|
|
|
|
testWidgets('a phone bar offers Settings, so the Pipelines bar has no gear', (
|
|
tester,
|
|
) async {
|
|
await pumpInShell(tester, const Size(390, 844));
|
|
expect(find.byType(NavigationBar), findsOneWidget);
|
|
expect(find.byKey(const Key('pipelines-open-settings')), findsNothing);
|
|
});
|
|
|
|
testWidgets('a rail offers Settings, so the Pipelines bar has no gear', (
|
|
tester,
|
|
) async {
|
|
await pumpInShell(tester, const Size(1200, 800));
|
|
expect(find.byType(NavigationRail), findsOneWidget);
|
|
expect(find.byKey(const Key('pipelines-open-settings')), findsNothing);
|
|
});
|
|
|
|
testWidgets('the floating tab bar lists tabs only, so the Pipelines bar '
|
|
'keeps the gear and it opens Settings', (tester) async {
|
|
final opened = await pumpInShell(tester, const Size(650, 844));
|
|
expect(find.byType(FloatingDestinationBar), findsOneWidget);
|
|
expect(find.byKey(const Key('pipelines-open-settings')), findsOneWidget);
|
|
// At this width the bar folds the gear into its More menu, so it is not
|
|
// hit-testable here; its handler is what opens Settings.
|
|
final gear = tester.widget<IconButton>(
|
|
find.byKey(const Key('pipelines-open-settings')),
|
|
);
|
|
expect(gear.tooltip, 'Settings');
|
|
gear.onPressed!();
|
|
expect(opened(), 1);
|
|
});
|
|
}
|