@@ -540,21 +540,47 @@ void main() {
540
540
messageStyleMessages: [data1],
541
541
expectedIsGroupConversation: true ,
542
542
expectedTitle: '#${stream .name } > $topicA ' ,
543
- expectedTagComponent: 'stream:${stream .streamId }:$topicA ' );
543
+ expectedTagComponent: 'stream:${stream .streamId }:${ topicA . toLowerCase ()} ' );
544
544
545
545
receiveFcmMessage (async , data2);
546
546
checkNotification (data2,
547
547
messageStyleMessages: [data2],
548
548
expectedIsGroupConversation: true ,
549
549
expectedTitle: '#${stream .name } > $topicB ' ,
550
- expectedTagComponent: 'stream:${stream .streamId }:$topicB ' );
550
+ expectedTagComponent: 'stream:${stream .streamId }:${ topicB . toLowerCase ()} ' );
551
551
552
552
receiveFcmMessage (async , data3);
553
553
checkNotification (data3,
554
554
messageStyleMessages: [data1, data3],
555
555
expectedIsGroupConversation: true ,
556
556
expectedTitle: '#${stream .name } > $topicA ' ,
557
- expectedTagComponent: 'stream:${stream .streamId }:$topicA ' );
557
+ expectedTagComponent: 'stream:${stream .streamId }:${topicA .toLowerCase ()}' );
558
+ })));
559
+
560
+ test ('stream message: topic changes only case' , () => runWithHttpClient (() => awaitFakeAsync ((async ) async {
561
+ await init ();
562
+ final stream = eg.stream ();
563
+ const topic1 = 'A ToPic' ;
564
+ const topic2 = 'a TOpic' ;
565
+ final message1 = eg.streamMessage (topic: topic1, stream: stream);
566
+ final data1 = messageFcmMessage (message1, streamName: stream.name);
567
+ final message2 = eg.streamMessage (topic: topic2, stream: stream);
568
+ final data2 = messageFcmMessage (message2, streamName: stream.name);
569
+
570
+ receiveFcmMessage (async , data1);
571
+ checkNotification (data1,
572
+ messageStyleMessages: [data1],
573
+ expectedIsGroupConversation: true ,
574
+ expectedTitle: '#${stream .name } > $topic1 ' ,
575
+ expectedTagComponent: 'stream:${stream .streamId }:a topic' );
576
+
577
+ receiveFcmMessage (async , data2);
578
+ checkNotification (data2,
579
+ messageStyleMessages: [data1, data2],
580
+ expectedIsGroupConversation: true ,
581
+ // Title updates with latest casing of topic.
582
+ expectedTitle: '#${stream .name } > $topic2 ' ,
583
+ expectedTagComponent: 'stream:${stream .streamId }:a topic' );
558
584
})));
559
585
560
586
test ('stream message: conversation stays same when stream is renamed' , () => runWithHttpClient (() => awaitFakeAsync ((async ) async {
@@ -781,6 +807,7 @@ void main() {
781
807
final data2 = messageFcmMessage (message2, streamName: stream.name);
782
808
final message3 = eg.streamMessage (stream: stream, topic: topicA);
783
809
final data3 = messageFcmMessage (message3, streamName: stream.name);
810
+ final conversationKey = 'stream:${stream .streamId }:${topicA .toLowerCase ()}' ;
784
811
final expectedGroupKey = '${data1 .realmUrl }|${data1 .userId }' ;
785
812
786
813
check (testBinding.androidNotificationHost.activeNotifications).isEmpty ();
@@ -789,14 +816,14 @@ void main() {
789
816
receiveFcmMessage (async , data2);
790
817
receiveFcmMessage (async , data3);
791
818
check (testBinding.androidNotificationHost.activeNotifications).deepEquals (< Condition <Object ?>> [
792
- conditionActiveNotif (data3, 'stream:${ stream . streamId }:$ topicA ' ),
819
+ conditionActiveNotif (data3, conversationKey ),
793
820
conditionSummaryActiveNotif (expectedGroupKey),
794
821
]);
795
822
796
823
// A RemoveFcmMessage for the first two messages; the notification stays.
797
824
receiveFcmMessage (async , removeFcmMessage ([message1, message2]));
798
825
check (testBinding.androidNotificationHost.activeNotifications).deepEquals (< Condition <Object ?>> [
799
- conditionActiveNotif (data3, 'stream:${ stream . streamId }:$ topicA ' ),
826
+ conditionActiveNotif (data3, conversationKey ),
800
827
conditionSummaryActiveNotif (expectedGroupKey),
801
828
]);
802
829
@@ -808,30 +835,34 @@ void main() {
808
835
test ('remove: clears summary notification only if all conversation notifications are cleared' , () => runWithHttpClient (() => awaitFakeAsync ((async ) async {
809
836
await init ();
810
837
final stream = eg.stream ();
838
+
811
839
const topicA = 'Topic A' ;
812
840
final message1 = eg.streamMessage (stream: stream, topic: topicA);
813
841
final data1 = messageFcmMessage (message1, streamName: stream.name);
842
+ final conversationKey1 = 'stream:${stream .streamId }:${topicA .toLowerCase ()}' ;
843
+ final expectedGroupKey = '${data1 .realmUrl }|${data1 .userId }' ;
844
+
814
845
const topicB = 'Topic B' ;
815
846
final message2 = eg.streamMessage (stream: stream, topic: topicB);
816
847
final data2 = messageFcmMessage (message2, streamName: stream.name);
817
- final expectedGroupKey = '${ data1 . realmUrl }|${ data1 . userId }' ;
848
+ final conversationKey2 = 'stream:${ stream . streamId }:${ topicB . toLowerCase () }' ;
818
849
819
850
check (testBinding.androidNotificationHost.activeNotifications).isEmpty ();
820
851
821
852
// Two notifications for different conversations; but same account.
822
853
receiveFcmMessage (async , data1);
823
854
receiveFcmMessage (async , data2);
824
855
check (testBinding.androidNotificationHost.activeNotifications).deepEquals (< Condition <Object ?>> [
825
- conditionActiveNotif (data1, 'stream:${ stream . streamId }:$ topicA ' ),
856
+ conditionActiveNotif (data1, conversationKey1 ),
826
857
conditionSummaryActiveNotif (expectedGroupKey),
827
- conditionActiveNotif (data2, 'stream:${ stream . streamId }:$ topicB ' ),
858
+ conditionActiveNotif (data2, conversationKey2 ),
828
859
]);
829
860
830
861
// A RemoveFcmMessage for first conversation; only clears the first conversation notif.
831
862
receiveFcmMessage (async , removeFcmMessage ([message1]));
832
863
check (testBinding.androidNotificationHost.activeNotifications).deepEquals (< Condition <Object ?>> [
833
864
conditionSummaryActiveNotif (expectedGroupKey),
834
- conditionActiveNotif (data2, 'stream:${ stream . streamId }:$ topicB ' ),
865
+ conditionActiveNotif (data2, conversationKey2 ),
835
866
]);
836
867
837
868
// Then a RemoveFcmMessage for the only remaining conversation;
@@ -844,6 +875,7 @@ void main() {
844
875
await init ();
845
876
final stream = eg.stream ();
846
877
const topic = 'Some Topic' ;
878
+ final conversationKey = 'stream:${stream .streamId }:some topic' ;
847
879
848
880
final account1 = eg.account (
849
881
realmUrl: Uri .parse ('https://1.chat.example' ),
@@ -868,15 +900,15 @@ void main() {
868
900
receiveFcmMessage (async , data1);
869
901
receiveFcmMessage (async , data2);
870
902
check (testBinding.androidNotificationHost.activeNotifications).deepEquals (< Condition <Object ?>> [
871
- conditionActiveNotif (data1, 'stream:${ stream . streamId }:$ topic ' ),
903
+ conditionActiveNotif (data1, conversationKey ),
872
904
conditionSummaryActiveNotif (groupKey1),
873
- conditionActiveNotif (data2, 'stream:${ stream . streamId }:$ topic ' ),
905
+ conditionActiveNotif (data2, conversationKey ),
874
906
conditionSummaryActiveNotif (groupKey2),
875
907
]);
876
908
877
909
receiveFcmMessage (async , removeFcmMessage ([message1], account: account1));
878
910
check (testBinding.androidNotificationHost.activeNotifications).deepEquals (< Condition <Object ?>> [
879
- conditionActiveNotif (data2, 'stream:${ stream . streamId }:$ topic ' ),
911
+ conditionActiveNotif (data2, conversationKey ),
880
912
conditionSummaryActiveNotif (groupKey2),
881
913
]);
882
914
@@ -889,6 +921,7 @@ void main() {
889
921
final realmUrl = eg.realmUrl;
890
922
final stream = eg.stream ();
891
923
const topic = 'Some Topic' ;
924
+ final conversationKey = 'stream:${stream .streamId }:some topic' ;
892
925
893
926
final account1 = eg.account (id: 1001 , user: eg.user (userId: 1001 ), realmUrl: realmUrl);
894
927
final message1 = eg.streamMessage (id: 1000 , stream: stream, topic: topic);
@@ -907,15 +940,15 @@ void main() {
907
940
receiveFcmMessage (async , data1);
908
941
receiveFcmMessage (async , data2);
909
942
check (testBinding.androidNotificationHost.activeNotifications).deepEquals (< Condition <Object ?>> [
910
- conditionActiveNotif (data1, 'stream:${ stream . streamId }:$ topic ' ),
943
+ conditionActiveNotif (data1, conversationKey ),
911
944
conditionSummaryActiveNotif (groupKey1),
912
- conditionActiveNotif (data2, 'stream:${ stream . streamId }:$ topic ' ),
945
+ conditionActiveNotif (data2, conversationKey ),
913
946
conditionSummaryActiveNotif (groupKey2),
914
947
]);
915
948
916
949
receiveFcmMessage (async , removeFcmMessage ([message1], account: account1));
917
950
check (testBinding.androidNotificationHost.activeNotifications).deepEquals (< Condition <Object ?>> [
918
- conditionActiveNotif (data2, 'stream:${ stream . streamId }:$ topic ' ),
951
+ conditionActiveNotif (data2, conversationKey ),
919
952
conditionSummaryActiveNotif (groupKey2),
920
953
]);
921
954
0 commit comments