Skip to content

Commit 83cc3c7

Browse files
committed
e2e: mute chats
1 parent 0ac6817 commit 83cc3c7

File tree

6 files changed

+232
-17
lines changed

6 files changed

+232
-17
lines changed

src/status_im2/contexts/chat/home/chat_list_item/view.cljs

+3-2
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@
235235
(if-not muted
236236
(when show-unread-badge?
237237
[quo/info-count
238-
{:style {:top 16
239-
:right 16}}
238+
{:style {:top 16
239+
:right 16}
240+
:accessibility-label :new-message-counter}
240241
unviewed-messages-count])
241242
[icons/icon :i/muted
242243
{:color colors/neutral-40

test/appium/tests/critical/chats/test_1_1_public_chats.py

+42-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from _pytest.outcomes import Failed
77
from selenium.common.exceptions import TimeoutException, NoSuchElementException
88

9-
from tests import marks, common_password, run_in_parallel
9+
from tests import marks, common_password, run_in_parallel, transl
1010
from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
1111
from tests.users import transaction_senders, basic_user, ens_user, ens_user_message_sender
1212
from views.sign_in_view import SignInView
@@ -1378,6 +1378,47 @@ def test_1_1_chat_is_shown_message_sent_delivered_from_offline(self):
13781378
self.errors.append('%s after back up online!' % e.msg)
13791379
self.errors.verify_no_errors()
13801380

1381+
@marks.testrail_id(703496)
1382+
def test_1_1_chat_mute_chat(self):
1383+
self.home_1.click_system_back_button_until_element_is_shown()
1384+
self.home_1.chats_tab.click()
1385+
self.home_1.just_fyi("Mute chat")
1386+
self.home_1.mute_chat_long_press(self.username_2)
1387+
1388+
muted_message = "should be muted"
1389+
self.chat_2.send_message(muted_message)
1390+
chat = self.home_1.get_chat(self.username_2)
1391+
if chat.new_messages_counter.is_element_displayed(30) or self.home_1.chats_tab.counter.is_element_displayed(10):
1392+
self.errors.append("New messages counter is shown after mute")
1393+
if not chat.chat_preview.text.startswith(muted_message):
1394+
self.errors.append("Message text '%s' is not shown in chat preview after mute" % muted_message)
1395+
chat.click()
1396+
if not self.chat_1.chat_element_by_text(muted_message).is_element_displayed(30):
1397+
self.errors.append("Message '%s' is not shown in chat for receiver after mute" % muted_message)
1398+
1399+
self.chat_1.just_fyi("Unmute chat")
1400+
self.chat_1.click_system_back_button_until_element_is_shown()
1401+
chat.long_press_element()
1402+
expected_text = "%s %s" % (transl["muted-until"], transl["until-you-turn-it-back-on"])
1403+
if not self.home_1.element_by_text(expected_text).is_element_displayed():
1404+
self.errors.append(
1405+
"Text '%s' is not shown for muted chat, https://github.com/status-im/status-mobile/issues/16768" %
1406+
expected_text)
1407+
self.home_1.mute_chat_button.click()
1408+
1409+
unmuted_message = "after unmute"
1410+
self.chat_2.send_message(unmuted_message)
1411+
if not chat.new_messages_counter.is_element_displayed(
1412+
30) or not self.home_1.chats_tab.counter.is_element_displayed(10):
1413+
self.errors.append("New messages counter is not shown after unmute")
1414+
if not chat.chat_preview.text.startswith(unmuted_message):
1415+
self.errors.append("Message text '%s' is not shown in chat preview after unmute" % unmuted_message)
1416+
chat.click()
1417+
if not self.chat_1.chat_element_by_text(unmuted_message).is_element_displayed(30):
1418+
self.errors.append("Message '%s' is not shown in chat for receiver after unmute" % unmuted_message)
1419+
1420+
self.errors.verify_no_errors()
1421+
13811422
@marks.testrail_id(702784)
13821423
def test_1_1_chat_delete_via_long_press_relogin(self):
13831424
self.home_2.click_system_back_button_until_element_is_shown()

test/appium/tests/critical/chats/test_group_chat.py

+94-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from _pytest.outcomes import Failed
33
from selenium.common.exceptions import NoSuchElementException, TimeoutException
44

5-
from tests import marks, run_in_parallel
5+
from tests import marks, run_in_parallel, transl
66
from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
77
from views.chat_view import ChatView
88
from views.sign_in_view import SignInView
@@ -151,18 +151,18 @@ def prepare_devices(self):
151151
self.message_before_adding = 'message before adding new user'
152152
self.message_to_admin = 'Hey, admin!'
153153
self.public_keys, self.usernames, self.chats = {}, {}, {}
154-
sign_in_views = [SignInView(self.drivers[key]) for key in self.drivers]
154+
self.sign_in_views = [SignInView(self.drivers[key]) for key in self.drivers]
155155
self.usernames = ('user admin', 'member_1', 'member_2')
156156
self.loop.run_until_complete(
157157
run_in_parallel(
158158
(
159-
(sign_in_views[0].create_user, {'enable_notifications': True, 'username': self.usernames[0]}),
160-
(sign_in_views[1].create_user, {'enable_notifications': True, 'username': self.usernames[1]}),
161-
(sign_in_views[2].create_user, {'enable_notifications': True, 'username': self.usernames[2]})
159+
(self.sign_in_views[0].create_user, {'enable_notifications': True, 'username': self.usernames[0]}),
160+
(self.sign_in_views[1].create_user, {'enable_notifications': True, 'username': self.usernames[1]}),
161+
(self.sign_in_views[2].create_user, {'enable_notifications': True, 'username': self.usernames[2]})
162162
)
163163
)
164164
)
165-
self.homes = [sign_in.get_home_view() for sign_in in sign_in_views]
165+
self.homes = [sign_in.get_home_view() for sign_in in self.sign_in_views]
166166
self.public_keys = self.loop.run_until_complete(
167167
run_in_parallel(
168168
(
@@ -517,3 +517,91 @@ def test_group_chat_pin_messages(self):
517517
)
518518

519519
self.errors.verify_no_errors()
520+
521+
@marks.testrail_id(703495)
522+
def test_group_chat_mute_chat(self):
523+
[self.homes[i].click_system_back_button_until_element_is_shown() for i in range(3)]
524+
525+
self.homes[1].just_fyi("Member 1 mutes the chat")
526+
self.homes[1].mute_chat_long_press(self.chat_name)
527+
# ToDo: should be redone to some exact period mute after issue with adb commands execution is solved with
528+
# SauceLabs or an option for 1 minute mute is added for e2e apk
529+
# self.homes[1].mute_chat_long_press(self.chat_name, "mute-for-1-hour")
530+
# device_time = self.homes[1].driver.device_time
531+
532+
self.homes[0].just_fyi("Admin sends a message")
533+
muted_message = "Text message in the muted chat"
534+
self.homes[0].get_chat(self.chat_name).click()
535+
try:
536+
initial_counter = int(self.homes[1].chats_tab.counter.text)
537+
except NoSuchElementException:
538+
initial_counter = 0
539+
self.chats[0].send_message(muted_message)
540+
self.homes[1].just_fyi("Member 1 checks that chat is muted and message is received")
541+
chat = self.homes[1].get_chat(self.chat_name)
542+
if chat.new_messages_counter.is_element_displayed(30):
543+
self.errors.append("New messages counter near chat name is shown after mute")
544+
try:
545+
after_mute_counter = int(self.homes[1].chats_tab.counter.text)
546+
except NoSuchElementException:
547+
after_mute_counter = 0
548+
if after_mute_counter > initial_counter:
549+
self.errors.append("New messages counter near chats tab button is %s after mute, but should be %s" % (
550+
after_mute_counter, initial_counter))
551+
if not chat.chat_preview.text.startswith("%s: %s" % (self.usernames[0], muted_message)):
552+
self.errors.append("Message text '%s' is not shown in chat preview after mute" % muted_message)
553+
chat.click()
554+
if not self.chats[1].chat_element_by_text(muted_message).is_element_displayed(30):
555+
self.errors.append(
556+
"Message '%s' is not shown in chat for %s after mute" % (muted_message, self.usernames[1]))
557+
self.chats[1].click_system_back_button_until_element_is_shown()
558+
chat.long_press_element()
559+
# expected_text = "Muted until %s today" % device_time + 1
560+
expected_text = "%s %s" % (transl["muted-until"], transl["until-you-turn-it-back-on"])
561+
if not self.homes[1].element_by_text(expected_text).is_element_displayed():
562+
self.errors.append(
563+
"Text '%s' is not shown for muted chat, https://github.com/status-im/status-mobile/issues/16768" %
564+
expected_text)
565+
self.chats[1].just_fyi("Member 1 unmutes the chat")
566+
# self.chats[1].just_fyi("Close app and change device time so chat will be unmuted by timer")
567+
# self.homes[1].put_app_to_background()
568+
# self.homes[1].driver.execute('mobile: shell', {
569+
# 'command': 'date',
570+
# 'args': [str(device_time + 1)]
571+
# })
572+
# self.homes[1].driver.launch_app()
573+
# self.sign_in_views[1].sign_in()
574+
# self.homes[1].chats_tab.click()
575+
# chat.long_press_element()
576+
# if self.homes[1].element_starts_with_text("Muted until").is_element_displayed():
577+
# self.errors.append("Chat is still muted after timeout")
578+
# self.errors.verify_no_errors()
579+
# self.homes[1].click_system_back_button()
580+
self.homes[1].mute_chat_button.click() # ToDo: remove when ^ is enabled
581+
582+
unmuted_message = "Chat is unmuted now"
583+
self.homes[2].just_fyi("Member 2 sends a message")
584+
self.homes[2].get_chat(self.chat_name).click()
585+
try:
586+
initial_counter = int(self.homes[1].chats_tab.counter.text)
587+
except NoSuchElementException:
588+
initial_counter = 0
589+
self.chats[2].send_message(unmuted_message)
590+
self.homes[1].just_fyi("Member 1 checks that chat is unmuted and message is received")
591+
if not chat.new_messages_counter.is_element_displayed(30):
592+
self.errors.append("New messages counter near chat name is not shown after unmute")
593+
try:
594+
after_mute_counter = int(self.homes[1].chats_tab.counter.text)
595+
except NoSuchElementException:
596+
after_mute_counter = 0
597+
if after_mute_counter <= initial_counter:
598+
self.errors.append("New messages counter near chats tab button is %s after unmute, but should be %s" % (
599+
after_mute_counter, initial_counter + 1))
600+
if not chat.chat_preview.text.startswith("%s: %s" % (self.usernames[2], unmuted_message)):
601+
self.errors.append("Message text '%s' is not shown in chat preview after unmute" % unmuted_message)
602+
chat.click()
603+
if not self.chats[1].chat_element_by_text(unmuted_message).is_element_displayed(30):
604+
self.errors.append(
605+
"Message '%s' is not shown in chat for %s after unmute" % (self.usernames[1], unmuted_message))
606+
607+
self.errors.verify_no_errors()

test/appium/tests/critical/test_public_chat_browsing.py

+56-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import datetime
12
import random
23
from datetime import timedelta
34

@@ -7,7 +8,7 @@
78
from dateutil import parser
89
from selenium.common.exceptions import NoSuchElementException, TimeoutException
910

10-
from tests import marks, test_dapp_name, test_dapp_url, run_in_parallel, pytest_config_global
11+
from tests import marks, test_dapp_name, test_dapp_url, run_in_parallel, pytest_config_global, transl
1112
from tests.base_test_case import create_shared_drivers, MultipleSharedDeviceTestCase
1213
from views.chat_view import CommunityView
1314
from views.dbs.waku_backup import user as waku_user
@@ -316,8 +317,8 @@ def prepare_devices(self):
316317
self.community = self.home.create_community(name=self.community_name, description='test description')
317318

318319
self.home.get_chat(self.community_name, community=True).click()
319-
community_view = self.home.get_community_view()
320-
self.channel = community_view.get_channel(self.channel_name).click()
320+
self.community_view = self.home.get_community_view()
321+
self.channel = self.community_view.get_channel(self.channel_name).click()
321322

322323
@marks.testrail_id(702846)
323324
def test_community_navigate_to_channel_when_relaunch(self):
@@ -348,6 +349,58 @@ def test_community_copy_and_paste_message_in_chat_input(self):
348349

349350
self.errors.verify_no_errors()
350351

352+
@marks.testrail_id(703382)
353+
def test_community_mute_community_and_channel(self):
354+
self.home.jump_to_communities_home()
355+
self.home.just_fyi("Mute community and check that channels are also muted")
356+
self.home.mute_chat_long_press(chat_name=self.community_name, mute_period="mute-for-1-hour", community=True)
357+
device_time = self.home.driver.device_time
358+
current_time = datetime.datetime.strptime(device_time, "%Y-%m-%dT%H:%M:%S%z")
359+
expected_time = current_time + datetime.timedelta(hours=1)
360+
expected_text = "Muted until %s %s" % (
361+
expected_time.strftime('%H:%M'),
362+
"today" if current_time.hour < 23 else "tomorrow"
363+
)
364+
self.home.get_chat(self.community_name).long_press_element()
365+
if not self.home.element_by_text(expected_text).is_element_displayed():
366+
self.errors.append("Text '%s' is not shown for muted community" % expected_text)
367+
self.home.click_system_back_button()
368+
369+
self.home.get_chat(self.community_name, community=True).click()
370+
self.community_view.get_channel(self.channel_name).long_press_element()
371+
if not self.home.element_by_text(expected_text).is_element_displayed():
372+
self.errors.append("Text '%s' is not shown for a channel in muted community" % expected_text)
373+
374+
self.home.just_fyi("Unmute channel and check that the community is also unmuted")
375+
self.home.mute_channel_button.click()
376+
self.home.jump_to_communities_home()
377+
self.home.get_chat(self.community_name).long_press_element()
378+
if not self.home.element_by_text("Mute community").is_element_displayed():
379+
self.errors.append("Community is not unmuted when channel is unmuted")
380+
self.home.click_system_back_button()
381+
382+
self.home.just_fyi("Mute channel and check that community is not muted")
383+
self.home.get_chat(self.community_name, community=True).click()
384+
self.home.mute_chat_long_press(chat_name=self.channel_name, mute_period="mute-for-1-week",
385+
community_channel=True)
386+
device_time = self.home.driver.device_time
387+
current_time = datetime.datetime.strptime(device_time, "%Y-%m-%dT%H:%M:%S%z")
388+
expected_time = current_time + datetime.timedelta(days=7)
389+
expected_text = "Muted until %s" % expected_time.strftime('%H:%M %a %d %b')
390+
self.community_view.get_channel(self.channel_name).long_press_element()
391+
if not self.home.element_by_text(expected_text).is_element_displayed():
392+
self.errors.append("Text '%s' is not shown for a muted community channel" % expected_text)
393+
self.home.click_system_back_button()
394+
395+
self.home.jump_to_communities_home()
396+
self.home.get_chat(self.community_name).long_press_element()
397+
if self.home.element_by_text(expected_text).is_element_displayed() or self.home.mute_community_button.text != \
398+
transl["mute-community"]:
399+
self.errors.append("Community is muted when channel is muted")
400+
self.home.click_system_back_button()
401+
402+
self.errors.verify_no_errors()
403+
351404
@marks.testrail_id(703133)
352405
def test_restore_multiaccount_with_waku_backup_remove_switch(self):
353406
self.home.jump_to_communities_home()

test/appium/views/base_view.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def click(self, times_to_click=3):
3737

3838
class UnreadMessagesCountText(Text):
3939
def __init__(self, driver, parent_locator: str):
40-
super().__init__(driver, xpath="(%s//android.widget.TextView)[last()]" % parent_locator)
40+
super().__init__(driver,
41+
xpath="%s/*[@resource-id='counter-component']/android.widget.TextView" % parent_locator)
4142

4243

4344
class TabButton(Button):

test/appium/views/home_view.py

+35-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import time
22

3+
from appium.webdriver.common.mobileby import MobileBy
34
from selenium.common.exceptions import TimeoutException, NoSuchElementException
45

56
from tests import test_dapp_url
67
from views.base_element import Button, Text, BaseElement, SilentButton, CheckBox, EditBox
7-
from views.base_view import BaseView
8+
from views.base_view import BaseView, UnreadMessagesCountText
89

910

1011
class ChatButton(Button):
@@ -72,9 +73,16 @@ def find_element(self):
7273

7374
@property
7475
def new_messages_counter(self):
75-
from views.base_view import UnreadMessagesCountText
76-
desired_counter = UnreadMessagesCountText(self.driver, self.locator)
77-
return desired_counter
76+
if self.community:
77+
return UnreadMessagesCountText(self.driver, self.locator)
78+
79+
class NewMessageCounterText(Text):
80+
def __init__(self, driver, parent_locator: str):
81+
super().__init__(
82+
driver,
83+
xpath="%s//*[@content-desc='new-message-counter']/android.widget.TextView" % parent_locator)
84+
85+
return NewMessageCounterText(self.driver, self.locator)
7886

7987
@property
8088
def chat_preview(self):
@@ -202,6 +210,15 @@ def __init__(self, driver, username=None, index=None):
202210
self.username_text = Text(self.driver, xpath="(%s//android.widget.TextView)[2]" % xpath_locator)
203211

204212

213+
class MuteButton(Button):
214+
def __init__(self, driver, accessibility_id):
215+
super().__init__(driver=driver, accessibility_id=accessibility_id)
216+
217+
@property
218+
def text(self):
219+
return self.find_element().find_element(by=MobileBy.CLASS_NAME, value="android.widget.TextView").text
220+
221+
205222
class HomeView(BaseView):
206223
def __init__(self, driver):
207224
super().__init__(driver)
@@ -254,6 +271,9 @@ def __init__(self, driver):
254271
self.chats_menu_invite_friends_button = Button(self.driver, accessibility_id="chats-menu-invite-friends-button")
255272
self.delete_chat_button = Button(self.driver, translation_id="delete-chat")
256273
self.clear_history_button = Button(self.driver, accessibility_id="clear-history")
274+
self.mute_chat_button = MuteButton(self.driver, accessibility_id="mute-chat")
275+
self.mute_community_button = MuteButton(self.driver, accessibility_id="mute-community")
276+
self.mute_channel_button = MuteButton(self.driver, accessibility_id="chat-toggle-muted")
257277
self.mark_all_messages_as_read_button = Button(self.driver, accessibility_id="mark-as-read")
258278

259279
# Connection icons
@@ -477,6 +497,17 @@ def clear_chat_long_press(self, username):
477497
from views.chat_view import ChatView
478498
ChatView(self.driver).clear_button.click()
479499

500+
def mute_chat_long_press(self, chat_name, mute_period="mute-till-unmute", community=False, community_channel=False):
501+
self.driver.info("Muting chat with %s" % chat_name)
502+
self.get_chat(username=chat_name, community_channel=community_channel).long_press_element()
503+
if community:
504+
self.mute_community_button.click()
505+
elif community_channel:
506+
self.mute_channel_button.click()
507+
else:
508+
self.mute_chat_button.click()
509+
self.element_by_translation_id(mute_period).click()
510+
480511
def get_pn(self, pn_text: str):
481512
self.driver.info("Getting PN by '%s'" % pn_text)
482513
expected_element = PushNotificationElement(self.driver, pn_text)

0 commit comments

Comments
 (0)