Skip to content

Commit d80f13e

Browse files
committed
init
1 parent f48eeaf commit d80f13e

10 files changed

+233
-121
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
"""
2+
Helper functions for common operations with multiple instances.
3+
Reduces code duplication across test files.
4+
"""
5+
import allure
6+
from allure_commons._allure import step
7+
8+
import configs
9+
10+
11+
@allure.step('Switch to AUT and prepare main window')
12+
def switch_to_aut(aut, main_window):
13+
"""
14+
Switch to the given AUT and prepare main window.
15+
16+
Args:
17+
aut: The AUT to switch to
18+
main_window: MainWindow instance
19+
"""
20+
aut.attach()
21+
main_window.prepare()
22+
23+
24+
@allure.step('Switch to AUT and hide main window')
25+
def switch_to_aut_and_hide(aut, main_window):
26+
"""
27+
Switch to the given AUT, prepare and hide main window.
28+
29+
Args:
30+
aut: The AUT to switch to
31+
main_window: MainWindow instance
32+
"""
33+
aut.attach()
34+
main_window.prepare()
35+
main_window.hide()
36+
37+
38+
@allure.step('Authorize user in AUT')
39+
def authorize_user_in_aut(aut, main_window, user_account):
40+
"""
41+
Authorize user in the given AUT.
42+
43+
Args:
44+
aut: The AUT to authorize user in
45+
main_window: MainWindow instance
46+
user_account: UserAccount to authorize
47+
"""
48+
aut.attach()
49+
main_window.wait_until_appears(configs.timeouts.APP_LOAD_TIMEOUT_MSEC).prepare()
50+
main_window.authorize_user(user_account)
51+
main_window.hide()
52+
53+
54+
@allure.step('Get chat key from user')
55+
def get_chat_key(aut, main_window):
56+
"""
57+
Get chat key from the current user.
58+
59+
Args:
60+
aut: The AUT to get chat key from
61+
main_window: MainWindow instance
62+
63+
Returns:
64+
str: Chat key of the user
65+
"""
66+
aut.attach()
67+
main_window.prepare()
68+
profile_popup = main_window.left_panel.open_online_identifier().open_profile_popup_from_online_identifier()
69+
chat_key = profile_popup.copy_chat_key
70+
main_window.left_panel.click()
71+
main_window.hide()
72+
return chat_key
73+
74+
75+
@allure.step('Send contact request from settings')
76+
def send_contact_request_from_settings(aut, main_window, chat_key, message):
77+
"""
78+
Send contact request from messaging settings.
79+
80+
Args:
81+
aut: The AUT to send request from
82+
main_window: MainWindow instance
83+
chat_key: Chat key of the recipient
84+
message: Message to send with the request
85+
86+
Returns:
87+
ContactsSettingsView: The contacts settings view instance
88+
"""
89+
aut.attach()
90+
main_window.prepare()
91+
settings = main_window.left_panel.open_settings()
92+
messaging_settings = settings.left_panel.open_messaging_settings()
93+
contacts_settings = messaging_settings.open_contacts_settings()
94+
contact_request_popup = contacts_settings.open_contact_request_form()
95+
contact_request_popup.send(chat_key, message)
96+
return contacts_settings
97+
98+
99+
@allure.step('Accept contact request from settings')
100+
def accept_contact_request_from_settings(aut, main_window, user_name):
101+
"""
102+
Accept contact request from messaging settings.
103+
104+
Args:
105+
aut: The AUT to accept request in
106+
main_window: MainWindow instance
107+
user_name: Name of the user to accept request from
108+
"""
109+
aut.attach()
110+
main_window.prepare()
111+
settings = main_window.left_panel.open_settings()
112+
messaging_settings = settings.left_panel.open_messaging_settings()
113+
contacts_settings = messaging_settings.open_contacts_settings()
114+
contacts_settings.accept_contact_request(user_name)
115+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,73 @@
1+
"""
2+
Helper functions for common settings operations.
3+
Reduces code duplication across test files.
4+
"""
5+
import allure
6+
from allure_commons._allure import step
7+
18
from constants.dock_buttons import DockButtons
29

310

11+
@allure.step('Enable testnet mode')
412
def enable_testnet_mode(main_window):
13+
"""Enable testnet mode from wallet settings."""
514
wallet_settings = main_window.left_panel.open_settings().left_panel.open_wallet_settings()
615
test_mode_popup = wallet_settings.open_networks().switch_testnet_mode_toggle()
716
test_mode_popup.turn_on_testnet_mode()
817

918

