@@ -604,6 +604,18 @@ void main() {
604
604
Subject <Poll > checkPoll (Message message) =>
605
605
check (store.messages[message.id]).isNotNull ().poll.isNotNull ();
606
606
607
+ late int pollNotifiedCount;
608
+
609
+ void checkPollNotified ({required int count}) {
610
+ check (pollNotifiedCount).equals (count);
611
+ pollNotifiedCount = 0 ;
612
+ // This captures any unchecked [messageList] notifications, to verify
613
+ // that poll live-updates do not trigger broader rebuilds.
614
+ checkNotNotified ();
615
+ }
616
+ void checkPollNotNotified () => checkPollNotified (count: 0 );
617
+ void checkPollNotifiedOnce () => checkPollNotified (count: 1 );
618
+
607
619
group ('handleSubmessageEvent' , () {
608
620
Future <Message > preparePollMessage ({
609
621
String ? question,
@@ -640,6 +652,10 @@ void main() {
640
652
}]);
641
653
await messageList.fetchInitial ();
642
654
checkNotifiedOnce ();
655
+ pollNotifiedCount = 0 ;
656
+ store.messages[message.id]! .poll! .addListener (() {
657
+ pollNotifiedCount++ ;
658
+ });
643
659
return message;
644
660
}
645
661
@@ -671,7 +687,7 @@ void main() {
671
687
// Invalid type for question
672
688
'question' : 100 ,
673
689
})));
674
- checkNotifiedOnce ();
690
+ checkPollNotNotified ();
675
691
checkPoll (message).question.equals ('Old question' );
676
692
});
677
693
@@ -680,7 +696,7 @@ void main() {
680
696
final message = await preparePollMessage (question: 'Old question' );
681
697
await store.handleEvent (eg.submessageEvent (message.id, eg.selfUser.userId,
682
698
content: PollQuestionEventSubmessage (question: 'New question' )));
683
- checkNotifiedOnce ();
699
+ checkPollNotifiedOnce ();
684
700
checkPoll (message).question.equals ('New question' );
685
701
});
686
702
@@ -705,7 +721,7 @@ void main() {
705
721
}) async {
706
722
await store.handleEvent (eg.submessageEvent (message.id, sender.userId,
707
723
content: PollNewOptionEventSubmessage (option: option, idx: idx)));
708
- checkNotifiedOnce ();
724
+ checkPollNotifiedOnce ();
709
725
}
710
726
711
727
test ('add option' , () async {
@@ -743,7 +759,7 @@ void main() {
743
759
Future <void > handleVoteEvent (String key, PollVoteOp op, User voter) async {
744
760
await store.handleEvent (eg.submessageEvent (message.id, voter.userId,
745
761
content: PollVoteEventSubmessage (key: key, op: op)));
746
- checkNotifiedOnce ();
762
+ checkPollNotifiedOnce ();
747
763
}
748
764
749
765
test ('add votes' , () async {
@@ -821,9 +837,11 @@ void main() {
821
837
message = await preparePollMessage (
822
838
options: [eg.pollOption (text: 'foo' , voters: [])]);
823
839
checkPoll (message).options.deepEquals ([conditionPollOption ('foo' )]);
824
- await handleVoteEvent (
825
- PollEventSubmessage .optionKey (senderId: null , idx: 0 ),
826
- PollVoteOp .unknown, eg.otherUser);
840
+ await store.handleEvent (eg.submessageEvent (message.id, eg.otherUser.userId,
841
+ content: PollVoteEventSubmessage (
842
+ key: PollEventSubmessage .optionKey (senderId: null , idx: 0 ),
843
+ op: PollVoteOp .unknown)));
844
+ checkPollNotNotified ();
827
845
checkPoll (message).options.deepEquals ([conditionPollOption ('foo' )]);
828
846
});
829
847
});
0 commit comments