feat(chat): keep the rail and chat list beside the open chat on wide windows
This commit is contained in:
@@ -155,7 +155,7 @@ Future<void> replyHistory(
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'a /chat/s1 deep link renders that thread and Back returns to /chat ($cupertino)',
|
||||
'a wide /chat/s1 deep link shows that thread beside the list and route Back returns to /chat ($cupertino)',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(900, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
@@ -207,14 +207,21 @@ void main() {
|
||||
expect(find.text('1 tool'), findsOneWidget);
|
||||
expect(find.text('Kept behind a native disclosure.'), findsNothing);
|
||||
|
||||
// One shell bar only: the embedded list/thread adds no second one.
|
||||
// The shell bar stays over the list and rail; the open chat has its
|
||||
// own bar in its pane, with no Back: the list beside it is the way out.
|
||||
expect(find.byType(ChatSessionsScreen), findsOneWidget);
|
||||
expect(
|
||||
find.byType(NavigationRail),
|
||||
cupertino ? findsNothing : findsOneWidget,
|
||||
);
|
||||
if (cupertino) {
|
||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||
expect(find.byType(CupertinoNavigationBar), findsNWidgets(2));
|
||||
expect(find.byType(AppBar), findsNothing);
|
||||
} else {
|
||||
expect(find.byType(AppBar), findsOneWidget);
|
||||
expect(find.byType(AppBar), findsNWidgets(2));
|
||||
expect(find.byType(CupertinoNavigationBar), findsNothing);
|
||||
}
|
||||
expect(findNativeBack(), findsNothing);
|
||||
|
||||
// A live frame updates the held thread.
|
||||
channel.incoming.add(
|
||||
@@ -233,16 +240,18 @@ void main() {
|
||||
await tester.pump();
|
||||
expect(find.text('A live line arrived.'), findsOneWidget);
|
||||
|
||||
// The open chat takes over the app bar: one Back there, and no
|
||||
// second header row under it.
|
||||
// The pane bar carries the thread's controls: no second header row.
|
||||
expect(find.byKey(const Key('chat-thread-header')), findsNothing);
|
||||
await tester.tap(findNativeBack());
|
||||
// A real Navigator pop finishes its native reverse transition.
|
||||
// Browser Back to /chat clears the open pane and keeps the list.
|
||||
await provider.didPushRouteInformation(
|
||||
RouteInformation(uri: Uri.parse('/chat')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(provider.value.uri.path, '/chat');
|
||||
expect(find.byType(ChatThreadView), findsNothing);
|
||||
expect(find.byType(ChatSessionsScreen), findsOneWidget);
|
||||
expect(find.text('Wire chat'), findsOneWidget);
|
||||
expect(find.text('Select a chat to open it here.'), findsOneWidget);
|
||||
|
||||
// Browser Forward re-opens the same session through its route.
|
||||
await provider.didPushRouteInformation(
|
||||
|
||||
@@ -29,7 +29,9 @@ class _Gateway extends FakeChatGateway {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final width in [390.0, 840.0]) {
|
||||
// Wide windows keep the chat beside its list instead of pushing a page; that
|
||||
// layout is covered by test/features/chat/chat_list_detail_test.dart.
|
||||
for (final width in [390.0]) {
|
||||
testWidgets(
|
||||
'list → chat → top → bottom → one system Back pops a real route at $width',
|
||||
(tester) async {
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import 'package:flutter/material.dart';
|
||||
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 '../../native_back.dart';
|
||||
import 'conversation/chat_thread_fixtures.dart';
|
||||
|
||||
class _Gateway extends FakeChatGateway {
|
||||
@override
|
||||
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
|
||||
if (type == 'chat_sessions') {
|
||||
return Future.value({
|
||||
'chat_sessions': [
|
||||
{'id': 'a', 'title': 'First chat'},
|
||||
{'id': 'b', 'title': 'Second chat'},
|
||||
],
|
||||
});
|
||||
}
|
||||
if (type == 'chat_shells') return Future.value({'chat_shells': []});
|
||||
return super.call(type, fields);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _pumpShell(WidgetTester tester, Size size) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final gateway = _Gateway()..history = (_) async => chatPage(const []);
|
||||
addTearDown(gateway.close);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: AdaptiveShell(
|
||||
destination: AppDestination.chat,
|
||||
destinationBodies: {
|
||||
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final size in [const Size(1280, 800), const Size(800, 830)]) {
|
||||
testWidgets('a wide window keeps the rail and list beside the open chat '
|
||||
'at $size', (tester) async {
|
||||
await _pumpShell(tester, size);
|
||||
expect(find.text('Select a chat to open it here.'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('First chat'));
|
||||
await tester.pumpAndSettle();
|
||||
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
|
||||
expect(navigator.canPop(), isFalse, reason: 'No page covers the shell');
|
||||
expect(find.byType(NavigationRail), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget);
|
||||
expect(find.text('Second chat'), findsOneWidget);
|
||||
// The shell bar keeps the list's controls; the pane bar has the chat's
|
||||
// title and no Back.
|
||||
expect(find.byKey(const Key('chat-new-chat')), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const ValueKey('chat-detail-pane')),
|
||||
matching: find.text('First chat'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(findNativeBack(), findsNothing);
|
||||
|
||||
// Another row swaps the open chat in place.
|
||||
await tester.tap(find.text('Second chat').first);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('chat-thread-a')), findsNothing);
|
||||
expect(find.byKey(const ValueKey('chat-thread-b')), findsOneWidget);
|
||||
expect(navigator.canPop(), isFalse);
|
||||
|
||||
// The rail still switches destinations with a chat open.
|
||||
await tester.tap(find.text('Runs'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('chat-thread-b')), findsNothing);
|
||||
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('a phone pushes the open chat as its own page', (tester) async {
|
||||
await _pumpShell(tester, const Size(390, 844));
|
||||
expect(find.text('Select a chat to open it here.'), findsNothing);
|
||||
|
||||
await tester.tap(find.text('First chat'));
|
||||
await tester.pumpAndSettle();
|
||||
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
|
||||
expect(navigator.canPop(), isTrue);
|
||||
expect(findNativeBack(), findsOneWidget);
|
||||
expect(find.byType(NavigationBar), findsNothing);
|
||||
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
}
|
||||
@@ -62,6 +62,10 @@ Future<void> _pumpScreen(
|
||||
_ScreenGateway gateway, {
|
||||
String? initialSessionId,
|
||||
}) async {
|
||||
// The phone layout: an open chat is its own page with the native Back.
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
|
||||
Reference in New Issue
Block a user