19+
@allure.step('Enable managing communities on testnet toggle')
1020
def enable_managing_communities_toggle(main_window):
21+
"""Enable managing communities on testnet from advanced settings."""
1122
settings = main_window.left_panel.open_settings()
1223
settings.left_panel.open_advanced_settings().enable_manage_communities_on_testnet_toggle()
1324

25+
26+
@allure.step('Open wallet settings')
27+
def open_wallet_settings(main_window):
28+
"""
29+
Open wallet settings from main window.
30+
31+
Returns:
32+
WalletSettingsView: The wallet settings view instance
33+
"""
34+
return main_window.left_panel.open_settings().left_panel.open_wallet_settings()
35+
36+
37+
@allure.step('Open messaging settings')
38+
def open_messaging_settings(main_window):
39+
"""
40+
Open messaging settings from main window.
41+
42+
Returns:
43+
MessagingSettingsView: The messaging settings view instance
44+
"""
45+
return main_window.left_panel.open_settings().left_panel.open_messaging_settings()
46+
47+
48+
@allure.step('Open profile settings')
49+
def open_profile_settings(main_window):
50+
"""
51+
Open profile settings from main window.
52+
53+
Returns:
54+
ProfileSettingsView: The profile settings view instance
55+
"""
56+
return main_window.left_panel.open_settings().left_panel.open_profile_settings()
57+
58+
59+
@allure.step('Verify toast notification contains message')
60+
def verify_toast_notification(main_window, expected_message):
61+
"""
62+
Verify that a toast notification contains the expected message.
63+
64+
Args:
65+
main_window: MainWindow instance
66+
expected_message: Expected message in the toast
67+
68+
Returns:
69+
bool: True if message is found in toast notifications
70+
"""
71+
messages = main_window.wait_for_toast_notifications()
72+
return expected_message in messages
73+

test/e2e/tests/crtitical_tests_prs/test_add_delete_account_from_settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from constants.wallet import WalletAccountSettings, DerivationPathValue
1313
from gui.main_window import MainWindow
1414
from gui.screens.settings_wallet import WalletSettingsView
15+
from helpers.settings_helper import open_wallet_settings
1516

1617

1718
@pytest.mark.critical
@@ -28,8 +29,7 @@ def test_delete_generated_account_from_wallet_settings(
2829
main_screen: MainWindow, user_account, account_name: str, color: str, emoji: str, emoji_unicode: str):
2930

3031
with step('Open add account pop up from wallet settings'):
31-
add_account_popup = \
32-
main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_add_account_pop_up()
32+
add_account_popup = open_wallet_settings(main_screen).open_add_account_pop_up()
3333

