import 'package:agent_shell/agent_shell.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('submits composer text', (tester) async { String? submitted; await tester.pumpWidget( MaterialApp( home: Scaffold( body: AgentShell( messages: const [], onSubmit: (text) => submitted = text, ), ), ), ); await tester.enterText(find.byType(TextField), 'hello'); await tester.tap(find.byIcon(Icons.send)); await tester.pump(); expect(submitted, 'hello'); }); testWidgets('emits approval action for tool calls', (tester) async { AgentToolAction? action; await tester.pumpWidget( MaterialApp( home: Scaffold( body: AgentShell( messages: const [ AgentMessage( id: 'm1', role: AgentMessageRole.assistant, text: 'I need approval.', toolCalls: [ AgentToolCall( id: 'tool-1', name: 'restart-node', status: AgentToolCallStatus.awaitingApproval, summary: 'Restart a node', ), ], ), ], onToolAction: (next) => action = next, ), ), ), ); await tester.tap(find.text('Approve')); await tester.pump(); expect(action?.toolCallId, 'tool-1'); expect(action?.type, AgentToolActionType.approve); }); }