tests: test for blocking/unblocking user is now using brand new accounts

This commit is contained in:
Anastasiya Semenkevich 2024-08-28 10:33:50 +03:00 committed by Anastasiya
parent 3cf6614082
commit d698d81e3f
8 changed files with 163 additions and 118 deletions

View File

@ -70,4 +70,5 @@ class BlockPopupWarnings(Enum):
BLOCK_WARNING_PART_1 = 'Blocking a user purges the database of all messages that youve previously received from '
BLOCK_WARNING_PART_2 = ' in all contexts. This can take a moment.'
UNBLOCK_TEXT_1 = 'Unblocking '
UNBLOCK_TEXT_2 = ' will allow new messages you receive from athletic to reach you.'
UNBLOCK_TEXT_2 = ' will allow new messages you receive from '
UNBLOCK_TEXT_3 = ' to reach you.'

View File

@ -17,7 +17,6 @@ class BlockUserPopup(BasePopup):
self._block_warning_box = QObject(names.blockWarningBox_StatusWarningBox)
self._you_will_not_see_text = TextLabel(names.youWillNotSeeText_StatusBaseText)
@allure.step('Wait until appears {0}')
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
self._block_user_button.wait_until_appears(timeout_msec)

View File

@ -40,21 +40,22 @@ never_show_radioButton_StatusRadioButton = {"container": settingsContentBase_Scr
# Contacts View
mainWindow_ContactsView = {"container": statusDesktop_mainWindow, "type": "ContactsView", "unnamed": 1, "visible": True}
mainWindow_Send_contact_request_to_chat_key_StatusButton = {"checkable": False, "container": mainWindow_ContactsView, "objectName": "ContactsView_ContactRequest_Button", "type": "StatusButton", "visible": True}
contactsTabBar_Pending_Requests_StatusTabButton = {"checkable": True, "container": mainWindow_ContactsView, "objectName": "ContactsView_PendingRequest_Button", "type": "StatusTabButton", "visible": True}
contactsTabBar_Pending_Requests_StatusTabButton = {"container": mainWindow_ContactsView, "objectName": "ContactsView_PendingRequest_Button", "type": "StatusTabButton", "visible": True}
settingsContentBaseScrollView_ContactListPanel = {"container": mainWindow_ContactsView, "objectName": "ContactListPanel_ListView", "type": "StatusListView", "visible": True}
settingsContentBaseScrollView_Item = {"container": mainWindow_ContactsView, "type": "Item", "unnamed": 1, "visible": True}
settingsContentBaseScrollView_sentRequests_ContactsListPanel = {"container": mainWindow_ContactsView, "objectName": "sentRequests_ContactsListPanel", "type": "ContactsListPanel", "visible": True}
contactsTabBar_Contacts_StatusTabButton = {"checkable": True, "container": mainWindow_ContactsView, "id": "contactsBtn", "type": "StatusTabButton", "unnamed": 1, "visible": True}
contactsTabBar_Contacts_StatusTabButton = {"container": mainWindow_ContactsView, "id": "contactsBtn", "type": "StatusTabButton", "unnamed": 1, "visible": True}
settingsContentBaseScrollView_receivedRequests_ContactsListPanel = {"container": mainWindow_ContactsView, "objectName": "receivedRequests_ContactsListPanel", "type": "ContactsListPanel", "visible": True}
settingsContentBaseScrollView_mutualContacts_ContactsListPanel = {"container": mainWindow_ContactsView, "id": "mutualContacts", "type": "ContactsListPanel", "unnamed": 1, "visible": True}
settingsContentBaseScrollView_Invite_friends_StatusButton = {"checkable": False, "container": mainWindow_ContactsView, "type": "StatusButton", "unnamed": 1, "visible": True}
settingsContentBaseScrollView_Invite_friends_StatusButton = {"container": mainWindow_ContactsView, "type": "StatusButton", "unnamed": 1, "visible": True}
settingsContentBaseScrollView_NoFriendsRectangle = {"container": mainWindow_ContactsView, "type": "NoFriendsRectangle", "unnamed": 1, "visible": True}
view_Profile_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "viewProfile_StatusItem", "type": "StatusMenuItem", "visible": True}
verify_Identity_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "verifyIdentity_StatusItem", "type": "StatusMenuItem", "visible": True}
respond_to_ID_Request_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "pendingIdentity_StatusItem", "type": "StatusMenuItem", "visible": True}
settingsContentBaseScrollView_Respond_to_ID_Request_StatusFlatButton = {"checkable": False, "container": mainWindow_ContactsView, "objectName": "verifyIdentity_StatusItem", "type": "StatusFlatButton", "unnamed": 1, "visible": True}
contactsTabBar_Blocked_StatusTabButton = {"checkable": True, "container": mainWindow_ContactsView, "objectName": "ContactsView_Blocked_Button", "type": "StatusTabButton", "visible": True}
unblock_user_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "unblock_StatusItem", "type": "StatusMenuItem", "visible": True}
view_Profile_StatusMenuItem = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "viewProfile_StatusItem", "type": "StatusMenuItem", "visible": True}
verify_Identity_StatusMenuItem = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "verifyIdentity_StatusItem", "type": "StatusMenuItem", "visible": True}
respond_to_ID_Request_StatusMenuItem = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "pendingIdentity_StatusItem", "type": "StatusMenuItem", "visible": True}
settingsContentBaseScrollView_Respond_to_ID_Request_StatusFlatButton = {"container": mainWindow_ContactsView, "objectName": "verifyIdentity_StatusItem", "type": "StatusFlatButton", "unnamed": 1, "visible": True}
contactsTabBar_Blocked_StatusTabButton = {"container": mainWindow_ContactsView, "objectName": "ContactsView_Blocked_Button", "type": "StatusTabButton", "visible": True}
unblock_user_StatusMenuItem = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "unblock_StatusItem", "type": "StatusMenuItem", "visible": True}
block_user_StatusMenuItem = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "blockUser_StatusItem", "type": "StatusMenuItem", "visible": True}
# Keycard Settings View
mainWindow_KeycardView = {"container": statusDesktop_mainWindow, "type": "KeycardView", "unnamed": 1, "visible": True}

