Merge branch 'chat/header-islands'
# Conflicts: # app/tool/capture/README.md
This commit is contained in:
@@ -4,7 +4,6 @@ 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/ui/layout/app_list_row.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'conversation/chat_thread_fixtures.dart';
|
||||
@@ -79,113 +78,22 @@ Future<ValueNotifier<String?>> _pump(
|
||||
Finder _thread(String id) => find.byKey(ValueKey('chat-thread-$id'));
|
||||
final _next = find.byKey(const Key('chat-next'));
|
||||
|
||||
bool _rowSelected(WidgetTester tester, String id) =>
|
||||
tester.widget<AppListRow>(find.byKey(Key('chat-row-$id'))).selected;
|
||||
|
||||
Future<void> _pressNext(WidgetTester tester) async {
|
||||
await tester.tap(_next);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('wide: Next chat walks the list order, wraps, syncs the row', (
|
||||
tester,
|
||||
) async {
|
||||
final route = await _pump(tester, const Size(1280, 800));
|
||||
await tester.tap(find.byKey(const Key('chat-row-a')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_thread('a'), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<IconButton>(
|
||||
find.descendant(of: _next, matching: find.byType(IconButton)),
|
||||
)
|
||||
.tooltip,
|
||||
'Next chat',
|
||||
);
|
||||
|
||||
final visited = <String>[];
|
||||
for (var i = 0; i < 5; i++) {
|
||||
await _pressNext(tester);
|
||||
visited.add(route.value!);
|
||||
expect(_thread(route.value!), findsOneWidget);
|
||||
expect(_rowSelected(tester, route.value!), isTrue);
|
||||
}
|
||||
// Closed is folded, so Done is skipped; after the last row comes the
|
||||
// first again.
|
||||
expect(visited, ['z', 'r', 's', 'd', 'a']);
|
||||
expect(_rowSelected(tester, 'd'), isFalse);
|
||||
final navigator = tester.state<NavigatorState>(
|
||||
find.byType(Navigator).first,
|
||||
);
|
||||
expect(navigator.canPop(), isFalse);
|
||||
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
|
||||
testWidgets('phone: Next chat replaces the open page, never stacks one', (
|
||||
tester,
|
||||
) async {
|
||||
final route = await _pump(tester, const Size(390, 844));
|
||||
await tester.tap(find.text('Second'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_thread('s'), findsOneWidget);
|
||||
|
||||
await _pressNext(tester);
|
||||
expect(route.value, 'd');
|
||||
expect(_thread('d'), findsOneWidget);
|
||||
expect(_thread('s'), findsNothing);
|
||||
await _pressNext(tester);
|
||||
expect(route.value, 'a', reason: 'wraps past the last row');
|
||||
|
||||
// One Back leaves the chat: no earlier chat page waits beneath it.
|
||||
await tester.pageBack();
|
||||
await tester.pumpAndSettle();
|
||||
expect(route.value, isNull);
|
||||
expect(_thread('a'), findsNothing);
|
||||
final navigator = tester.state<NavigatorState>(
|
||||
find.byType(Navigator).first,
|
||||
);
|
||||
expect(navigator.canPop(), isFalse);
|
||||
expect(_rowSelected(tester, 'a'), isFalse);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
|
||||
testWidgets('only one chat to show hides Next chat', (tester) async {
|
||||
await _pump(
|
||||
for (final size in [const Size(1280, 800), const Size(390, 844)]) {
|
||||
testWidgets('Next chat is absent from header and More at $size', (
|
||||
tester,
|
||||
const Size(390, 844),
|
||||
rows: const [
|
||||
{'id': 'r', 'title': 'Recent', 'directory': '/w'},
|
||||
{'id': 'c', 'title': 'Done', 'directory': '/w', 'closed_at': 1},
|
||||
],
|
||||
);
|
||||
await tester.tap(find.text('Recent'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_thread('r'), findsOneWidget);
|
||||
expect(_next, findsNothing);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
|
||||
testWidgets('unfolding Closed offers Next chat and includes its rows', (
|
||||
tester,
|
||||
) async {
|
||||
final route = await _pump(
|
||||
tester,
|
||||
const Size(1280, 800),
|
||||
rows: const [
|
||||
{'id': 'r', 'title': 'Recent', 'directory': '/w'},
|
||||
{'id': 'c', 'title': 'Done', 'directory': '/w', 'closed_at': 1},
|
||||
],
|
||||
);
|
||||
await tester.tap(find.text('Recent'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_next, findsNothing);
|
||||
await tester.tap(find.text('Closed'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_next, findsOneWidget);
|
||||
await _pressNext(tester);
|
||||
expect(route.value, 'c');
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
) async {
|
||||
await _pump(tester, size);
|
||||
await tester.tap(find.byKey(const Key('chat-row-a')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_thread('a'), findsOneWidget);
|
||||
expect(_next, findsNothing);
|
||||
expect(find.byTooltip('Next chat'), findsNothing);
|
||||
await tester.tap(find.byTooltip('More actions').hitTestable().first);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Next chat'), findsNothing);
|
||||
expect(find.text('Add chat pane'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,25 +86,25 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('model-a'), findsOneWidget);
|
||||
expect(find.byTooltip('Change model (currently model-a)'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-model')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Model Beta'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('model-b'), findsOneWidget);
|
||||
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
|
||||
|
||||
await tester.tap(findNativeBack());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('model-b'), findsNothing);
|
||||
expect(find.byTooltip('Change model (currently model-b)'), findsNothing);
|
||||
|
||||
// The list still carries the row it read before the switch; reopening must
|
||||
// still show the model the server accepted.
|
||||
await tester.tap(find.byKey(const Key('chat-row-s')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('model-b'), findsOneWidget);
|
||||
expect(find.text('model-a'), findsNothing);
|
||||
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
|
||||
expect(find.byTooltip('Change model (currently model-a)'), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-model')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -133,7 +133,7 @@ void main() {
|
||||
// The deep link opened before any row was tapped: the list's own read
|
||||
// supplies the title and the recorded model, with no second list request.
|
||||
expect(find.text('Wire chat'), findsOneWidget);
|
||||
expect(find.text('model-a'), findsOneWidget);
|
||||
expect(find.byTooltip('Change model (currently model-a)'), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
||||
expect(gateway.count('chat_sessions'), 1);
|
||||
|
||||
@@ -149,7 +149,7 @@ void main() {
|
||||
expect(gateway.calls.last.fields, {
|
||||
'chat_model': {'session_id': 's', 'provider': 'p2', 'model': 'model-b'},
|
||||
});
|
||||
expect(find.text('model-b'), findsOneWidget);
|
||||
expect(find.byTooltip('Change model (currently model-b)'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
|
||||
@@ -85,33 +85,28 @@ Future<void> _tap(
|
||||
}
|
||||
|
||||
Finder _row(String id) => find.byKey(Key('chat-row-$id'));
|
||||
final _next = find.byKey(const Key('chat-next'));
|
||||
|
||||
final _desktop = TargetPlatformVariant.only(TargetPlatform.macOS);
|
||||
final _mobile = TargetPlatformVariant.only(TargetPlatform.android);
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'desktop, wide: a clicked row and Next chat focus the composer',
|
||||
(tester) async {
|
||||
await _pump(tester, const Size(1280, 800));
|
||||
await _tap(tester, _row('r'), kind: PointerDeviceKind.mouse);
|
||||
expect(_thread('r'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 'r'), isTrue);
|
||||
testWidgets('desktop, wide: clicked rows focus the composer', (tester) async {
|
||||
await _pump(tester, const Size(1280, 800));
|
||||
await _tap(tester, _row('r'), kind: PointerDeviceKind.mouse);
|
||||
expect(_thread('r'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 'r'), isTrue);
|
||||
|
||||
// Focus elsewhere, then the chat already open: clicking returns it.
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
await tester.pump();
|
||||
await _tap(tester, _row('r'), kind: PointerDeviceKind.mouse);
|
||||
expect(_composerFocused(tester, 'r'), isTrue);
|
||||
// Focus elsewhere, then the chat already open: clicking returns it.
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
await tester.pump();
|
||||
await _tap(tester, _row('r'), kind: PointerDeviceKind.mouse);
|
||||
expect(_composerFocused(tester, 'r'), isTrue);
|
||||
|
||||
await _tap(tester, _next, kind: PointerDeviceKind.mouse);
|
||||
expect(_thread('s'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 's'), isTrue);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
variant: _desktop,
|
||||
);
|
||||
await _tap(tester, _row('s'), kind: PointerDeviceKind.mouse);
|
||||
expect(_thread('s'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 's'), isTrue);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
}, variant: _desktop);
|
||||
|
||||
testWidgets(
|
||||
'desktop, narrow window: a tapped row focuses the chat page composer',
|
||||
@@ -125,33 +120,29 @@ void main() {
|
||||
variant: _desktop,
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'desktop: a closed chat leaves its composer unfocused',
|
||||
(tester) async {
|
||||
await _pump(tester, const Size(1280, 800));
|
||||
await _tap(tester, find.text('Closed'));
|
||||
await _tap(tester, _row('c'), kind: PointerDeviceKind.mouse);
|
||||
expect(_thread('c'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 'c'), isFalse);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
variant: _desktop,
|
||||
);
|
||||
testWidgets('desktop: a closed chat leaves its composer unfocused', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, const Size(1280, 800));
|
||||
await _tap(tester, find.text('Closed'));
|
||||
await _tap(tester, _row('c'), kind: PointerDeviceKind.mouse);
|
||||
expect(_thread('c'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 'c'), isFalse);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
}, variant: _desktop);
|
||||
|
||||
testWidgets(
|
||||
'mobile: a finger tap and Next chat do not raise the keyboard',
|
||||
(tester) async {
|
||||
await _pump(tester, const Size(390, 844));
|
||||
await _tap(tester, find.text('Recent'));
|
||||
expect(_thread('r'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 'r'), isFalse);
|
||||
await _tap(tester, _next);
|
||||
expect(_thread('s'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 's'), isFalse);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
variant: _mobile,
|
||||
);
|
||||
testWidgets('mobile: finger taps do not raise the keyboard', (tester) async {
|
||||
await _pump(tester, const Size(390, 844));
|
||||
await _tap(tester, find.text('Recent'));
|
||||
expect(_thread('r'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 'r'), isFalse);
|
||||
await tester.pageBack();
|
||||
await tester.pumpAndSettle();
|
||||
await _tap(tester, find.text('Second'));
|
||||
expect(_thread('s'), findsOneWidget);
|
||||
expect(_composerFocused(tester, 's'), isFalse);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
}, variant: _mobile);
|
||||
|
||||
testWidgets(
|
||||
'mobile, wide: a touch tap leaves focus, a mouse click focuses',
|
||||
|
||||
@@ -179,7 +179,10 @@ void main() {
|
||||
await tester.enterText(_input('a'), 'Keep this draft');
|
||||
final originalWidth = tester.getSize(_thread('a')).width;
|
||||
Future<void> choose(String label) async {
|
||||
await tester.tap(find.byTooltip('Chat list layout').first);
|
||||
await tester.tap(find.byTooltip('More actions').hitTestable().first);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Chat list layout'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text(label));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -259,10 +262,12 @@ void main() {
|
||||
.hitTestable();
|
||||
if (closePane.evaluate().isEmpty) {
|
||||
await tester.tap(
|
||||
find.descendant(
|
||||
of: _thread('c'),
|
||||
matching: find.byTooltip('More actions'),
|
||||
),
|
||||
find
|
||||
.descendant(
|
||||
of: _thread('c'),
|
||||
matching: find.byTooltip('More actions'),
|
||||
)
|
||||
.hitTestable(),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Close pane'));
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/core/servers/server_scope.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_sidebar_controls.dart';
|
||||
import 'package:pipelines_app/features/chat/screen.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace_store.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
@@ -89,13 +90,17 @@ void main() {
|
||||
);
|
||||
}
|
||||
expect(
|
||||
tester
|
||||
.widget<ChatSidebarButton>(find.byType(ChatSidebarButton).first)
|
||||
(tester
|
||||
.widget<ChatThreadView>(find.byType(ChatThreadView).first)
|
||||
.sidebarControl!
|
||||
as ChatSidebarButton)
|
||||
.mode,
|
||||
ChatSidebarMode.hidden,
|
||||
);
|
||||
tester
|
||||
.widget<ChatSidebarButton>(find.byType(ChatSidebarButton).first)
|
||||
(tester
|
||||
.widget<ChatThreadView>(find.byType(ChatThreadView).first)
|
||||
.sidebarControl!
|
||||
as ChatSidebarButton)
|
||||
.onChanged(ChatSidebarMode.compact);
|
||||
} else {
|
||||
expect(find.byType(ChatSidebarButton), findsNothing);
|
||||
@@ -115,8 +120,10 @@ void main() {
|
||||
expect((_workspace(tester).root as ChatWorkspaceSplit).ratio, .42);
|
||||
if (width > 1000) {
|
||||
expect(
|
||||
tester
|
||||
.widget<ChatSidebarButton>(find.byType(ChatSidebarButton).first)
|
||||
(tester
|
||||
.widget<ChatThreadView>(find.byType(ChatThreadView).first)
|
||||
.sidebarControl!
|
||||
as ChatSidebarButton)
|
||||
.mode,
|
||||
ChatSidebarMode.compact,
|
||||
);
|
||||
|
||||
@@ -2,6 +2,10 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_header.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_sidebar_controls.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_adaptive.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
import '../../../native_back.dart';
|
||||
import 'chat_thread_fixtures.dart';
|
||||
@@ -95,6 +99,129 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final width in [320.0, 390.0, 1280.0]) {
|
||||
testWidgets(
|
||||
'${cupertino ? 'Cupertino' : 'Material'} grouped actions at $width and text scale 2',
|
||||
(tester) async {
|
||||
_useNarrowText(tester);
|
||||
tester.view.physicalSize = Size(width, 800);
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
gateway.history = (_) async => chatPage(const []);
|
||||
gateway.subscribe = () async => const {};
|
||||
var sidebar = 0;
|
||||
var pane = 0;
|
||||
var next = 0;
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
ChatThreadView(
|
||||
gateway: gateway,
|
||||
sessionId: 's',
|
||||
title: _title,
|
||||
session: {
|
||||
..._session,
|
||||
'mode': 'safe',
|
||||
'mode_name': 'Ask before making changes',
|
||||
},
|
||||
onBack: () {},
|
||||
onNextChat: () => next++,
|
||||
sidebarControl: ChatBarAction(
|
||||
label: 'Sidebar action',
|
||||
onPressed: () => sidebar++,
|
||||
materialIcon: Icons.menu,
|
||||
cupertinoIcon: CupertinoIcons.sidebar_left,
|
||||
),
|
||||
paneControls: [
|
||||
ChatBarAction(
|
||||
label: 'Pane action',
|
||||
onPressed: () => pane++,
|
||||
materialIcon: Icons.add_box,
|
||||
cupertinoIcon: CupertinoIcons.plus_square,
|
||||
),
|
||||
],
|
||||
),
|
||||
cupertino: cupertino,
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final selectors = find.byKey(
|
||||
const Key('chat-model-permission-island'),
|
||||
);
|
||||
final actions = find.byKey(const Key('chat-actions-island'));
|
||||
expect(selectors, findsOneWidget);
|
||||
expect(actions, findsOneWidget);
|
||||
expect(
|
||||
tester.getTopRight(selectors).dx,
|
||||
lessThan(tester.getTopLeft(actions).dx),
|
||||
);
|
||||
expect(find.byKey(const Key('chat-next')), findsNothing);
|
||||
expect(find.text('Next chat'), findsNothing);
|
||||
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-mode')), findsOneWidget);
|
||||
for (final key in ['chat-model', 'chat-mode']) {
|
||||
expect(
|
||||
tester.getSize(find.byKey(Key(key))).width,
|
||||
greaterThanOrEqualTo(cupertino ? 44 : 48),
|
||||
);
|
||||
}
|
||||
expect(find.text('Sidebar action'), findsNothing);
|
||||
expect(find.text('Pane action'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
// Both More entries retain their original callbacks in native menus.
|
||||
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Sidebar action'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(sidebar, 1);
|
||||
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Pane action'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(pane, 1);
|
||||
expect(next, 0);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'sidebar layout submenu retains callback on ${cupertino ? 'Cupertino' : 'Material'}',
|
||||
(tester) async {
|
||||
ChatSidebarMode? picked;
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
ChatThreadHeader(
|
||||
title: 'Chat',
|
||||
folder: 'demo',
|
||||
onInfo: () {},
|
||||
actions: const [Icon(Icons.folder_outlined)],
|
||||
moreActions: [
|
||||
ChatSidebarButton(
|
||||
mode: ChatSidebarMode.expanded,
|
||||
onChanged: (value) => picked = value,
|
||||
),
|
||||
],
|
||||
),
|
||||
cupertino: cupertino,
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(ChatSidebarButton), findsNothing);
|
||||
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Chat list layout'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Hide chat list'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(picked, ChatSidebarMode.hidden);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('a conversation without a model keeps the same compact row', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user