1
+ import 'package:flutter_test/flutter_test.dart' ;
2
+ import 'package:model/email/prefix_email_address.dart' ;
3
+ import 'package:core/presentation/resources/image_paths.dart' ;
4
+ import 'package:tmail_ui_user/features/mailbox/presentation/mailbox_view.dart' ;
5
+ import 'package:tmail_ui_user/features/composer/presentation/composer_view.dart' ;
6
+ import 'package:tmail_ui_user/main/localizations/app_localizations.dart' ;
7
+
8
+ import '../../base/base_test_scenario.dart' ;
9
+ import '../../robots/composer_robot.dart' ;
10
+ import '../../robots/mailbox_menu_robot.dart' ;
11
+ import '../../robots/thread_robot.dart' ;
12
+
13
+ class TeamMailboxReceiveEmailScenario extends BaseTestScenario {
14
+ const TeamMailboxReceiveEmailScenario (super .$);
15
+
16
+ @override
17
+ Future <void > runTestLogic () async {
18
+ const teamMailboxName = 'bob-guests' ;
19
+ const teamMailboxEmail = '$teamMailboxName @example.com' ;
20
+ const subject = 'email to team mailbox' ;
21
+
22
+ final threadRobot = ThreadRobot ($);
23
+ final composerRobot = ComposerRobot ($);
24
+ final mailboxMenuRobot = MailboxMenuRobot ($);
25
+ final imagePaths = ImagePaths ();
26
+ final appLocalizations = AppLocalizations ();
27
+
28
+ await threadRobot.openMailbox ();
29
+ await _expectMailboxViewVisible ();
30
+ await _expectTeamMailboxVisible (teamMailboxName);
31
+
32
+ await mailboxMenuRobot.closeMenu ();
33
+ await threadRobot.openComposer ();
34
+ await _expectComposerViewVisible ();
35
+ await composerRobot.grantContactPermission ();
36
+ await composerRobot.addRecipientIntoField (
37
+ prefixEmailAddress: PrefixEmailAddress .to,
38
+ email: teamMailboxEmail,
39
+ );
40
+ await composerRobot.addSubject (subject);
41
+ await composerRobot.sendEmail (imagePaths);
42
+ await _expectSendEmailSuccessToast (appLocalizations);
43
+ await $.pump (const Duration (seconds: 2 ));
44
+
45
+ await threadRobot.openMailbox ();
46
+ await mailboxMenuRobot.expandMailboxWithName (teamMailboxName);
47
+ await mailboxMenuRobot.openFolderByName (appLocalizations.inboxMailboxDisplayName.toUpperCase ());
48
+ await _expectEmailWithSubjectVisible (subject);
49
+ }
50
+
51
+ Future <void > _expectMailboxViewVisible () async {
52
+ await expectViewVisible ($(MailboxView ));
53
+ }
54
+
55
+ Future <void > _expectTeamMailboxVisible (String name) async {
56
+ await $.scrollUntilVisible (finder: $(name));
57
+ await expectViewVisible ($(name));
58
+ }
59
+
60
+ Future <void > _expectComposerViewVisible () async {
61
+ await expectViewVisible ($(ComposerView ));
62
+ }
63
+
64
+ Future <void > _expectSendEmailSuccessToast (AppLocalizations appLocalizations) async {
65
+ await expectViewVisible (
66
+ $(find.text (appLocalizations.message_has_been_sent_successfully)),
67
+ );
68
+ }
69
+
70
+ Future <void > _expectEmailWithSubjectVisible (String subject) async {
71
+ await expectViewVisible ($(subject));
72
+ }
73
+ }
0 commit comments