Keep background pane updates from stealing destination navigation
This commit is contained in:
@@ -4,6 +4,8 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/screen.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_actions.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||
@@ -260,4 +262,44 @@ void main() {
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
testWidgets(
|
||||
'background new-session completion never navigates away from Search',
|
||||
(tester) async {
|
||||
final gateway = await _setup(tester);
|
||||
final opened = <String>[];
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: AdaptiveShell(
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
AppDestination.chat: (_) =>
|
||||
ChatScreen(gateway: gateway, onSessionSelected: opened.add),
|
||||
AppDestination.search: (_) => const Text('Search destination'),
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Chat a').first);
|
||||
await tester.pumpAndSettle();
|
||||
await _split(tester, 'b', 'Open to the right');
|
||||
final finishedNew = tester
|
||||
.widget<ChatThreadView>(_thread('b'))
|
||||
.onNewSession!;
|
||||
final before = opened.length;
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.search')));
|
||||
await tester.pumpAndSettle();
|
||||
finishedNew('b', {'id': 'b-new', 'title': 'Fresh B'}, 'Started fresh');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Search destination'), findsOneWidget);
|
||||
expect(opened.length, before);
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_thread('a'), findsOneWidget);
|
||||
expect(_thread('b-new'), findsOneWidget);
|
||||
expect(opened.last, 'b-new');
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user