Skip to content

Commit f4bb321

Browse files
committed
e2e: fixes for pinning messages tests
1 parent fe0e685 commit f4bb321

File tree

5 files changed

+50
-36
lines changed

5 files changed

+50
-36
lines changed

test/appium/tests/communities/test_community.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ def test_restore_multiaccount_with_waku_backup_remove_profile_switch(self):
230230

231231
self.home.just_fyi("Check that can remove user from logged out state")
232232
self.home.reopen_app(sign_in=False)
233+
self.sign_in.show_profiles_button.click_if_shown()
233234
user_card = self.sign_in.get_user_profile_by_name(username=recover_user_name)
234235
user_card.open_user_options()
235236
self.sign_in.remove_profile_button.click()
@@ -954,7 +955,7 @@ def test_community_mentions_push_notification(self):
954955
self.device_2.just_fyi("Sender checks the reaction for a message with a mention")
955956
try:
956957
self.channel_2.chat_element_by_text(self.username_1).emojis_below_message(
957-
emoji="sad").wait_for_element_text(1)
958+
emoji="sad").wait_for_element_text(text=1, wait_time=60)
958959
except (Failed, NoSuchElementException):
959960
self.errors.append(self.channel_2, "Message reaction is not shown for the sender")
960961

@@ -1013,7 +1014,7 @@ def test_community_markdown_support(self):
10131014
self.channel_2,
10141015
'%s is not displayed with markdown in community channel for the sender \n' % message)
10151016

1016-
if not self.channel_1.chat_element_by_text(message).is_element_displayed():
1017+
if not self.channel_1.chat_element_by_text(message).is_element_displayed(60):
10171018
self.errors.append(
10181019
self.channel_1,
10191020
'%s is not displayed with markdown in community channel for the recipient \n' % message)
@@ -1034,7 +1035,7 @@ def test_community_markdown_support(self):
10341035
self.errors.append(
10351036
self.chat_1, '%s is not displayed with markdown in 1-1 chat for the sender (device 1) \n' % message)
10361037

1037-
if not self.chat_2.chat_element_by_text(message).is_element_displayed(30):
1038+
if not self.chat_2.chat_element_by_text(message).is_element_displayed(60):
10381039
self.errors.append(
10391040
self.chat_2,
10401041
'%s is not displayed with markdown in 1-1 chat for the recipient (device 2) \n' % message)

test/appium/tests/private_chats/test_group_chat.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ def test_group_chat_reactions(self):
125125
def _check_reactions_count(chat_view_index):
126126
self.chats[chat_view_index].just_fyi("Checking reactions count for each group member and admin")
127127
chat_element = self.chats[chat_view_index].chat_element_by_text(message)
128-
chat_element.emojis_below_message(emoji="thumbs-up").wait_for_element_text(2)
129-
chat_element.emojis_below_message(emoji="love").wait_for_element_text(1)
130-
chat_element.emojis_below_message(emoji="laugh").wait_for_element_text(1)
128+
chat_element.emojis_below_message(emoji="thumbs-up").wait_for_element_text(text=2, wait_time=60)
129+
chat_element.emojis_below_message(emoji="love").wait_for_element_text(text=1, wait_time=60)
130+
chat_element.emojis_below_message(emoji="laugh").wait_for_element_text(text=1, wait_time=60)
131131

