fix(chat): fix ChatBloc event callback and test reliability
- Fix onEvent callback initialization in ChatBloc constructor - Add MockAgUiService to isolate test from mock API behavior - Remove unnecessary non-null assertions in tests
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../data/models/ag_ui_event.dart';
|
||||
import '../../data/models/chat_list_item.dart';
|
||||
import '../../data/models/tool_result.dart';
|
||||
import '../../data/services/ag_ui_service.dart';
|
||||
|
||||
class ChatState {
|
||||
final List<ChatListItem> items;
|
||||
@@ -38,20 +39,12 @@ class ChatState {
|
||||
}
|
||||
}
|
||||
|
||||
class AgUiService {
|
||||
void Function(AgUiEvent)? onEvent;
|
||||
|
||||
AgUiService({this.onEvent});
|
||||
|
||||
Future<void> sendMessage(String content) async {}
|
||||
}
|
||||
|
||||
class ChatBloc extends Cubit<ChatState> {
|
||||
final AgUiService _service;
|
||||
final Map<String, String> _toolCallArgsBuffer = {};
|
||||
|
||||
ChatBloc({AgUiService? service})
|
||||
: _service = service ?? AgUiService(onEvent: (_) {}),
|
||||
: _service = service ?? AgUiService(),
|
||||
super(const ChatState()) {
|
||||
_service.onEvent = _handleEvent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user