Files
pipelines/app/test/shell/destination_reselect_test.dart
T
alan 88858945c5 Route rail re-taps through destination reselection
Ensure the navigation rail shares the destination re-selection hook used by the phone tab bar, so re-tapping Chat can reopen active chats on wide layouts. Add focused coverage and record the land-gate verification results.
2026-11-12 03:37:01 +00:00

109 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';
void main() {
Map<AppDestination, WidgetBuilder> bodies() => {
for (final destination in shellTabDestinations)
destination: (_) => Text(destination.name),
};
testWidgets('tapping the shown tab re-selects it instead of selecting', (
tester,
) async {
final selected = <AppDestination>[];
final reselected = <AppDestination>[];
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destinationBodies: bodies(),
destination: AppDestination.chat,
onDestinationSelected: selected.add,
onDestinationReselected: reselected.add,
),
),
);
await tester.pump();
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pump();
expect(reselected, [AppDestination.chat]);
expect(selected, isEmpty);
});
testWidgets('a phone tab bar re-tap of the shown tab re-selects it', (
tester,
) async {
tester.view.physicalSize = const Size(400, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final selected = <AppDestination>[];
final reselected = <AppDestination>[];
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destinationBodies: bodies(),
destination: AppDestination.chat,
onDestinationSelected: selected.add,
onDestinationReselected: reselected.add,
),
),
);
await tester.pump();
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pump();
expect(reselected, [AppDestination.chat]);
expect(selected, isEmpty);
});
testWidgets('tapping another tab selects it, not a re-select', (
tester,
) async {
final selected = <AppDestination>[];
final reselected = <AppDestination>[];
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destinationBodies: bodies(),
destination: AppDestination.chat,
onDestinationSelected: selected.add,
onDestinationReselected: reselected.add,
),
),
);
await tester.pump();
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pump();
expect(selected, [AppDestination.runs]);
expect(reselected, isEmpty);
});
testWidgets('without a re-select hook a shown tab is selected as before', (
tester,
) async {
final selected = <AppDestination>[];
await tester.pumpWidget(
MaterialApp(
home: AdaptiveShell(
destinationBodies: bodies(),
destination: AppDestination.chat,
onDestinationSelected: selected.add,
),
),
);
await tester.pump();
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pump();
expect(selected, [AppDestination.chat]);
});
}