@@ -604,6 +604,18 @@ void main() {
604604 Subject <Poll > checkPoll (Message message) =>
605605 check (store.messages[message.id]).isNotNull ().poll.isNotNull ();
606606
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+
607619 group ('handleSubmessageEvent' , () {
608620 Future <Message > preparePollMessage ({
609621 String ? question,
@@ -640,6 +652,10 @@ void main() {
640652 }]);
641653 await messageList.fetchInitial ();
642654 checkNotifiedOnce ();
655+ pollNotifiedCount = 0 ;
656+ store.messages[message.id]! .poll! .addListener (() {
657+ pollNotifiedCount++ ;
658+ });
643659 return message;
644660 }
645661
@@ -671,7 +687,7 @@ void main() {
671687 // Invalid type for question
672688 'question' : 100 ,
673689 })));
674- checkNotifiedOnce ();
690+ checkPollNotNotified ();
675691 checkPoll (message).question.equals ('Old question' );
676692 });
677693
@@ -680,7 +696,7 @@ void main() {
680696 final message = await preparePollMessage (question: 'Old question' );
681697 await store.handleEvent (eg.submessageEvent (message.id, eg.selfUser.userId,
682698 content: PollQuestionEventSubmessage (question: 'New question' )));
683- checkNotifiedOnce ();
699+ checkPollNotifiedOnce ();
684700 checkPoll (message).question.equals ('New question' );
685701 });
686702
@@ -705,7 +721,7 @@ void main() {
705721 }) async {
706722 await store.handleEvent (eg.submessageEvent (message.id, sender.userId,
707723 content: PollNewOptionEventSubmessage (option: option, idx: idx)));
708- checkNotifiedOnce ();
724+ checkPollNotifiedOnce ();
709725 }
710726
711727 test ('add option' , () async {
@@ -743,7 +759,7 @@ void main() {
743759 Future <void > handleVoteEvent (String key, PollVoteOp op, User voter) async {
744760 await store.handleEvent (eg.submessageEvent (message.id, voter.userId,
745761 content: PollVoteEventSubmessage (key: key, op: op)));
746- checkNotifiedOnce ();
762+ checkPollNotifiedOnce ();
747763 }
748764
749765 test ('add votes' , () async {
@@ -821,9 +837,11 @@ void main() {
821837 message = await preparePollMessage (
822838 options: [eg.pollOption (text: 'foo' , voters: [])]);
823839 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 ();
827845 checkPoll (message).options.deepEquals ([conditionPollOption ('foo' )]);
828846 });
829847 });
0 commit comments