@@ -373,6 +373,95 @@ void main() {
373
373
},
374
374
);
375
375
376
+ testWidgets (
377
+ 'Test that is possible to add a audio message with file attachments too' ,
378
+ (WidgetTester tester) async {
379
+ final client = MockClient ();
380
+ final clientState = MockClientState ();
381
+ final channel = MockChannel ();
382
+ final channelState = MockChannelState ();
383
+ final lastMessageAt = DateTime .parse ('2020-06-22 12:00:00' );
384
+
385
+ when (() => client.state).thenReturn (clientState);
386
+ when (() => clientState.currentUser).thenReturn (OwnUser (id: 'user-id' ));
387
+ when (() => channel.lastMessageAt).thenReturn (lastMessageAt);
388
+ when (() => channel.state).thenReturn (channelState);
389
+ when (() => channel.client).thenReturn (client);
390
+ when (() => channel.isMuted).thenReturn (false );
391
+ when (() => channel.isMutedStream).thenAnswer ((i) => Stream .value (false ));
392
+ when (() => channel.extraDataStream).thenAnswer (
393
+ (i) => Stream .value ({
394
+ 'name' : 'test' ,
395
+ }),
396
+ );
397
+ when (() => channel.extraData).thenReturn ({
398
+ 'name' : 'test' ,
399
+ });
400
+ when (() => channelState.membersStream).thenAnswer (
401
+ (i) => Stream .value ([
402
+ Member (
403
+ userId: 'user-id' ,
404
+ user: User (id: 'user-id' ),
405
+ )
406
+ ]),
407
+ );
408
+ when (() => channelState.members).thenReturn ([
409
+ Member (
410
+ userId: 'user-id' ,
411
+ user: User (id: 'user-id' ),
412
+ ),
413
+ ]);
414
+ when (() => channelState.messages).thenReturn ([
415
+ Message (
416
+ text: 'hello' ,
417
+ user: User (id: 'other-user' ),
418
+ )
419
+ ]);
420
+ when (() => channelState.messagesStream).thenAnswer (
421
+ (i) => Stream .value ([
422
+ Message (
423
+ text: 'hello' ,
424
+ user: User (id: 'other-user' ),
425
+ )
426
+ ]),
427
+ );
428
+
429
+ final messageInputController = StreamMessageInputController ();
430
+
431
+ await tester.pumpWidget (MaterialApp (
432
+ home: StreamChat (
433
+ client: client,
434
+ child: StreamChannel (
435
+ channel: channel,
436
+ child: Scaffold (
437
+ body: StreamMessageInput (
438
+ enableAudioRecord: false ,
439
+ messageInputController: messageInputController,
440
+ ),
441
+ ),
442
+ ),
443
+ ),
444
+ ));
445
+
446
+ messageInputController.attachments += [
447
+ Attachment (type: 'audio_recording' ),
448
+ Attachment (type: 'file' ),
449
+ ];
450
+
451
+ await tester.pump ();
452
+
453
+ expect (
454
+ find.byWidgetPredicate ((widget) => widget is AudioPlayerComposeMessage ),
455
+ findsOneWidget,
456
+ );
457
+
458
+ expect (
459
+ find.byWidgetPredicate ((widget) => widget is StreamFileAttachment ),
460
+ findsOneWidget,
461
+ );
462
+ },
463
+ );
464
+
376
465
testWidgets (
377
466
'Test that start the audio input correctly appears' ,
378
467
(WidgetTester tester) async {
0 commit comments