mirror of
https://github.com/foss42/apidash.git
synced 2025-12-05 12:34:26 +08:00
56 lines
1.5 KiB
Dart
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();
|
|
}
|
|
}
|