View File

@ -6,6 +6,7 @@ import allure
import configs.timeouts
import driver
from driver.objects_access import walk_children
from gui.components.settings.block_user_popup import BlockUserPopup
from gui.components.settings.respond_to_id_request_popup import RespondToIDRequestPopup
from gui.components.settings.send_contact_request_popup import SendContactRequest
from gui.components.settings.unblock_user_popup import UnblockUserPopup
@ -120,7 +121,8 @@ class ContactsSettingsView(QObject):
self._view_profile_item = QObject(settings_names.view_Profile_StatusMenuItem)
self._respond_to_id_request_button = Button(
settings_names.settingsContentBaseScrollView_Respond_to_ID_Request_StatusFlatButton)
self._unblock_item = Button(settings_names.unblock_user_StatusMenuItem)
self._unblock_item = QObject(settings_names.unblock_user_StatusMenuItem)
self._block_item = QObject(settings_names.block_user_StatusMenuItem)
@property
@allure.step('Get contact items')
@ -210,7 +212,7 @@ class ContactsSettingsView(QObject):
request = self.find_contact_in_list(contact, timeout_sec)
request.reject()
@allure.step('Open verify identity popup')
@allure.step('Open thee dots menu for contact')
def open_more_options_popup(
self, contact: str, timeout_sec: int = configs.timeouts.MESSAGING_TIMEOUT_SEC):
request = self.find_contact_in_list(contact, timeout_sec)
@ -235,3 +237,8 @@ class ContactsSettingsView(QObject):
def unblock_user(self):
self._unblock_item.click()
return UnblockUserPopup().wait_until_appears()
@allure.step('Block user')
def block_user(self):
self._block_item.click()
return BlockUserPopup().wait_until_appears()

View File