132132
self.loop.run_until_complete(run_in_parallel((
133133
(_check_reactions_count, {'chat_view_index': 0}),
@@ -181,9 +181,9 @@ def _check_reactions_count_after_change(chat_view_index):
181181
"Checking reactions count for each group member and admin after they were changed")
182182
chat_element = self.chats[chat_view_index].chat_element_by_text(message)
183183
try:
184-
chat_element.emojis_below_message(emoji="thumbs-up").wait_for_element_text(1)
185-
chat_element.emojis_below_message(emoji="love").wait_for_element_text(1)
186-
chat_element.emojis_below_message(emoji="sad").wait_for_element_text(2)
184+
chat_element.emojis_below_message(emoji="thumbs-up").wait_for_element_text(text=1, wait_time=60)
185+
chat_element.emojis_below_message(emoji="love").wait_for_element_text(text=1, wait_time=60)
186+
chat_element.emojis_below_message(emoji="sad").wait_for_element_text(text=2, wait_time=60)
187187
except (Failed, NoSuchElementException):
188188
self.errors.append(self.chats[chat_view_index],
189189
"Incorrect reactions count for %s after changing the reactions" % self.usernames[
@@ -203,9 +203,9 @@ def _check_reactions_count_after_change(chat_view_index):
203203
self.chats[0].just_fyi("Admin checks reactions count after relogin")
204204
message_element = self.chats[0].chat_element_by_text(message)
205205
try:
206-
message_element.emojis_below_message(emoji="thumbs-up").wait_for_element_text(1)
207-
message_element.emojis_below_message(emoji="love").wait_for_element_text(1)
208-
message_element.emojis_below_message(emoji="sad").wait_for_element_text(2)
206+
message_element.emojis_below_message(emoji="thumbs-up").wait_for_element_text(text=1, wait_time=60)
207+
message_element.emojis_below_message(emoji="love").wait_for_element_text(text=1, wait_time=60)
208+
message_element.emojis_below_message(emoji="sad").wait_for_element_text(text=2, wait_time=60)
209209
except (Failed, NoSuchElementException):
210210
self.errors.append(self.chats[0], "Incorrect reactions count after relogin")
211211

@@ -349,7 +349,7 @@ def _proceed_to_chat(index):
349349
def _check_messages(index):
350350
self.chats[index].just_fyi("Check that messages are shown for user %s" % self.usernames[index])
351351
for message_text in (message_1, message_2):
352-
if not self.chats[index].chat_element_by_text(message_text).is_element_displayed(30):
352+
if not self.chats[index].chat_element_by_text(message_text).is_element_displayed(60):
353353
self.errors.append(self.chats[index], '%s if not shown for device %s' % (message_text, index))
354354

355355
self.loop.run_until_complete(run_in_parallel((
@@ -361,6 +361,8 @@ def _check_messages(index):
361361
self.errors.verify_no_errors()
362362

363363
@marks.testrail_id(702732)
364+
@marks.xfail(
365+
reason="Can not unpin messages from pinned messages menu - https://github.com/status-im/status-mobile/issues/22497")
364366
def test_group_chat_pin_messages(self):
365367
[self.homes[i].navigate_back_to_home_view() for i in range(3)]
366368
[self.homes[i].get_chat(self.chat_name).click() for i in range(3)]
@@ -372,6 +374,7 @@ def test_group_chat_pin_messages(self):
372374
self.chats[0].send_message(self.message_1)
373375
self.chats[0].pin_message(self.message_1, "pin-to-chat")
374376
for chat in self.chats[0], self.chats[1]:
377+
chat.chat_element_by_text(self.message_1).wait_for_visibility_of_element(60)
375378
if not chat.chat_element_by_text(self.message_1).pinned_by_label.is_element_displayed(30):
376379
self.errors.append(chat, "Message 1 is not pinned in group chat!")
377380

@@ -401,17 +404,18 @@ def test_group_chat_pin_messages(self):
401404
self.chats[0].send_message(message)
402405
self.chats[0].pin_message(message, 'pin-to-chat')
403406
for chat in self.chats[0], self.chats[1]:
407+
chat.chat_element_by_text(message).wait_for_visibility_of_element(60)
404408
if not chat.chat_element_by_text(message).pinned_by_label.is_element_displayed(30):
405409
self.errors.append(chat, "%s is not pinned in group chat!" % message)
406410

407411
self.chats[0].just_fyi("Check that a user can not pin more than 3 messages")
408412
self.chats[0].send_message(self.message_4)
409413
self.chats[0].pin_message(self.message_4, 'pin-to-chat')
410414
self.chats[0].view_pinned_messages_button.click_until_presence_of_element(self.chats[0].pinned_messages_list)
411-
unpin_element = self.chats[0].element_by_translation_id('unpin-from-chat')
412-
self.chats[0].pinned_messages_list.message_element_by_text(self.message_2).long_press_without_release()
413-
unpin_element.click_until_absense_of_element(desired_element=unpin_element)
414-
self.chats[0].chat_element_by_text(self.message_4).click()
415+
if self.chats[0].pinned_messages_list.message_element_by_text(self.message_4).is_element_displayed():
416+
self.errors.append(self.chats[0], "Can pin more than 3 messages")
417+
self.chats[0].tap_by_coordinates(500, 100)
418+
self.chats[0].pin_message(self.message_2, action='unpin-from-chat')
415419
self.chats[0].pin_message(self.message_4, 'pin-to-chat')
416420
for chat in self.chats[0], self.chats[1]:
417421
if not chat.chat_element_by_text(self.message_4).pinned_by_label.is_element_displayed(30):
@@ -438,7 +442,7 @@ def _check_pinned_messages(index):
438442
else:
439443
self.errors.append(self.chats[index],
440444
"Message '%s' is missed on Pinned messages list for user %s" % (
441-
message, self.usernames[index])
445+
message_text, self.usernames[index])
442446
)
443447

444448
self.loop.run_until_complete(run_in_parallel((

test/appium/tests/private_chats/test_one_to_one_chat.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def prepare_devices(self):
4747
"Message 1", "Message 2", "Message 3", "Message 4"
4848

4949
@marks.smoke
50-
@marks.xfail(reason="Might fail from time to time as reaction are set too slowly") # TODO: needs investigation
50+
@marks.xfail(reason="Might fail from time to time as reaction are set too slowly") # TODO: needs investigation
5151
@marks.testrail_id(702730)
5252
def test_1_1_chat_message_reaction(self):
5353
message_from_sender = "Message sender"
@@ -186,25 +186,28 @@ def test_1_1_chat_emoji_send_reply_and_open_link(self):
186186

187187
self.errors.verify_no_errors()
188188

189-
@marks.smoke
189+
# @marks.smoke # ToDo: return to the smoke suite when https://github.com/status-im/status-mobile/issues/22497 is fixed
190190
@marks.testrail_id(702731)
191+
@marks.xfail(
192+
reason="Can not unpin messages from pinned messages menu - https://github.com/status-im/status-mobile/issues/22497")
191193
def test_1_1_chat_pin_messages(self):
192194
self.home_1.just_fyi("Check that Device1 can pin own message in 1-1 chat")
193195
self.chat_2.navigate_back_to_home_view()
194196
self.home_2.chats_tab.click()
195197
self.home_2.get_chat(self.username_1).click()
196198
self.chat_1.send_message(self.message_1)
197199
self.chat_1.send_message(self.message_2)
198-
self.chat_1.chat_element_by_text(self.message_1).wait_for_status_to_be("Delivered")
199-
self.chat_1.pin_message(self.message_1, 'pin-to-chat')
200+
self.chat_1.chat_element_by_text(self.message_1).wait_for_status_to_be(expected_status="Delivered", timeout=60)
201+
self.chat_1.pin_message(self.message_1, action='pin-to-chat')
200202
if not self.chat_1.chat_element_by_text(self.message_1).pinned_by_label.is_element_displayed():
201203
self.drivers[0].fail("Message is not pinned!")
202204

203205
self.home_1.just_fyi("Check that Device2 can pin Device1 message in 1-1 chat and two pinned "
204206
"messages are in Device1 profile")
205-
self.chat_2.pin_message(self.message_2, 'pin-to-chat')
207+
self.chat_2.pin_message(self.message_2, action='pin-to-chat')
206208
for chat_number, chat in enumerate([self.chat_1, self.chat_2]):
207209
chat.pinned_messages_count.wait_for_element_text(text="2",
210+
wait_time=60,
208211
message="Pinned messages count is not 2 as expected!")
209212

210213
chat.just_fyi("Check pinned messages are visible in Pinned panel for user %s" % (chat_number + 1))
@@ -232,8 +235,8 @@ def test_1_1_chat_pin_messages(self):
232235
self.home_1.just_fyi("Check that Device1 can not pin more than 3 messages and 'Unpin' dialog appears")
233236
for message in (self.message_3, self.message_4):
234237
self.chat_1.send_message(message)
235-
self.chat_1.chat_element_by_text(message).wait_for_status_to_be("Delivered")
236-
self.chat_1.pin_message(message, 'pin-to-chat')
238+
self.chat_1.chat_element_by_text(message).wait_for_status_to_be(expected_status="Delivered", timeout=60)
239+
self.chat_1.pin_message(message, action='pin-to-chat')
237240
# if not self.chat_1.pin_limit_popover.is_element_displayed():
238241
# self.errors.append("Pin limit popover is not displayed when pinning more than 3 messages")
239242
self.chat_1.view_pinned_messages_button.click_until_presence_of_element(self.chat_1.pinned_messages_list)
@@ -250,30 +253,28 @@ def test_1_1_chat_pin_messages(self):
250253
if not chat.chat_element_by_text(self.message_4).pinned_by_label.is_element_displayed(30):
251254
self.errors.append(chat, "Message 4 is not pinned in chat after unpinning previous one")
252255

253-
self.home_1.just_fyi("Check pinned messages are visible in Pinned panel for both users")
254256
for chat_number, chat in enumerate([self.chat_1, self.chat_2]):
257+
chat.just_fyi("Check pinned messages are visible in Pinned panel for user %s" % (chat_number + 1))
255258
count = chat.pinned_messages_count.text
256259
if count != '3':
257260
self.errors.append(chat,
258261
"Pinned messages count is %s but should be 3 for user %s" % (count, chat_number + 1))
259262

260263
self.home_1.just_fyi("Unpin one message and check it's unpinned for another user")
261-
self.chat_2.tap_by_coordinates(500, 100)
262-
264+
self.chat_1.tap_by_coordinates(500, 100)
263265
self.chat_1.view_pinned_messages_button.click_until_presence_of_element(self.chat_1.pinned_messages_list)
264266
pinned_message = self.chat_1.pinned_messages_list.message_element_by_text(self.message_4)
265-
266267
unpin_element = self.chat_1.element_by_translation_id("unpin-from-chat")
267268
pinned_message.long_press_without_release()
268269
unpin_element.click_until_absense_of_element(unpin_element)
269-
# try:
270-
# self.chat_2.chat_element_by_text(self.message_4).pinned_by_label.wait_for_invisibility_of_element()
271-
# except TimeoutException:
272-
# self.errors.append("Message_4 is not unpinned!")
270+
try:
271+
self.chat_2.chat_element_by_text(self.message_4).pinned_by_label.wait_for_invisibility_of_element(60)
272+
except TimeoutException:
273+
self.errors.append(self.chat_2, "'%s' is not unpinned!" % self.message_4)
273274

274275
for chat_number, chat in enumerate([self.chat_1, self.chat_2]):
275276
try:
276-
chat.pinned_messages_count.wait_for_element_text(text='2', wait_time=20)
277+
chat.pinned_messages_count.wait_for_element_text(text='2', wait_time=60)
277278
except Failed:
278279
self.errors.append(
279280
chat, "Pinned messages count is not 2 after unpinning the last pinned message for user %s" % (

test/appium/views/chat_view.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,9 @@ def __init__(self, driver):
332332

333333
def join_community(self, password=common_password, open_community=True):
334334
self.driver.info("Joining community")
335-
ChatView(self.driver).chat_element_by_text("https://status.app/c/").click_on_link_inside_message_body()
335+
chat_element = ChatView(self.driver).chat_element_by_text("https://status.app/c/")
336+
chat_element.wait_for_visibility_of_element(60)
337+
chat_element.click_on_link_inside_message_body()
336338
self.join_button.wait_and_click(120)
337339
self.slide_to_request_to_join_button.swipe_right_on_element(width_percentage=16)
338340
self.password_input.send_keys(password)
@@ -649,7 +651,10 @@ def send_message(self, message: str = 'test message', wait_chat_input_sec=5):
649651
def pin_message(self, message, action="pin"):
650652
self.driver.info("Looking for message '%s' pin" % message)
651653
element = self.element_by_translation_id(action)
652-
self.chat_element_by_text(message).long_press_without_release()
654+
self.chat_element_by_text(message).long_press_until_element_is_shown(element)
655+
if not element.is_element_displayed():
656+
self.driver.fail(
657+
"Device %s: Action '%s' is not displayed for the message '%s'" % (self.driver.number, action, message))
653658
element.click_until_absense_of_element(element)
654659

655660
def edit_message_in_chat(self, message_to_edit, message_to_update):

test/appium/views/sign_in_view.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def recover_access(self, passphrase: str, password: str = common_password, enabl
103103
self.create_profile_button.click()
104104
self.maybe_later_button.wait_and_click()
105105
else:
106+
self.show_profiles_button.click_if_shown()
106107
self.plus_profiles_button.click()
107108
self.create_new_profile_button.click()
108109
self.use_recovery_phrase_button.click()
@@ -122,6 +123,7 @@ def sync_profile(self, sync_code: str, first_user: bool = True):
122123
self.log_in_button.click()
123124
self.maybe_later_button.click()
124125
else:
126+
self.show_profiles_button.click_if_shown()
125127
self.plus_profiles_button.click()
126128
self.sync_or_recover_new_profile_button.click()
127129
self.log_in_by_syncing_button.click()
@@ -134,6 +136,7 @@ def sync_profile(self, sync_code: str, first_user: bool = True):
134136

135137
def sign_in(self, user_name, password=common_password):
136138
self.driver.info("## Sign in (password: %s)" % password, device=False)
139+
self.show_profiles_button.click_if_shown()
137140
self.get_user_profile_by_name(user_name).click()
138141
self.password_input.wait_for_visibility_of_element(10)
139142
self.password_input.send_keys(password)

0 commit comments

Comments
 (0)