Merge branch 'worktree-agent-a717651aa412e3b7c'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,11 @@ import 'chat_registration_test.dart'
|
||||
|
||||
final _field = find.byKey(const Key('chat-quick-switch-field'));
|
||||
|
||||
Future<void> _replySessions(WidgetTester tester, FakeChannel channel) async {
|
||||
Future<void> _replySessions(
|
||||
WidgetTester tester,
|
||||
FakeChannel channel, {
|
||||
bool awaiting = false,
|
||||
}) async {
|
||||
final request = await waitForRequest(tester, channel, 'chat_sessions');
|
||||
channel.incoming.add(
|
||||
jsonEncode({
|
||||
@@ -22,7 +26,12 @@ Future<void> _replySessions(WidgetTester tester, FakeChannel channel) async {
|
||||
'chat_sessions': [
|
||||
{'id': 's1', 'title': 'Wire chat', 'directory': '/workspace/demo'},
|
||||
{'id': 's2', 'title': 'Second chat', 'directory': '/workspace/other'},
|
||||
{'id': 's3', 'title': 'Third chat', 'directory': '/workspace/demo'},
|
||||
{
|
||||
'id': 's3',
|
||||
'title': 'Third chat',
|
||||
'directory': '/workspace/demo',
|
||||
if (awaiting) 'activity': {'awaiting_operator': 1, 'seq': 1},
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
@@ -31,8 +40,9 @@ Future<void> _replySessions(WidgetTester tester, FakeChannel channel) async {
|
||||
|
||||
Future<FakeChannel> _mountOnChat(
|
||||
WidgetTester tester,
|
||||
PlatformRouteInformationProvider provider,
|
||||
) async {
|
||||
PlatformRouteInformationProvider provider, {
|
||||
bool awaiting = false,
|
||||
}) async {
|
||||
tester.view.physicalSize = const Size(1200, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
@@ -48,10 +58,15 @@ Future<FakeChannel> _mountOnChat(
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await _replySessions(tester, channel);
|
||||
await _replySessions(tester, channel, awaiting: awaiting);
|
||||
await replySubscribe(tester, channel);
|
||||
await replyHistory(tester, channel);
|
||||
await tester.pumpAndSettle();
|
||||
// A chat waiting for the operator pulses its badge, so it never settles.
|
||||
if (awaiting) {
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
} else {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
expect(find.byType(ChatThreadView), findsOneWidget);
|
||||
return channel;
|
||||
}
|
||||
@@ -149,6 +164,81 @@ void main() {
|
||||
await _teardown(tester);
|
||||
});
|
||||
|
||||
testWidgets('the shortcut then Enter returns to the previous chat', (
|
||||
tester,
|
||||
) async {
|
||||
final provider = _provider();
|
||||
final channel = await _mountOnChat(tester, provider);
|
||||
await _chord(tester, LogicalKeyboardKey.controlLeft);
|
||||
await tester.enterText(_field, 'second');
|
||||
await tester.pump();
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
|
||||
await tester.pump();
|
||||
await replySubscribe(tester, channel, index: 1);
|
||||
await replyHistory(tester, channel, index: 1);
|
||||
await tester.pumpAndSettle();
|
||||
expect(provider.value.uri.path, '/chat/s2');
|
||||
|
||||
await _chord(tester, LogicalKeyboardKey.controlLeft);
|
||||
// Most recent first: the open chat, then the one before it, selected.
|
||||
final rows = tester
|
||||
.widgetList<ListTile>(
|
||||
find.byWidgetPredicate(
|
||||
(w) =>
|
||||
w is ListTile && '${w.key}'.contains('chat-quick-switch-row'),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
expect(
|
||||
rows.map((tile) => '${tile.key}'.split('row-').last.split("'").first),
|
||||
['s2', 's1', 's3'],
|
||||
);
|
||||
expect(rows[1].selected, isTrue);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
|
||||
await tester.pumpAndSettle();
|
||||
expect(provider.value.uri.path, '/chat/s1');
|
||||
await _teardown(tester);
|
||||
});
|
||||
|
||||
testWidgets('Alt+J opens the next chat waiting for you', (tester) async {
|
||||
final provider = _provider();
|
||||
final channel = await _mountOnChat(tester, provider, awaiting: true);
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyJ);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await replySubscribe(tester, channel, index: 1);
|
||||
await replyHistory(tester, channel, index: 1);
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
expect(provider.value.uri.path, '/chat/s3');
|
||||
|
||||
// Only the open chat needs you now: nothing else to go to.
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyJ);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/chat/s3');
|
||||
expect(find.text('No other chat needs you.'), findsOneWidget);
|
||||
await _teardown(tester);
|
||||
});
|
||||
|
||||
testWidgets('Alt+N from Runs opens New chat', (tester) async {
|
||||
await _mountOnChat(tester, _provider());
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
await tester.pump();
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.altLeft);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.keyN);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.altLeft);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 600));
|
||||
expect(find.byType(Dialog), findsOneWidget);
|
||||
await _teardown(tester);
|
||||
});
|
||||
|
||||
testWidgets('elsewhere the shortcut still jumps to Chat', (tester) async {
|
||||
final provider = _provider();
|
||||
await _mountOnChat(tester, provider);
|
||||
|
||||
Reference in New Issue
Block a user