Skip to content

Commit 118f91e

Browse files
committed
chore(@e2e): fixes for tests on windows
1 parent ad0935d commit 118f91e

File tree

9 files changed

+74
-38
lines changed

9 files changed

+74
-38
lines changed

test/e2e/gui/components/changes_detected_popup.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,42 @@ class ChangesDetectedToastMessage(QObject):
1111
def __init__(self):
1212
super(ChangesDetectedToastMessage, self).__init__(
1313
names.mainWindow_settingsDirtyToastMessage_SettingsDirtyToastMessage)
14-
self._save_button = Button(names.mainWindow_Save_changes_StatusButton)
14+
self.save_button = Button(names.mainWindow_Save_changes_StatusButton)
1515

1616
@allure.step('Save changes')
17-
def click_save_changes_button(self):
18-
self._save_button.click()
17+
def save_changes(self, max_attempts: int = 4):
18+
for attempt in range(1, max_attempts + 1):
19+
self.save_button.click()
20+
try:
21+
self.wait_until_hidden(timeout_msec=configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
22+
return
23+
except TimeoutError:
24+
if attempt < max_attempts:
25+
continue
26+
else:
27+
raise
28+
1929

20-
@allure.step('Check if save changes button is visible')
21-
def is_save_changes_button_visible(self) -> bool:
22-
return self._save_button.is_visible
2330

2431

2532
class PermissionsChangesDetectedToastMessage(QObject):
2633

2734
def __init__(self):
2835
super().__init__(communities_names.editPermissionView_settingsDirtyToastMessage_SettingsDirtyToastMessage)
29-
self._update_permission_button = Button(communities_names.editPermissionView_Update_permission_StatusButton)
36+
self.update_permission_button = Button(communities_names.editPermissionView_Update_permission_StatusButton)
3037

3138
@allure.step('Update permission')
3239
def update_permission(self, max_attempts: int = 4):
3340
for attempt in range(1, max_attempts + 1):
34-
self._update_permission_button.click()
41+
self.update_permission_button.click()
3542
try:
36-
# Use a shorter timeout per attempt, but allow multiple attempts
37-
self.wait_until_hidden(timeout_msec=configs.timeouts.PROCESS_TIMEOUT_SEC * 1000)
38-
# If we reach here, the popup is hidden - success!
43+
self.wait_until_hidden(timeout_msec=configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
3944
return
4045
except TimeoutError:
4146
if attempt < max_attempts:
4247
# Continue to next attempt
4348
continue
4449
else:
45-
# Last attempt failed, re-raise the exception
4650
raise
4751

4852

test/e2e/gui/main_window.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def open_messages_screen(self):
8484
return self.messages_button
8585

8686
@allure.step('Click Gear button and open Settings screen')
87-
@open_with_retries(SettingsScreen)
87+
@open_with_retries(SettingsScreen, attempts=3, delay=3.0)
8888
def open_settings(self):
8989
return self.settings_button
9090

test/e2e/gui/screens/messages.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,18 @@ def get_chats_names(self) -> typing.List[str]:
5555
return chats_list
5656

5757
@allure.step('Click chat item')
58-
def click_chat_by_name(self, chat_name: str):
58+
def click_chat_by_name(self, chat_name: str, attempts: int = 4):
5959
self._chat_list_item.real_name['objectName'] = chat_name
60-
self._chat_list_item.click()
61-
skip_message_backup_popup_if_visible()
62-
return ChatView()
60+
61+
for attempt in range(1, attempts + 1):
62+
self._chat_list_item.click()
63+
try:
64+
return ChatView().wait_until_appears()
65+
except Exception as e:
66+
if attempt < attempts:
67+
continue
68+
else:
69+
raise Exception(f"Failed to open ChatView after {attempts} attempts: {e}")
6370

6471
@allure.step('Click start chat button')
6572
def start_chat(self):
@@ -160,10 +167,18 @@ def init_ui(self):
160167
self.banner_image = QObject(real_name=driver.objectMap.realName(child))
161168

162169
@allure.step('Open community invitation')
163-
def open_community_invitation(self):
170+
def open_community_invitation(self, attempts: int = 4):
164171
driver.waitFor(lambda: self.delegate_button.is_visible, configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
165-
self.delegate_button.click()
166-
return CommunityScreen().wait_until_appears()
172+
173+
for attempt in range(1, attempts + 1):
174+
self.delegate_button.click()
175+
try:
176+
return CommunityScreen().wait_until_appears()
177+
except Exception as e:
178+
if attempt < attempts:
179+
continue
180+
else:
181+
raise Exception(f"Failed to open CommunityScreen after {attempts} attempts: {e}")
167182

168183
def open_banned_community_invitation(self):
169184
driver.waitFor(lambda: self.delegate_button.is_visible, configs.timeouts.UI_LOAD_TIMEOUT_MSEC)

test/e2e/helpers/chat_helper.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,28 @@
44
import time
55
import allure
66

7+
import configs
78
from gui.components.community.enable_message_backup_popup import EnableMessageBackupPopup
89

910

1011
@allure.step('Skip Enable Messages backup popup')
11-
def skip_message_backup_popup_if_visible():
12+
def skip_message_backup_popup_if_visible(attempts = 4):
1213
"""
1314
Skip the message backup popup if it's visible.
14-
This is a common operation that appears in multiple places throughout the codebase.
1515
"""
16-
# Small delay to ensure popup has time to appear
17-
time.sleep(0.1)
1816

1917
message_back_up_popup = EnableMessageBackupPopup()
20-
if message_back_up_popup.is_visible:
18+
if not message_back_up_popup.is_visible:
19+
return
20+
21+
for attempt in range(1, attempts + 1):
2122
message_back_up_popup.skip_button.click()
22-
# Small delay after clicking to ensure action is processed
23-
time.sleep(0.1)
23+
try:
24+
message_back_up_popup.wait_until_hidden(timeout_msec=configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
25+
return
26+
except Exception as e:
27+
if attempt < attempts:
28+
continue
29+
else:
30+
raise Exception(f"Failed to close EnableMessageBackupPopup after {attempts} attempts: {e}")
31+

test/e2e/scripts/utils/decorators.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,21 @@ def decorator(func):
4343
@wraps(func)
4444
def wrapper(self, *args, **kwargs):
4545
last_exception = None
46+
# TODO: https://github.com/status-im/status-desktop/issues/18888
47+
# Workaround for app freeze when opening settings
48+
is_settings_screen = screen_class.__name__ == 'SettingsScreen'
49+
4650
for attempt in range(1, attempts + 1):
4751
try:
4852
LOG.info(f'Attempt #{attempt} to open {screen_class.__name__}')
4953
button = func(self, *args, **kwargs)
54+
# if is_settings_screen:
55+
# # Additional wait before click for SettingsScreen due to app freeze issue
56+
# time.sleep(3)
5057
button.click()
58+
# if is_settings_screen:
59+
# # Additional wait after click for SettingsScreen due to app freeze issue
60+
# time.sleep(3)
5161
popup = screen_class().wait_until_appears()
5262
return popup
5363
except Exception as e:

test/e2e/tests/crtitical_tests_prs/test_create_edit_join_community_pin_unpin_message.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from configs import get_platform
77
from constants.community import Channel
88
from gui.main_window import MainWindow
9+
from helpers.chat_helper import skip_message_backup_popup_if_visible
910
from helpers.multiple_instances_helper import (
1011
authorize_user_in_aut, get_chat_key, send_contact_request_from_settings,
1112
accept_contact_request_from_settings, switch_to_aut
@@ -129,6 +130,7 @@ def test_create_edit_join_community_pin_unpin_message(multiple_instances):
129130
switch_to_aut(aut_one, main_screen)
130131
messages_view = main_screen.left_panel.open_messages_screen()
131132
chat = messages_view.left_panel.click_chat_by_name(user_two.name)
133+
skip_message_backup_popup_if_visible()
132134
chat.click_community_invite(new_name, 0)
133135

134136
with step(f'User {user_one.name}, verify welcome community popup'):

test/e2e/tests/crtitical_tests_prs/test_messaging_1x1_chat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
import string
33
import time
44

5-
import allure
65
import pytest
76
from allure_commons._allure import step
87

98
import driver
10-
from configs import get_platform
119
from constants.messaging import Messaging
1210
from constants.wallet import WalletAddress
1311
from ext.test_files.base64_images import BASE_64_IMAGE_JPEG
@@ -81,6 +79,8 @@ def test_1x1_chat_add_contact_in_settings(multiple_instances):
8179

8280
with step(f'User {user_two.name}, accept contact request from {user_one.name}'):
8381
contacts_settings.accept_contact_request(user_one.name)
82+
skip_message_backup_popup_if_visible()
83+
8484

8585
with step(f'Verify that contact appeared in contacts list of {user_two.name} in messaging settings'):
8686
# Test is on a chat screen, so we need to open settings from left panel

test/e2e/tests/crtitical_tests_prs/test_messaging_group_chat.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def test_group_chat_add_contact_in_ac(multiple_instances, community_name, domain
141141

142142
with step(f'Check group members and message for {user_two.name}'):
143143
switch_to_aut(aut_two, main_window)
144+
skip_message_backup_popup_if_visible()
144145

145146
assert driver.waitFor(lambda: group_chat_new_name in messages_screen.left_panel.get_chats_names,
146147
10000), f'{group_chat_new_name} is not present in chats list for {aut_two}'
@@ -207,7 +208,7 @@ def test_group_chat_add_contact_in_ac(multiple_instances, community_name, domain
207208
with step('Wait until link preview is ready'):
208209
assert driver.waitFor(
209210
lambda: domain_link_2 == messages_screen.group_chat.get_link_preview_bubble_description(),
210-
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
211+
15000)
211212

212213
with step(f'Paste image to the same message'):
213214
messages_screen.group_chat.choose_image(str(path))
@@ -261,9 +262,9 @@ def test_group_chat_add_contact_in_ac(multiple_instances, community_name, domain
261262
main_window.minimize()
262263

263264
with step(f'Check group members and message for {user_three.name}'):
264-
switch_to_aut(aut_three, main_window)
265-
266265
with step(f'Check that {user_three.name} is not a member of a group'):
266+
switch_to_aut(aut_three, main_window)
267+
skip_message_backup_popup_if_visible()
267268
assert driver.waitFor(lambda: group_chat_new_name in messages_screen.left_panel.get_chats_names,
268269
10000), f'{group_chat_new_name} is not present in chats list for {aut_three}'
269270
messages_screen.left_panel.click_chat_by_name(group_chat_new_name)

test/e2e/tests/settings/settings_profile/test_settings_profile_edit.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,14 @@ def test_set_name_bio_social_links(main_screen: MainWindow, aut: AUT, user_accou
2727
new_user_name = random_name_string()
2828
profile_settings.set_name(new_user_name)
2929
profile_settings.set_bio(bio)
30-
ChangesDetectedToastMessage().click_save_changes_button()
31-
assert ChangesDetectedToastMessage().is_visible is False, \
32-
f'Bottom floating buttons are not hidden'
30+
ChangesDetectedToastMessage().save_changes()
3331
assert \
3432
main_screen.left_panel.open_online_identifier().open_profile_popup_from_online_identifier().user_name \
3533
== new_user_name, \
3634
f'Display name was not applied after changing'
3735
main_screen.left_panel.click()
3836
profile_settings.set_social_links(links)
39-
ChangesDetectedToastMessage().click_save_changes_button()
40-
assert ChangesDetectedToastMessage().is_visible is False, \
41-
f'Bottom floating buttons are not hidden'
37+
ChangesDetectedToastMessage().save_changes()
4238
assert len(profile_settings.get_social_links) > 0, f'No social links were added'
4339

4440
with step('Restart application'):

0 commit comments

Comments
 (0)