@ -1,103 +0,0 @@
import allure
import pytest
from allure_commons._allure import step
import constants
import driver
from constants import UserAccount
from constants.community_settings import BlockPopupWarnings, ToastMessages
from gui.main_window import MainWindow
import configs
from tests.communities import marks
pytestmark = marks
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/738772',
"Block or unblock someone in Status")
@pytest.mark.case(738772)
@pytest.mark.parametrize('user_data_one, user_data_two, user_data_three', [
(configs.testpath.TEST_USER_DATA / 'squisher', configs.testpath.TEST_USER_DATA / 'athletic',
configs.testpath.TEST_USER_DATA / 'nervous')
])
def test_block_and_unblock_user_from_settings_and_profile(multiple_instances, user_data_one, user_data_two, user_data_three):
user_one: UserAccount = constants.user_account_one
user_two: UserAccount = constants.user_account_two
user_three: UserAccount = constants.user_account_three
timeout = configs.timeouts.UI_LOAD_TIMEOUT_MSEC
main_screen = MainWindow()
with multiple_instances(user_data=user_data_one) as aut_one, multiple_instances(
user_data=user_data_two) as aut_two, multiple_instances(user_data=user_data_three) as aut_three:
with step(f'Launch multiple instances with authorized users {user_one.name}, {user_two.name}, {user_three}'):
for aut, account in zip([aut_one, aut_two, aut_three], [user_one, user_two, user_three]):
aut.attach()
main_screen.wait_until_appears(configs.timeouts.APP_LOAD_TIMEOUT_MSEC).prepare()
main_screen.authorize_user(account)
main_screen.hide()
with step(
f'User {user_one.name}, block contact {user_two.name} from user profile and verify button Unblock '
f'appeared'):
aut_one.attach()
main_screen.prepare()
community_screen = main_screen.left_panel.select_community('Community with 2 users')
profile_popup = community_screen.right_panel.click_member(user_two.name)
block_popup = profile_popup.block_user()
warning_text = BlockPopupWarnings.BLOCK_WARNING_PART_1.value + user_two.name + BlockPopupWarnings.BLOCK_WARNING_PART_2.value
assert driver.waitFor(lambda: block_popup.get_warning_text() == warning_text,
timeout), f'Text is incorrect, actual text is {block_popup.get_warning_text()}, correct text is {warning_text}'
block_popup.block()
with step('Check that Unblock user button appeared'):
assert driver.waitFor(lambda: profile_popup.is_unblock_button_visible,
timeout), f"Unblock button did not appear"
main_screen.left_panel.click()
with step('Check toast message about blocked member'):
toast_messages = main_screen.wait_for_notification()
message_1 = ToastMessages.REMOVED_CONTACT_TOAST.value
message_2 = user_two.name + ToastMessages.BLOCKED_USER_TOAST.value
assert driver.waitFor(lambda: message_1 in toast_messages,
timeout), f"Toast message {message_1} is incorrect, current message is {toast_messages}"
assert driver.waitFor(lambda: message_2 in toast_messages,
timeout), f"Toast message {message_2} is incorrect, current message is {toast_messages}"
main_screen.hide()
with step(f'User {user_two.name} does not see {user_one.name} in contacts list'):
aut_two.attach()
main_screen.prepare()
contacts_settings = main_screen.left_panel.open_settings().left_panel.open_messaging_settings().open_contacts_settings()
assert driver.waitFor(lambda: user_one.name not in contacts_settings.contact_items, timeout)
main_screen.hide()
with step(
f'User {user_one.name}, unblock {user_two.name} from contact settings and verify {user_two.name} was removed from blocked list'):
aut_one.attach()
main_screen.prepare()
contacts_settings = main_screen.left_panel.open_settings().left_panel.open_messaging_settings().open_contacts_settings()
unblock_popup = contacts_settings.open_blocked().open_more_options_popup(user_two.name).unblock_user()
warning_text = BlockPopupWarnings.UNBLOCK_TEXT_1.value + user_two.name + BlockPopupWarnings.UNBLOCK_TEXT_2.value
assert driver.waitFor(lambda: unblock_popup.get_warning_text() == warning_text,
timeout), f'Text is incorrect, actual text is {unblock_popup.get_warning_text()}, correct text is {warning_text}'
unblock_popup.unblock()
with step('Check toast message about unblocked member'):
toast_messages = main_screen.wait_for_notification()
message_2 = user_two.name + ToastMessages.UNBLOCKED_USER_TOAST.value
assert driver.waitFor(lambda: message_2 in toast_messages,
timeout), f"Toast message {message_2} is incorrect, current message is {toast_messages}"
with step(
f'User {user_one.name}, block stranger {user_three.name} from user profile and verify button Unblock appeared'):
community_screen = main_screen.left_panel.select_community('Community with 2 users')
profile_popup = community_screen.right_panel.click_member(user_three.name)
block_popup = profile_popup.block_user()
block_popup.block()
with step('Check that Unblock user button appeared'):
assert driver.waitFor(lambda: profile_popup.is_unblock_button_visible, timeout), f"Unblock button did not appear"
with step(
f'User {user_one.name}, unblock stranger {user_three.name} from user profile and verify that Unblock button dissapeared and send request is visible again'):
profile_popup.unblock_user().unblock()
assert driver.waitFor(lambda: profile_popup.is_send_request_button_visible(), timeout)

