@@ -10,6 +10,7 @@ import 'package:zulip/api/model/model.dart';
10
10
import 'package:zulip/api/route/messages.dart' ;
11
11
import 'package:zulip/model/binding.dart' ;
12
12
import 'package:zulip/model/compose.dart' ;
13
+ import 'package:zulip/model/internal_link.dart' ;
13
14
import 'package:zulip/model/localizations.dart' ;
14
15
import 'package:zulip/model/narrow.dart' ;
15
16
import 'package:zulip/model/store.dart' ;
@@ -439,6 +440,42 @@ void main() {
439
440
});
440
441
});
441
442
443
+ group ('CopyMessageLinkButton' , () {
444
+ setUp (() async {
445
+ TestDefaultBinaryMessengerBinding .instance.defaultBinaryMessenger.setMockMethodCallHandler (
446
+ SystemChannels .platform,
447
+ MockClipboard ().handleMethodCall,
448
+ );
449
+ });
450
+
451
+ Future <void > tapCopyMessageLinkButton (WidgetTester tester) async {
452
+ await tester.ensureVisible (find.byIcon (Icons .link, skipOffstage: false ));
453
+ await tester.tap (find.byIcon (Icons .link));
454
+ await tester.pump (); // [MenuItemButton.onPressed] called in a post-frame callback: flutter/flutter@e4a39fa2e
455
+ }
456
+
457
+ testWidgets ('copies message link to clipboard' , (tester) async {
458
+ testBinding.deviceInfoResult = IosDeviceInfo (systemVersion: '16.0' );
459
+
460
+ final message = eg.streamMessage ();
461
+ final narrow = TopicNarrow .ofMessage (message);
462
+ await setupToMessageActionSheet (tester, message: message, narrow: narrow);
463
+ final store = await testBinding.globalStore.perAccount (eg.selfAccount.id);
464
+
465
+ await tapCopyMessageLinkButton (tester);
466
+ await tester.pump (Duration .zero);
467
+ final expectedLink = narrowLink (store, narrow, nearMessageId: message.id).toString ();
468
+ check (await Clipboard .getData ('text/plain' )).isNotNull ().text.equals (expectedLink);
469
+
470
+ final snackbar = tester.widget <SnackBar >(find.byType (SnackBar ));
471
+ check (snackbar.behavior).equals (SnackBarBehavior .floating);
472
+ final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
473
+ tester.widget (find.descendant (matchRoot: true ,
474
+ of: find.byWidget (snackbar.content),
475
+ matching: find.text (zulipLocalizations.successMessageLinkCopied)));
476
+ });
477
+ });
478
+
442
479
group ('ShareButton' , () {
443
480
// Tests should call this.
444
481
MockSharePlus setupMockSharePlus () {
@@ -481,7 +518,7 @@ void main() {
481
518
check (mockSharePlus.sharedString).equals ('Hello world' );
482
519
await tester.pump ();
483
520
await tester.tap (find.byWidget (checkErrorDialog (tester,
484
- expectedTitle: 'Sharing failed' )));
521
+ expectedTitle: 'Sharing failed' )));
485
522
});
486
523
487
524
testWidgets ('request has an error' , (WidgetTester tester) async {
0 commit comments