forked from eatvio/eatvio_app
Merge remote-tracking branch 'upstream/main' into issue-1062
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,77 @@
|
||||
import 'package:eatvio_app/features/chat/models/chat_message_model.dart';
|
||||
import 'package:eatvio_app/features/video_calls/services/video_call_chat_signal.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
ChatMessageModel message({
|
||||
String data = '',
|
||||
String? roomId = 'room-1',
|
||||
ChatMessageType? type,
|
||||
}) {
|
||||
return ChatMessageModel(
|
||||
id: 1,
|
||||
data: data,
|
||||
mediaData: null,
|
||||
authorId: 7,
|
||||
updatedAt: DateTime.utc(2026, 1, 1),
|
||||
isRead: false,
|
||||
isCurrentUserAuthor: false,
|
||||
roomId: roomId,
|
||||
type: type,
|
||||
);
|
||||
}
|
||||
|
||||
group('VideoCallChatSignal', () {
|
||||
test('recognizes a realtime video call start without type', () {
|
||||
final payload = VideoCallChatSignal.incomingPayload(
|
||||
message: message(data: 'Анна начал(а) видеозвонок.'),
|
||||
);
|
||||
|
||||
expect(payload, isNotNull);
|
||||
expect(payload!.conversationUuid, 'room-1');
|
||||
expect(payload.counterpartName, 'Анна');
|
||||
expect(payload.messageId, 1);
|
||||
});
|
||||
|
||||
test('recognizes an english realtime video call start', () {
|
||||
expect(
|
||||
VideoCallChatSignal.kindOf(message(data: 'Anna started a video call.')),
|
||||
VideoCallChatSignalKind.started,
|
||||
);
|
||||
});
|
||||
|
||||
test('recognizes a realtime video call end', () {
|
||||
expect(
|
||||
VideoCallChatSignal.kindOf(
|
||||
message(data: 'Анна завершил(а) видеозвонок.'),
|
||||
),
|
||||
VideoCallChatSignalKind.ended,
|
||||
);
|
||||
});
|
||||
|
||||
test('uses an explicit message type when the broadcast includes it', () {
|
||||
expect(
|
||||
VideoCallChatSignal.kindOf(
|
||||
message(data: 'ignored', type: ChatMessageType.videoCallStarted),
|
||||
),
|
||||
VideoCallChatSignalKind.started,
|
||||
);
|
||||
});
|
||||
|
||||
test('does not treat an ordinary chat message as a call', () {
|
||||
expect(
|
||||
VideoCallChatSignal.kindOf(
|
||||
message(
|
||||
data: 'я начал видеозвонок вручную',
|
||||
type: ChatMessageType.text,
|
||||
),
|
||||
),
|
||||
VideoCallChatSignalKind.none,
|
||||
);
|
||||
expect(
|
||||
VideoCallChatSignal.incomingPayload(message: message(data: 'привет')),
|
||||
isNull,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:eatvio_app/features/video_calls/services/video_call_ended_push_payload.dart';
|
||||
import 'package:eatvio_app/features/video_calls/services/video_call_kit_id.dart';
|
||||
import 'package:eatvio_app/features/video_calls/services/video_call_push_payload.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
@@ -58,6 +59,23 @@ void main() {
|
||||
expect(payload, isNotNull);
|
||||
});
|
||||
|
||||
test('parses message id for a stable CallKit uuid', () {
|
||||
final payload = VideoCallPushPayload.tryParse({
|
||||
'type': 'video_call_started',
|
||||
'conversation_uuid': '550e8400-e29b-41d4-a716-446655440000',
|
||||
'message_id': '42',
|
||||
});
|
||||
|
||||
expect(payload?.messageId, 42);
|
||||
expect(
|
||||
VideoCallKitId.iosUuid(
|
||||
conversationUuid: payload!.conversationUuid,
|
||||
messageId: payload.messageId,
|
||||
),
|
||||
'550e8400-e29b-41d4-a716-00000000002a',
|
||||
);
|
||||
});
|
||||
|
||||
test('ignores regular chat push', () {
|
||||
expect(
|
||||
VideoCallPushPayload.tryParse({
|
||||
|
||||
Reference in New Issue
Block a user