Skip to content

Commit 334e77f

Browse files
compose: Configure text controller to append generated video chat url
1 parent e33a670 commit 334e77f

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

lib/widgets/compose_box.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,11 @@ class _AttachVideoChatUrlButton extends StatelessWidget {
10671067
final placeholder = _getMeetingUrl(zulipLocalizations,
10681068
store.realmVideoChatProvider, store.jitsiServerUrl);
10691069
if (placeholder == null) return;
1070+
1071+
final contentController = controller.content;
1072+
final insertionRange = contentController.insertionIndex();
1073+
contentController.value = contentController.value.replaced(insertionRange, '$placeholder\n\n');
1074+
controller.contentFocusNode.requestFocus();
10701075
}
10711076

10721077
@override

test/widgets/compose_box_test.dart

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ void main() {
6363
List<Subscription> subscriptions = const [],
6464
List<Message>? messages,
6565
bool? mandatoryTopics,
66+
int? realmVideoChatProvider,
67+
String? jitsiServerUrl,
6668
int? zulipFeatureLevel,
6769
}) async {
6870
streams ??= subscriptions;
@@ -89,6 +91,8 @@ void main() {
8991
subscriptions: subscriptions,
9092
zulipFeatureLevel: zulipFeatureLevel,
9193
realmMandatoryTopics: mandatoryTopics,
94+
realmVideoChatProvider: realmVideoChatProvider,
95+
jitsiServerUrl: jitsiServerUrl,
9296
realmAllowMessageEditing: true,
9397
realmMessageContentEditLimitSeconds: null,
9498
));
@@ -1037,6 +1041,54 @@ void main() {
10371041
});
10381042
});
10391043

1044+
group('video call button', () {
1045+
Future<void> prepare(WidgetTester tester, {
1046+
String? jitsiServerUrl,
1047+
int? realmVideoChatProvider,
1048+
}) async {
1049+
TypingNotifier.debugEnable = false;
1050+
addTearDown(TypingNotifier.debugReset);
1051+
1052+
final channel = eg.stream();
1053+
final narrow = ChannelNarrow(channel.streamId);
1054+
await prepareComposeBox(tester,
1055+
narrow: narrow,
1056+
streams: [channel],
1057+
jitsiServerUrl : jitsiServerUrl,
1058+
realmVideoChatProvider : realmVideoChatProvider,
1059+
);
1060+
1061+
await enterTopic(tester, narrow: narrow, topic: 'some topic');
1062+
await tester.pump();
1063+
}
1064+
1065+
group('attach video call link', () {
1066+
testWidgets('jitsi success', (tester) async {
1067+
await prepare(tester);
1068+
connection.prepare();
1069+
1070+
await tester.tap(find.byIcon(ZulipIcons.video));
1071+
await tester.pump();
1072+
1073+
check(controller!.content.text)
1074+
..startsWith('[Join video call.](https://meet.jit.si')
1075+
..endsWith('#config.startWithVideoMuted=false)\n\n');
1076+
});
1077+
1078+
testWidgets('zoom success', (tester) async {
1079+
await prepare(tester, jitsiServerUrl: '',
1080+
realmVideoChatProvider: 2);
1081+
connection.prepare();
1082+
1083+
await tester.tap(find.byIcon(ZulipIcons.video));
1084+
await tester.pump();
1085+
1086+
check(controller!.content.text)
1087+
.equals('[Join video call.](https://zoom.us/start/meeting)\n\n');
1088+
});
1089+
});
1090+
});
1091+
10401092
group('uploads', () {
10411093
void checkAppearsLoading(WidgetTester tester, bool expected) {
10421094
final sendButtonElement = tester.element(find.ancestor(

0 commit comments

Comments
 (0)