Files
pipelines/app/test/features/chat/shell/chat_shell_composer_test.dart
T
alan 046de9db4d Use proper phone sheets for chat and Files menus
On phones the chat's More menu, chat list rows and Files entries open a
Material bottom sheet headed by the chat or file, with full-width icon
rows and destructive actions last in the error colour; desktop menus
show icons, a minimum width and destructive actions after a divider.
The chat menu drops Run command and Open chats, keeps a single terminal
entry and lists Close pane last.
2026-11-13 01:14:12 +00:00

69 lines
2.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'chat_shell_fixtures.dart';
/// A desktop keyboard, where Enter sends.
final _desktop = TargetPlatformVariant.only(TargetPlatform.linux);
void main() {
late ShellGateway gateway;
setUp(() => gateway = ShellGateway());
tearDown(() => gateway.close());
final field = find.byKey(const Key('chat-composer-field'));
final shellMode = find.byKey(const Key('chat-composer-shell-mode'));
testWidgets('a leading ! shows Shell mode and runs instead of sending', (
tester,
) async {
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
await tester.enterText(field, 'hello');
await tester.pump();
expect(shellMode, findsNothing);
await tester.enterText(field, '!git status');
await tester.pump();
expect(shellMode, findsOneWidget);
expect(find.text('Shell'), findsOneWidget);
expect(find.byTooltip('Run command'), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pump();
await tester.pump();
expect(gateway.bodies('chat_shell_run').single['command'], 'git status');
expect(gateway.calls.where((c) => c.type == 'chat_prompt'), isEmpty);
expect(shellMode, findsNothing, reason: 'the draft was consumed');
// The started run is drawn as a card at once.
expect(find.text('\$ git status'), findsOneWidget);
}, variant: _desktop);
testWidgets('a refused command keeps the draft and says why', (tester) async {
gateway.refusal = 'this chat already runs 4 commands';
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
await tester.enterText(field, '!sleep 9');
await tester.pump();
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pump();
await tester.pump();
expect(find.textContaining('already runs 4 commands'), findsOneWidget);
expect(shellMode, findsOneWidget);
expect(gateway.calls.where((c) => c.type == 'chat_prompt'), isEmpty);
});
testWidgets('a bare ! asks for a command and sends nothing', (tester) async {
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
await tester.enterText(field, '!');
await tester.pump();
await tester.tap(find.byKey(const Key('chat-composer-primary')));
await tester.pump();
expect(find.text('Type a command after !.'), findsOneWidget);
expect(gateway.bodies('chat_shell_run'), isEmpty);
});
}