View File

@ -25,7 +25,6 @@ pytestmark = marks
'channel_name, channel_description, channel_emoji, channel_emoji_image, channel_color, new_channel_name, '
'new_channel_description, new_channel_emoji',
[('Channel', 'Description', 'sunglasses', None, '#4360df', 'New-channel', 'New channel description', 'thumbsup')])
# @pytest.mark.critical TODO: https://github.com/status-im/desktop-qa-automation/issues/658
def test_create_edit_remove_community_channel(main_screen, channel_name, channel_description, channel_emoji,
channel_emoji_image,
channel_color, new_channel_name, new_channel_description,
@ -169,6 +168,7 @@ def test_member_cannot_see_hidden_channel(multiple_instances, user_data_one, use
assert driver.waitFor(lambda: channel not in community_screen.left_panel.channels,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/737070',
'Owner can view and post in a non restricted channel')
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/737074',

View File

@ -35,7 +35,7 @@ def test_group_chat(multiple_instances):
multiple_instances(user_data=None) as aut_one, \
multiple_instances(user_data=None) as aut_two, \
multiple_instances(user_data=None) as aut_three:
with step(f'Launch multiple instances with authorized users {user_one.name}, {user_two.name}, {user_three}'):
with step(f'Launch multiple instances with new users {user_one.name}, {user_two.name}, {user_three}'):
for aut, account in zip([aut_one, aut_two, aut_three], [user_one, user_two, user_three]):
aut.attach()
main_window.wait_until_appears(configs.timeouts.APP_LOAD_TIMEOUT_MSEC).prepare()

View File

@ -0,0 +1,140 @@
import allure
import pytest
from allure_commons._allure import step
import constants
import driver
from constants import UserAccount, RandomUser
from constants.community_settings import BlockPopupWarnings, ToastMessages
from gui.main_window import MainWindow
import configs
from gui.screens.messages import ToolBar
from gui.screens.settings_messaging import ContactItem
from tests.communities import marks
pytestmark = marks
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/738772',
"Block or unblock someone in Status")
@pytest.mark.case(738772)
def test_block_and_unblock_user_from_settings_and_profile(multiple_instances):
user_one: UserAccount = RandomUser()
user_two: UserAccount = RandomUser()
user_three: UserAccount = RandomUser()
timeout = configs.timeouts.UI_LOAD_TIMEOUT_MSEC
main_screen = MainWindow()
with \
multiple_instances(user_data=None) as aut_one, \
multiple_instances(user_data=None) as aut_two, \
multiple_instances(user_data=None) as aut_three:
with step(f'Launch multiple instances with new users {user_one.name}, {user_two.name}, {user_three.name}'):
for aut, account in zip([aut_one, aut_two, aut_three], [user_one, user_two, user_three]):
aut.attach()
main_screen.wait_until_appears(configs.timeouts.APP_LOAD_TIMEOUT_MSEC).prepare()
main_screen.authorize_user(account)
main_screen.hide()
with step(f'User {user_two.name}, get chat key'):
aut_two.attach()
main_screen.prepare()
profile_popup = main_screen.left_panel.open_online_identifier().open_profile_popup_from_online_identifier()
user_2_chat_key = profile_popup.copy_chat_key
profile_popup.close()
main_screen.hide()
with step(f'User {user_one.name}, send contact request to {user_two.name}'):
aut_one.attach()
main_screen.prepare()
settings = main_screen.left_panel.open_settings()
contact_request_form = settings.left_panel.open_messaging_settings().open_contacts_settings().open_contact_request_form()
contact_request_form.send(user_2_chat_key, f'Hello {user_two.name}')
with step(f'User {user_two.name}, accept contact request from {user_one.name} via activity center'):
aut_two.attach()
main_screen.prepare()
activity_center = ToolBar().open_activity_center()
request = activity_center.find_contact_request_in_list(user_one.name, timeout)
activity_center.click_activity_center_button(
'Contact requests').accept_contact_request(request)
activity_center.click()
main_screen.hide()
with step(f'User {user_three.name}, get chat key'):
aut_three.attach()
main_screen.prepare()
profile_popup = main_screen.left_panel.open_online_identifier().open_profile_popup_from_online_identifier()
user_3_chat_key = profile_popup.copy_chat_key
profile_popup.close()
main_screen.hide()
with step(f'User {user_two.name}, send contact request to {user_three.name}'):
aut_two.attach()
main_screen.prepare()
settings = main_screen.left_panel.open_settings()
contact_request_form = settings.left_panel.open_messaging_settings().open_contacts_settings().open_contact_request_form()
contact_request_form.send(user_3_chat_key, f'Hello {user_three.name}')
main_screen.hide()
with step(f'User {user_three.name}, accept contact request from {user_two.name} via activity center'):
aut_three.attach()
main_screen.prepare()
activity_center = ToolBar().open_activity_center()
request = activity_center.find_contact_request_in_list(user_two.name, timeout)
activity_center.click_activity_center_button(
'Contact requests').accept_contact_request(request)
activity_center.click()
main_screen.hide()
with step(
f'User {user_one.name}, block contact {user_two.name} from user profile and verify button Block '
f'appeared'):
aut_one.attach()
main_screen.prepare()
contacts_settings = main_screen.left_panel.open_settings().left_panel.open_messaging_settings().open_contacts_settings()
assert driver.waitFor(lambda: user_two.name in [str(contact) for contact in contacts_settings.contact_items], timeout)
block_popup = contacts_settings.open_contacts().open_more_options_popup(user_two.name).block_user()
warning_text = BlockPopupWarnings.BLOCK_WARNING_PART_1.value + user_two.name + BlockPopupWarnings.BLOCK_WARNING_PART_2.value
assert driver.waitFor(lambda: block_popup.get_warning_text() == warning_text,
timeout), f'Text is incorrect, actual text is {block_popup.get_warning_text()}, correct text is {warning_text}'
block_popup.block()
with step('Check toast message about blocked member'):
toast_messages = main_screen.wait_for_notification()
message_1 = ToastMessages.REMOVED_CONTACT_TOAST.value
message_2 = user_two.name + ToastMessages.BLOCKED_USER_TOAST.value
assert driver.waitFor(lambda: message_1 in toast_messages,
timeout), f"Toast message {message_1} is incorrect, current message is {toast_messages}"
assert driver.waitFor(lambda: message_2 in toast_messages,
timeout), f"Toast message {message_2} is incorrect, current message is {toast_messages}"
main_screen.hide()
with step(f'User {user_two.name} does not see {user_one.name} in contacts list'):
aut_two.attach()
main_screen.prepare()
contacts_settings = main_screen.left_panel.open_settings().left_panel.open_messaging_settings().open_contacts_settings()
assert driver.waitFor(lambda: user_one.name not in [str(contact) for contact in contacts_settings.contact_items], timeout)
main_screen.hide()
with step(
f'User {user_one.name}, unblock {user_two.name} from contact settings and verify {user_two.name} was removed from blocked list'):
aut_one.attach()
main_screen.prepare()
contacts_settings = main_screen.left_panel.open_settings().left_panel.open_messaging_settings().open_contacts_settings()
unblock_popup = contacts_settings.open_blocked().open_more_options_popup(user_two.name).unblock_user()
warning_text = \
BlockPopupWarnings.UNBLOCK_TEXT_1.value + user_two.name + \
BlockPopupWarnings.UNBLOCK_TEXT_2.value + user_two.name + \
BlockPopupWarnings.UNBLOCK_TEXT_3.value
assert driver.waitFor(lambda: unblock_popup.get_warning_text() == warning_text,
timeout), f'Text is incorrect, actual text is {unblock_popup.get_warning_text()}, correct text is {warning_text}'
unblock_popup.unblock()
with step('Check toast message about unblocked member'):
toast_messages = main_screen.wait_for_notification()
message_2 = user_two.name + ToastMessages.UNBLOCKED_USER_TOAST.value
assert driver.waitFor(lambda: message_2 in toast_messages,
timeout), f"Toast message {message_2} is incorrect, current message is {toast_messages}"