Skip to content

Commit 3f607ce

Browse files
committed
e2e: mute chats
1 parent 0ac6817 commit 3f607ce

File tree

6 files changed

+211
-16
lines changed

6 files changed

+211
-16
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

+40-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,45 @@ 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("Text '%s' is now shown" % expected_text)
1405+
self.home_1.mute_chat_button.click()
1406+
1407+
unmuted_message = "after unmute"
1408+
self.chat_2.send_message(unmuted_message)
1409+
if not chat.new_messages_counter.is_element_displayed(
1410+
30) or not self.home_1.chats_tab.counter.is_element_displayed(10):
1411+
self.errors.append("New messages counter is not shown after unmute")
1412+
if not chat.chat_preview.text.startswith(unmuted_message):
1413+
self.errors.append("Message text '%s' is not shown in chat preview after unmute" % unmuted_message)
1414+
chat.click()
1415+
if not self.chat_1.chat_element_by_text(unmuted_message).is_element_displayed(30):
1416+
self.errors.append("Message '%s' is not shown in chat for receiver after unmute" % unmuted_message)
1417+
1418+
self.errors.verify_no_errors()
1419+
13811420
@marks.testrail_id(702784)
13821421
def test_1_1_chat_delete_via_long_press_relogin(self):
13831422
self.home_2.click_system_back_button_until_element_is_shown()

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

+92-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,89 @@ 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("Text '%s' is now shown" % expected_text)
563+
self.chats[1].just_fyi("Member 1 unmutes the chat")
564+
# self.chats[1].just_fyi("Close app and change device time so chat will be unmuted by timer")
565+
# self.homes[1].put_app_to_background()
566+
# self.homes[1].driver.execute('mobile: shell', {
567+
# 'command': 'date',
568+
# 'args': [str(device_time + 1)]
569+
# })
570+
# self.homes[1].driver.launch_app()
571+
# self.sign_in_views[1].sign_in()
572+
# self.homes[1].chats_tab.click()
573+
# chat.long_press_element()
574+
# if self.homes[1].element_starts_with_text("Muted until").is_element_displayed():
575+
# self.errors.append("Chat is still muted after timeout")
576+
# self.errors.verify_no_errors()
577+
# self.homes[1].click_system_back_button()
578+
self.homes[1].mute_chat_button.click() # ToDo: remove when ^ is enabled
579+
580+
unmuted_message = "Chat is unmuted now"
581+
self.homes[2].just_fyi("Member 2 sends a message")
582+
self.homes[2].get_chat(self.chat_name).click()
583+
try:
584+
initial_counter = int(self.homes[1].chats_tab.counter.text)
585+
except NoSuchElementException:
586+
initial_counter = 0
587+
self.chats[2].send_message(unmuted_message)
588+
self.homes[1].just_fyi("Member 1 checks that chat is unmuted and message is received")
589+
if not chat.new_messages_counter.is_element_displayed(30):
590+
self.errors.append("New messages counter near chat name is not shown after unmute")
591+
try:
592+
after_mute_counter = int(self.homes[1].chats_tab.counter.text)
593+
except NoSuchElementException:
594+
after_mute_counter = 0
595+
if after_mute_counter <= initial_counter:
596+
self.errors.append("New messages counter near chats tab button is %s after unmute, but should be %s" % (
597+
after_mute_counter, initial_counter + 1))
598+
if not chat.chat_preview.text.startswith("%s: %s" % (self.usernames[2], unmuted_message)):
599+
self.errors.append("Message text '%s' is not shown in chat preview after unmute" % unmuted_message)
600+
chat.click()
601+
if not self.chats[1].chat_element_by_text(unmuted_message).is_element_displayed(30):
602+
self.errors.append(
603+
"Message '%s' is not shown in chat for %s after unmute" % (self.usernames[1], unmuted_message))
604+
605+
self.errors.verify_no_errors()

test/appium/tests/critical/test_public_chat_browsing.py

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

@@ -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,52 @@ 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 also 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 %m %b')
390+
self.home.jump_to_communities_home()
391+
self.home.get_chat(self.community_name).long_press_element()
392+
if not self.home.element_by_text(expected_text).is_element_displayed():
393+
self.errors.append("Text '%s' is not shown for community when channel is muted" % expected_text)
394+
self.home.click_system_back_button()
395+
396+
self.errors.verify_no_errors()
397+
351398
@marks.testrail_id(703133)
352399
def test_restore_multiaccount_with_waku_backup_remove_switch(self):
353400
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

+25-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from tests import test_dapp_url
66
from views.base_element import Button, Text, BaseElement, SilentButton, CheckBox, EditBox
7-
from views.base_view import BaseView
7+
from views.base_view import BaseView, UnreadMessagesCountText
88

99

1010
class ChatButton(Button):
@@ -72,9 +72,16 @@ def find_element(self):
7272

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

7986
@property
8087
def chat_preview(self):
@@ -254,6 +261,9 @@ def __init__(self, driver):
254261
self.chats_menu_invite_friends_button = Button(self.driver, accessibility_id="chats-menu-invite-friends-button")
255262
self.delete_chat_button = Button(self.driver, translation_id="delete-chat")
256263
self.clear_history_button = Button(self.driver, accessibility_id="clear-history")
264+
self.mute_chat_button = Button(self.driver, accessibility_id="mute-chat")
265+
self.mute_community_button = Button(self.driver, accessibility_id="mute-community")
266+
self.mute_channel_button = Button(self.driver, accessibility_id="chat-toggle-muted")
257267
self.mark_all_messages_as_read_button = Button(self.driver, accessibility_id="mark-as-read")
258268

259269
# Connection icons
@@ -477,6 +487,17 @@ def clear_chat_long_press(self, username):
477487
from views.chat_view import ChatView
478488
ChatView(self.driver).clear_button.click()
479489

490+
def mute_chat_long_press(self, chat_name, mute_period="mute-till-unmute", community=False, community_channel=False):
491+
self.driver.info("Muting chat with %s" % chat_name)
492+
self.get_chat(username=chat_name, community_channel=community_channel).long_press_element()
493+
if community:
494+
self.mute_community_button.click()
495+
elif community_channel:
496+
self.mute_channel_button.click()
497+
else:
498+
self.mute_chat_button.click()
499+
self.element_by_translation_id(mute_period).click()
500+
480501
def get_pn(self, pn_text: str):
481502
self.driver.info("Getting PN by '%s'" % pn_text)
482503
expected_element = PushNotificationElement(self.driver, pn_text)

0 commit comments

Comments
 (0)