diff --git a/mobile/test/features/channels/compose_bar_test.dart b/mobile/test/features/channels/compose_bar_test.dart index 6718aa47f6..284c751956 100644 --- a/mobile/test/features/channels/compose_bar_test.dart +++ b/mobile/test/features/channels/compose_bar_test.dart @@ -3231,12 +3231,15 @@ void main() { final signer = nostr.Keys.generate(); final publishedEvents = >[]; final uploadResponse = Completer(); + var uploadStarted = false; + var sends = 0; final uploadService = MediaUploadService( baseUrl: 'https://relay.example', nsec: signer.nsec, - httpClient: http_testing.MockClient( - (request) => uploadResponse.future, - ), + httpClient: http_testing.MockClient((request) { + uploadStarted = true; + return uploadResponse.future; + }), pickGalleryVideo: () async => null, pickGalleryImage: () async => null, pickGalleryImages: () async => [ @@ -3250,7 +3253,9 @@ void main() { currentPubkey: signer.public, relayAgents: [_testAgent(agentPubkey)], channels: [_makeCurrentChannel(), _makeSharedMemberChannel()], - onSend: (_, _, {mediaTags = const >[]}) async {}, + onSend: (_, _, {mediaTags = const >[]}) async { + sends += 1; + }, ), ); @@ -3271,7 +3276,12 @@ void main() { await tester.pumpAndSettle(); await tester.tap(find.text('Helper Bot')); await tester.pumpAndSettle(); - await tester.enterText(find.byType(TextField), 'hello @Helper Bot'); + await tester.enterText(find.byType(TextField), 'hello @Helper Bot '); + await tester.pumpAndSettle(); + final submittedText = tester + .widget(find.byType(TextField)) + .controller! + .text; await tester.tap(find.byIcon(LucideIcons.arrowUp)); await tester.pump(); @@ -3281,6 +3291,7 @@ void main() { ); await tester.pump(const Duration(milliseconds: 220)); + expect(uploadStarted, isTrue); await tester.tap(find.byKey(const ValueKey('compose-upload-cancel'))); uploadResponse.complete( http.Response( @@ -3303,8 +3314,13 @@ void main() { ); expect( tester.widget(find.byType(TextField)).controller!.text, - 'hello @Helper Bot', + submittedText, ); + expect(sends, 0); + // Restoring the draft can start a new autocomplete debounce. Dispose + // its owner before draining fake time; do not leak a timer to teardown. + await tester.pumpWidget(const SizedBox.shrink()); + await tester.pump(const Duration(milliseconds: 300)); }, );