3434
with step('Add a new generated account from wallet settings screen'):
3535
add_account_popup.set_name(account_name).save_changes()
@@ -70,7 +70,7 @@ def test_delete_generated_account_from_wallet_settings(
7070
with step('Navigate to wallet and reopen account details for deletion'):
7171
# Navigate to wallet screen first, then to settings to get fresh acc_view
7272
main_screen.home.open_from_dock(DockButtons.WALLET.value)
73-
acc_view = main_screen.left_panel.open_settings().left_panel.open_wallet_settings().open_account_in_settings(account_name, account_index)
73+
acc_view = open_wallet_settings(main_screen).open_account_in_settings(account_name, account_index)
7474

7575
with step('Delete generated account'):
7676
delete_confirmation_popup = acc_view.open_remove_account_with_confirmation_popup()

test/e2e/tests/crtitical_tests_prs/test_add_edit_restart_add_delete_generated_account.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import driver
1313
from gui.main_window import MainWindow
14+
from helpers.settings_helper import open_wallet_settings
1415

1516

1617
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703033', 'Manage a generated account')

test/e2e/tests/crtitical_tests_prs/test_create_edit_join_community_pin_unpin_message.py

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
import driver
66
from constants.community import Channel
77
from gui.main_window import MainWindow
8-
from scripts.utils.browser import get_response, get_page_content
8+
from helpers.multiple_instances_helper import (
9+
authorize_user_in_aut, get_chat_key, send_contact_request_from_settings,
10+
accept_contact_request_from_settings, switch_to_aut
11+
)
912
from scripts.utils.generators import random_text_message, random_community_introduction, random_community_description, \
1013
random_community_name, random_community_leave_message
1114
import configs
@@ -31,36 +34,17 @@ def test_create_edit_join_community_pin_unpin_message(multiple_instances):
3134
with multiple_instances() as aut_one, multiple_instances() as aut_two:
3235
with step(f'Launch multiple instances with authorized users {user_one.name} and {user_two.name}'):
3336
for aut, account in zip([aut_one, aut_two], [user_one, user_two]):
34-
aut.attach()
35-
main_screen.wait_until_appears(configs.timeouts.APP_LOAD_TIMEOUT_MSEC).prepare()
36-
main_screen.authorize_user(account)
37-
main_screen.hide()
37+
authorize_user_in_aut(aut, main_screen, account)
3838

3939
with step(f'User {user_two.name}, get chat key'):
40-
aut_two.attach()
41-
main_screen.prepare()
42-
profile_popup = main_screen.left_panel.open_online_identifier().open_profile_popup_from_online_identifier()
43-
chat_key = profile_popup.copy_chat_key
44-
main_screen.left_panel.click()
45-
main_screen.hide()
40+
chat_key = get_chat_key(aut_two, main_screen)
4641

4742
with step(f'User {user_one.name}, send contact request to {user_two.name}'):
48-
aut_one.attach()
49-
main_screen.prepare()
50-
settings = main_screen.left_panel.open_settings()
51-
messaging_settings = settings.left_panel.open_messaging_settings()
52-
contacts_settings = messaging_settings.open_contacts_settings()
53-
contact_request_popup = contacts_settings.open_contact_request_form()
54-
contact_request_popup.send(chat_key, f'Hello {user_two.name}')
43+
send_contact_request_from_settings(aut_one, main_screen, chat_key, f'Hello {user_two.name}')
5544
main_screen.hide()
5645

5746
with step(f'User {user_two.name}, accept contact request from {user_one.name}'):
58-
aut_two.attach()
59-
main_screen.prepare()
60-
settings = main_screen.left_panel.open_settings()
61-
messaging_settings = settings.left_panel.open_messaging_settings()
62-
contacts_settings = messaging_settings.open_contacts_settings()
63-
contacts_settings.accept_contact_request(user_one.name)
47+
accept_contact_request_from_settings(aut_two, main_screen, user_one.name)
6448

6549
with step(f'User {user_two.name}, create community and invite {user_one.name}'):
6650
with step('Create community and select it'):
@@ -144,8 +128,7 @@ def test_create_edit_join_community_pin_unpin_message(multiple_instances):
144128
main_screen.hide()
145129

146130
with step(f'User {user_one.name}, accept invitation from {user_two.name}'):
147-
aut_one.attach()
148-
main_screen.prepare()
131+
switch_to_aut(aut_one, main_screen)
149132
messages_view = main_screen.left_panel.open_messages_screen()
150133
chat = messages_view.left_panel.click_chat_by_name(user_two.name)
151134
chat.click_community_invite(new_name, 0)
@@ -164,8 +147,7 @@ def test_create_edit_join_community_pin_unpin_message(multiple_instances):
164147
main_screen.hide()
165148

166149
with step(f'User {user_two.name}, see two members in community members list'):
167-
aut_two.attach()
168-
main_screen.prepare()
150+
switch_to_aut(aut_two, main_screen)
169151
assert driver.waitFor(lambda: user_one.name in community_screen.right_panel.members, 10000)
170152
assert '2' in community_screen.left_panel.members
171153

@@ -193,23 +175,20 @@ def test_create_edit_join_community_pin_unpin_message(multiple_instances):
193175
main_screen.hide()
194176

195177
with step(f'User {user_one.name} see the {second_message_text} as pinned'):
196-
aut_one.attach()
197-
main_screen.prepare()
178+
switch_to_aut(aut_one, main_screen)
198179
message = messages_screen.chat.find_message_by_text(second_message_text, 1)
199180
assert driver.waitFor(lambda: message.message_is_pinned, configs.timeouts.APP_LOAD_TIMEOUT_MSEC)
200181
assert message.pinned_info_text + message.user_name_in_pinned_message == 'Pinned by' + user_two.name
201182
assert message.get_message_color() == ColorCodes.ORANGE.value
202183
main_screen.hide()
203184

204185
with step(f'User {user_two.name} unpin message from pinned messages popup'):
205-
aut_two.attach()
206-
main_screen.prepare()
186+
switch_to_aut(aut_two, main_screen)
207187
pinned_msgs = messages_screen.tool_bar.open_pinned_messages_popup()
208188
pinned_msgs.unpin_message().close()
209189

210190
with step(f'User {user_one.name} see the {second_message_text} as unpinned'):
211-
aut_one.attach()
212-
main_screen.prepare()
191+
switch_to_aut(aut_one, main_screen)
213192
message = messages_screen.chat.find_message_by_text(second_message_text, 1)
214193
assert driver.waitFor(lambda: not message.message_is_pinned, configs.timeouts.APP_LOAD_TIMEOUT_MSEC)
215194
assert message.user_name_in_pinned_message == ''

0 commit comments

Comments
 (0)