|
| 1 | +import time |
| 2 | +from datetime import datetime |
| 3 | +from copy import deepcopy |
| 4 | + |
1 | 5 | import allure |
2 | 6 | import pytest |
3 | 7 | from allure import step |
4 | 8 |
|
| 9 | +import configs |
5 | 10 | import constants |
6 | | -from driver.aut import AUT |
| 11 | +import driver |
| 12 | +from constants import UserAccount |
7 | 13 | from gui.components.changes_detected_popup import ChangesDetectedToastMessage |
8 | 14 | from gui.main_window import MainWindow |
9 | 15 | from . import marks |
@@ -33,49 +39,116 @@ def test_change_own_display_name(main_screen: MainWindow, user_account, new_name |
33 | 39 |
|
34 | 40 |
|
35 | 41 | @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703002', 'Switch state to offline') |
36 | | -@pytest.mark.case(703002) |
37 | | -@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/149") |
38 | | -def test_switch_states_between_offline_and_online(aut: AUT, main_screen: MainWindow, user_account): |
39 | | - with (step('Open settings and switch state to offline')): |
40 | | - settings = main_screen.left_panel |
41 | | - settings.set_user_to_offline() |
42 | | - |
43 | | - with step('Verify user appears offline'): |
44 | | - assert settings.user_is_offline() |
45 | | - |
46 | | - with step('Restart application'): |
47 | | - aut.restart() |
48 | | - main_screen.authorize_user(user_account) |
49 | | - |
50 | | - with step('Verify user appears offline'): |
51 | | - assert settings.user_is_offline() |
52 | | - |
53 | | - with (step('Open settings and switch state to online')): |
54 | | - settings = main_screen.left_panel |
55 | | - settings.set_user_to_online() |
56 | | - |
57 | | - with step('Restart application'): |
58 | | - aut.restart() |
59 | | - main_screen.authorize_user(user_account) |
60 | | - |
61 | | - with step('Verify user appears online'): |
62 | | - assert settings.user_is_online() |
63 | | - |
64 | | - |
| 42 | +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703003', 'Switch state to online') |
65 | 43 | @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703004', 'Switch state to automatic') |
66 | | -@pytest.mark.case(703004) |
67 | | -@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/149") |
68 | | -def test_switch_state_to_automatic(aut: AUT, main_screen: MainWindow, user_account): |
69 | | - with step('Open settings and switch state to automatic'): |
70 | | - settings = main_screen.left_panel |
71 | | - settings.set_user_to_automatic() |
72 | | - |
73 | | - with step('Verify user status set automatically to online'): |
74 | | - assert settings.user_is_set_to_automatic() |
75 | | - |
76 | | - with step('Restart application'): |
77 | | - aut.restart() |
78 | | - main_screen.authorize_user(user_account) |
79 | | - |
80 | | - with step('Verify user status set automatically to online'): |
81 | | - assert settings.user_is_set_to_automatic() |
| 44 | +@pytest.mark.case(703002, 703003, 703004) |
| 45 | +@pytest.mark.parametrize('user_data_one, user_data_two', [ |
| 46 | + (configs.testpath.TEST_USER_DATA / 'user_account_one', configs.testpath.TEST_USER_DATA / 'user_account_two') |
| 47 | +]) |
| 48 | +def test_switch_state_to_offline_online_automatic(multiple_instance, user_data_one, user_data_two): |
| 49 | + user_one: UserAccount = constants.user_account_one |
| 50 | + user_two: UserAccount = constants.user_account_two |
| 51 | + community_params = deepcopy(constants.community_params) |
| 52 | + community_params['name'] = f'{datetime.now():%d%m%Y_%H%M%S}' |
| 53 | + main_screen = MainWindow() |
| 54 | + |
| 55 | + with multiple_instance() as aut_one, multiple_instance() as aut_two: |
| 56 | + with step(f'Launch multiple instances with authorized users {user_one.name} and {user_two.name}'): |
| 57 | + for aut, account in zip([aut_one, aut_two], [user_one, user_two]): |
| 58 | + aut.attach() |
| 59 | + main_screen.wait_until_appears(configs.timeouts.APP_LOAD_TIMEOUT_MSEC).prepare() |
| 60 | + main_screen.authorize_user(account) |
| 61 | + main_screen.hide() |
| 62 | + |
| 63 | + with step(f'User {user_two.name}, get chat key'): |
| 64 | + aut_two.attach() |
| 65 | + main_screen.prepare() |
| 66 | + profile_popup = main_screen.left_panel.open_online_identifier().open_profile_popup_from_online_identifier() |
| 67 | + chat_key = profile_popup.copy_chat_key |
| 68 | + profile_popup.close() |
| 69 | + main_screen.hide() |
| 70 | + |
| 71 | + with step(f'User {user_one.name}, send contact request to {user_two.name}'): |
| 72 | + aut_one.attach() |
| 73 | + main_screen.prepare() |
| 74 | + settings = main_screen.left_panel.open_settings() |
| 75 | + messaging_settings = settings.left_panel.open_messaging_settings() |
| 76 | + contacts_settings = messaging_settings.open_contacts_settings() |
| 77 | + contact_request_popup = contacts_settings.open_contact_request_form() |
| 78 | + contact_request_popup.send(chat_key, f'Hello {user_two.name}') |
| 79 | + main_screen.hide() |
| 80 | + |
| 81 | + with step(f'User {user_two.name}, accept contact request from {user_one.name}'): |
| 82 | + aut_two.attach() |
| 83 | + main_screen.prepare() |
| 84 | + settings = main_screen.left_panel.open_settings() |
| 85 | + messaging_settings = settings.left_panel.open_messaging_settings() |
| 86 | + contacts_settings = messaging_settings.open_contacts_settings() |
| 87 | + contacts_settings.accept_contact_request(user_one.name) |
| 88 | + |
| 89 | + with step(f'User {user_two.name}, create community and invite {user_one.name}'): |
| 90 | + main_screen.create_community(community_params['name'], community_params['description'], |
| 91 | + community_params['intro'], community_params['outro'], |
| 92 | + community_params['logo']['fp'], community_params['banner']['fp']) |
| 93 | + main_screen.left_panel.invite_people_in_community([user_one.name], 'Message', community_params['name']) |
| 94 | + main_screen.hide() |
| 95 | + |
| 96 | + with step(f'User {user_one.name}, accept invitation from {user_two.name}'): |
| 97 | + aut_one.attach() |
| 98 | + main_screen.prepare() |
| 99 | + messages_view = main_screen.left_panel.open_messages_screen() |
| 100 | + chat = messages_view.left_panel.open_chat(user_two.name) |
| 101 | + community_screen = chat.accept_community_invite(community_params['name'], '0') |
| 102 | + |
| 103 | + with step(f'User {user_one.name}, verify welcome community popup'): |
| 104 | + welcome_popup = community_screen.left_panel.open_welcome_community_popup() |
| 105 | + assert community_params['name'] in welcome_popup.title |
| 106 | + assert community_params['intro'] == welcome_popup.intro |
| 107 | + welcome_popup.join().authenticate(user_two.password) |
| 108 | + welcome_popup.share_address() |
| 109 | + assert driver.waitFor(lambda: not community_screen.left_panel.is_join_community_visible, |
| 110 | + configs.timeouts.UI_LOAD_TIMEOUT_MSEC), 'Join community button not hidden' |
| 111 | + main_screen.hide() |
| 112 | + |
| 113 | + with step(f'User {user_two.name}, switch state to offline'): |
| 114 | + aut_two.attach() |
| 115 | + main_screen.prepare() |
| 116 | + settings = main_screen.left_panel |
| 117 | + settings.set_user_to_offline() |
| 118 | + main_screen.hide() |
| 119 | + |
| 120 | + with step(f'User {user_one.name}, sees {user_two.name} as offline'): |
| 121 | + aut_one.attach() |
| 122 | + main_screen.prepare() |
| 123 | + assert community_screen.right_panel.member_is_offline(1) |
| 124 | + main_screen.hide() |
| 125 | + |
| 126 | + with step(f'User {user_two.name}, switch state to online'): |
| 127 | + aut_two.attach() |
| 128 | + main_screen.prepare() |
| 129 | + settings = main_screen.left_panel |
| 130 | + settings.set_user_to_online() |
| 131 | + main_screen.hide() |
| 132 | + |
| 133 | + with step(f'User {user_one.name}, sees {user_two.name} as online'): |
| 134 | + aut_one.attach() |
| 135 | + main_screen.prepare() |
| 136 | + time.sleep(2) |
| 137 | + assert community_screen.right_panel.member_is_online(1) |
| 138 | + main_screen.hide() |
| 139 | + |
| 140 | + with step(f'User {user_two.name}, switch state to automatic'): |
| 141 | + aut_two.attach() |
| 142 | + main_screen.prepare() |
| 143 | + settings = main_screen.left_panel |
| 144 | + settings.set_user_to_automatic() |
| 145 | + |
| 146 | + with step('Verify user status set automatically to online'): |
| 147 | + assert settings.user_is_online() |
| 148 | + main_screen.hide() |
| 149 | + |
| 150 | + with step(f'User {user_one.name}, sees {user_two.name} as online'): |
| 151 | + aut_one.attach() |
| 152 | + main_screen.prepare() |
| 153 | + assert community_screen.right_panel.member_is_online(1) |
| 154 | + main_screen.hide() |
0 commit comments