Open active chat when Chat is reselected
Route destination re-selections through the adaptive shell so Chat can restore its retained workspace and focus the composer. Add shell and phone coverage plus implementation notes for the empty-list behavior and verification limits.
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
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('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]);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user