aabd22b5ad
Replace the narrow-layout floating destination pill with a full-width Material 3 NavigationBar. Reuse the shell destination model and badge wiring while preserving re-selection callbacks and hiding the bar for keyboard/detail states.
87 lines
3.1 KiB
Dart
87 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.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';
|
|
|
|
void main() {
|
|
for (final width in [390.0, 1000.0]) {
|
|
testWidgets(
|
|
'Material shell adapts at width $width and supports large text',
|
|
(tester) async {
|
|
tester.view.physicalSize = Size(width, 900);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
await tester.pumpWidget(
|
|
const MaterialApp(
|
|
home: MediaQuery(
|
|
data: MediaQueryData(textScaler: TextScaler.linear(2)),
|
|
child: AdaptiveShell(),
|
|
),
|
|
),
|
|
);
|
|
expect(find.text('Pipelines'), findsWidgets);
|
|
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
|
// This shell reads its width from a MediaQuery of zero size, so it lays
|
|
// out as a phone at every test width: the navigation bar, no rail.
|
|
expect(find.byType(NavigationBar), findsOneWidget);
|
|
expect(find.byType(FloatingDestinationBar), findsNothing);
|
|
expect(find.byType(NavigationRail), findsNothing);
|
|
expect(tester.takeException(), isNull);
|
|
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Runs — Not implemented'), findsOneWidget);
|
|
},
|
|
);
|
|
}
|
|
|
|
testWidgets('destination state survives switching tabs', (tester) async {
|
|
var builds = 0;
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: AdaptiveShell(
|
|
destinationBodies: {
|
|
// Bodies reach the top edge under the floating bar; this one
|
|
// keeps its button clear of it.
|
|
AppDestination.pipelines: (_) => Center(
|
|
child: StatefulBuilder(
|
|
builder: (context, setState) => TextButton(
|
|
onPressed: () => setState(() => builds++),
|
|
child: Text('Builds: $builds'),
|
|
),
|
|
),
|
|
),
|
|
AppDestination.runs: (_) => const Text('Runs screen'),
|
|
},
|
|
),
|
|
),
|
|
);
|
|
await tester.tap(find.text('Builds: 0'));
|
|
await tester.pump();
|
|
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Builds: 1'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('destination content can be supplied by integration', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: AdaptiveShell(
|
|
destinationBodies: {
|
|
AppDestination.pipelines: (_) =>
|
|
const Text('Injected pipelines screen'),
|
|
},
|
|
),
|
|
),
|
|
);
|
|
expect(find.text('Injected pipelines screen'), findsOneWidget);
|
|
expect(find.text('Pipelines — Not implemented'), findsNothing);
|
|
});
|
|
}
|