Files
apidash/test/dashbot/widgets/action_buttons/test_utils.dart
2025-09-25 18:46:16 +05:30

56 lines
1.5 KiB
Dart

import 'package:apidash/dashbot/core/model/chat_attachment.dart';
import 'package:apidash/dashbot/core/providers/dashbot_window_notifier.dart';
import 'package:apidash/dashbot/features/chat/models/chat_action.dart';
import 'package:apidash/dashbot/features/chat/viewmodel/chat_viewmodel.dart';
import 'package:apidash/dashbot/core/constants/constants.dart';
class TestChatViewmodel extends ChatViewmodel {
TestChatViewmodel(super.ref);
final List<ChatAction> applyAutoFixCalls = [];
final List<({String text, ChatMessageType type, bool countAsUser})>
sendMessageCalls = [];
final List<ChatAttachment> openApiAttachmentCalls = [];
bool throwOnApplyAutoFix = false;
@override
Future<void> applyAutoFix(ChatAction action) async {
applyAutoFixCalls.add(action);
if (throwOnApplyAutoFix) {
throw Exception('applyAutoFix error');
}
}
@override
Future<void> sendMessage({
required String text,
ChatMessageType type = ChatMessageType.general,
bool countAsUser = true,
}) async {
sendMessageCalls.add((text: text, type: type, countAsUser: countAsUser));
}
@override
Future<void> handleOpenApiAttachment(ChatAttachment att) async {
openApiAttachmentCalls.add(att);
}
}
class RecordingDashbotWindowNotifier extends DashbotWindowNotifier {
int hideCalls = 0;
int showCalls = 0;
@override
void hide() {
hideCalls += 1;
super.hide();
}
@override
void show() {
showCalls += 1;
super.show();
}
}