|
2 | 2 | from _pytest.outcomes import Failed
|
3 | 3 | from selenium.common.exceptions import NoSuchElementException, TimeoutException
|
4 | 4 |
|
5 |
| -from tests import marks, run_in_parallel |
| 5 | +from tests import marks, run_in_parallel, transl |
6 | 6 | from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
|
7 | 7 | from views.chat_view import ChatView
|
8 | 8 | from views.sign_in_view import SignInView
|
@@ -151,18 +151,18 @@ def prepare_devices(self):
|
151 | 151 | self.message_before_adding = 'message before adding new user'
|
152 | 152 | self.message_to_admin = 'Hey, admin!'
|
153 | 153 | 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] |
155 | 155 | self.usernames = ('user admin', 'member_1', 'member_2')
|
156 | 156 | self.loop.run_until_complete(
|
157 | 157 | run_in_parallel(
|
158 | 158 | (
|
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]}) |
162 | 162 | )
|
163 | 163 | )
|
164 | 164 | )
|
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] |
166 | 166 | self.public_keys = self.loop.run_until_complete(
|
167 | 167 | run_in_parallel(
|
168 | 168 | (
|
@@ -517,3 +517,89 @@ def test_group_chat_pin_messages(self):
|
517 | 517 | )
|
518 | 518 |
|
519 | 519 | 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() |
0 commit comments