@@ -70,13 +70,18 @@ void _publicationTests() {
7070 });
7171 }
7272
73- for (final switchCommunity in [false , true ]) {
73+ for (final (boundary, switchCommunity) in [
74+ for (final boundary in ['reader' , 'scan' , 'scan error' , 'prompt' ])
75+ for (final change in [false , true ]) (boundary, change),
76+ ]) {
7477 testWidgets (
75- 'authorization cancellation reports scope change only: $switchCommunity ' ,
78+ 'authorization cancellation $ boundary reports scope change only: $switchCommunity ' ,
7679 (tester) async {
7780 final key = 'd' * 64 ;
7881 final signer = nostr.Keys .generate ();
7982 final pending = Completer <List <AgentDirectoryEntry >>();
83+ final members = Completer <List <ChannelMember >>();
84+ var scanPending = false ;
8085 var reads = 0 ;
8186 var sent = 0 ;
8287 await tester.pumpWidget (
@@ -86,9 +91,27 @@ void _publicationTests() {
8691 relayConfig: () => _SwitchableRelayConfigNotifier (
8792 RelayConfig (baseUrl: 'https://relay.example' , nsec: signer.nsec),
8893 ),
94+ membersLoader: () => boundary == 'prompt'
95+ ? Future .value (
96+ scanPending
97+ ? []
98+ : [
99+ ChannelMember (
100+ pubkey: 'a' * 64 ,
101+ displayName: 'Alice' ,
102+ role: 'member' ,
103+ joinedAt: DateTime (2025 ),
104+ ),
105+ ],
106+ )
107+ : scanPending
108+ ? members.future
109+ : Future .value ([]),
89110 relayAgents: [_testAgent (key)],
90111 channels: [
91- _makeCurrentChannel (channelType: 'dm' ),
112+ _makeCurrentChannel (
113+ channelType: boundary == 'reader' ? 'dm' : 'stream' ,
114+ ),
92115 _makeSharedMemberChannel (),
93116 ],
94117 authorizationReader: (_, _, _, _) {
@@ -105,17 +128,45 @@ void _publicationTests() {
105128 await tester.pumpAndSettle ();
106129 await tester.tap (find.text ('Helper Bot' ));
107130 await tester.pumpAndSettle ();
108- await tester.enterText (find.byType (TextField ), 'hello @Helper Bot' );
131+ if (boundary == 'prompt' ) {
132+ await tester.enterText (find.byType (TextField ), '@Helper Bot @ali' );
133+ await tester.pumpAndSettle ();
134+ await tester.tap (find.text ('Alice' ));
135+ await tester.pumpAndSettle ();
136+ } else {
137+ await tester.enterText (find.byType (TextField ), 'hello @Helper Bot' );
138+ }
139+ final controller = tester
140+ .widget <TextField >(find.byType (TextField ))
141+ .controller! ;
142+ if (boundary != 'reader' ) {
143+ scanPending = true ;
144+ ProviderScope .containerOf (
145+ tester.element (find.byType (ComposeBar )),
146+ ).invalidate (channelMembersProvider ('channel-1' ));
147+ await tester.pump ();
148+ }
109149 await tester.tap (find.byIcon (LucideIcons .arrowUp));
110150 await tester.pump ();
111- expect (reads, 1 );
151+ expect (reads, boundary == 'reader' ? 1 : 0 );
152+ if (boundary == 'prompt' ) {
153+ await tester.pump (const Duration (milliseconds: 300 ));
154+ }
112155 if (switchCommunity) {
113156 ProviderScope .containerOf (tester.element (find.byType (ComposeBar )))
114157 .read (relayConfigProvider.notifier)
115158 .update (baseUrl: 'https://other.example' , nsec: signer.nsec);
116159 await tester.pump ();
117160 } else {
118- await tester.enterText (find.byType (TextField ), 'new intent' );
161+ controller.text = 'new intent' ;
162+ }
163+ if (boundary == 'prompt' ) {
164+ await tester.tap (find.text ('Invite' ));
165+ }
166+ if (boundary == 'scan error' ) {
167+ members.completeError (StateError ('scan unavailable' ));
168+ } else if (boundary == 'scan' ) {
169+ members.complete ([]);
119170 }
120171 pending.complete ([
121172 AgentDirectoryEntry (
@@ -131,10 +182,7 @@ void _publicationTests() {
131182 switchCommunity ? findsOneWidget : findsNothing,
132183 );
133184 expect (find.textContaining ('Could not authorize' ), findsNothing);
134- expect (
135- tester.widget <TextField >(find.byType (TextField )).controller! .text,
136- switchCommunity ? '' : 'new intent' ,
137- );
185+ expect (controller.text, switchCommunity ? '' : 'new intent' );
138186 },
139187 );
140188 }
0 commit comments