From 9b11caf5a2a1bb2c8228c34651e7717df20875e2 Mon Sep 17 00:00:00 2001 From: Valentina Novgorodtceva Date: Fri, 16 Feb 2024 12:08:57 +0700 Subject: [PATCH] test: updated permission test with editing and deleting --- test/e2e/constants/community_settings.py | 2 + .../{settings => }/changes_detected_popup.py | 12 ++++ test/e2e/gui/components/delete_popup.py | 9 ++- test/e2e/gui/objects_map/names.py | 8 +++ test/e2e/gui/screens/community_settings.py | 49 ++++++++++++-- .../test_communities_permissions.py | 67 ++++++++++++++++--- .../test_settings_profile_edit.py | 2 +- 7 files changed, 132 insertions(+), 17 deletions(-) rename test/e2e/gui/components/{settings => }/changes_detected_popup.py (55%) diff --git a/test/e2e/constants/community_settings.py b/test/e2e/constants/community_settings.py index a4739f59a6..b1995186a4 100644 --- a/test/e2e/constants/community_settings.py +++ b/test/e2e/constants/community_settings.py @@ -31,3 +31,5 @@ class AirdropsElements(Enum): class ToastMessages(Enum): CREATE_PERMISSION_TOAST = 'Community permission created' + UPDATE_PERMISSION_TOAST = 'Community permission updated' + DELETE_PERMISSION_TOAST = 'Community permission updated' diff --git a/test/e2e/gui/components/settings/changes_detected_popup.py b/test/e2e/gui/components/changes_detected_popup.py similarity index 55% rename from test/e2e/gui/components/settings/changes_detected_popup.py rename to test/e2e/gui/components/changes_detected_popup.py index 2aed610a13..9a0f099307 100644 --- a/test/e2e/gui/components/settings/changes_detected_popup.py +++ b/test/e2e/gui/components/changes_detected_popup.py @@ -16,3 +16,15 @@ class ChangesDetectedToastMessage(QObject): def save(self): self._save_button.click() self.wait_until_hidden() + + +class PermissionsChangesDetectedToastMessage(QObject): + + def __init__(self): + super().__init__(names.editPermissionView_settingsDirtyToastMessage_SettingsDirtyToastMessage) + self._update_permission_button = Button(names.editPermissionView_Save_changes_StatusButton) + + @allure.step('Update permission') + def update_permission(self): + self._update_permission_button.click() + self.wait_until_hidden() diff --git a/test/e2e/gui/components/delete_popup.py b/test/e2e/gui/components/delete_popup.py index d1399a293b..d0dee0c647 100644 --- a/test/e2e/gui/components/delete_popup.py +++ b/test/e2e/gui/components/delete_popup.py @@ -22,10 +22,15 @@ class DeletePopup(BasePopup): raise ex - - class DeleteCategoryPopup(DeletePopup): def __init__(self): super().__init__() self._delete_button = Button(names.confirm_StatusButton) + + +class DeletePermissionPopup(DeletePopup): + + def __init__(self): + super().__init__() + self._delete_button = Button(names.confirm_permission_delete_StatusButton) diff --git a/test/e2e/gui/objects_map/names.py b/test/e2e/gui/objects_map/names.py index bbdaa3ec5c..d546f853f3 100644 --- a/test/e2e/gui/objects_map/names.py +++ b/test/e2e/gui/objects_map/names.py @@ -230,6 +230,7 @@ mainWallet_AddEditAccountPopup_AccountEmoji = {"container": statusDesktop_mainWi o_StatusDialogBackground = {"container": statusDesktop_mainWindow_overlay, "type": "StatusDialogBackground", "unnamed": 1, "visible": True} delete_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "deleteChatConfirmationDialogDeleteButton", "type": "StatusButton", "visible": True} confirm_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "confirmDeleteCategoryButton", "type": "StatusButton", "visible": True} +confirm_permission_delete_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "id": "confirmButton", "type": "StatusButton", "unnamed": 1, "visible": True} # Authenticate Popup keycardSharedPopupContent_KeycardPopupContent = {"container": statusDesktop_mainWindow_overlay, "objectName": "KeycardSharedPopupContent", "type": "KeycardPopupContent", "visible": True} @@ -727,6 +728,12 @@ mainWindow_PermissionsSettingsPanel = {"container": statusDesktop_mainWindow, "t whoHoldsTagListItem = {"container": mainWindow_PermissionsView, "objectName": "whoHoldsStatusListItem", "type": "StatusListItemTag", "visible": True} isAllowedTagListItem = {"container": mainWindow_PermissionsView, "objectName": "isAllowedStatusListItem", "type": "StatusListItemTag", "visible": True} inCommunityTagListItem = {"container": mainWindow_PermissionsView, "objectName": "inCommunityStatusListItem", "type": "StatusListItemTag", "visible": True} +edit_pencil_icon_StatusIcon = {"container": mainWindow_PermissionsView, "objectName": "edit_pencil-icon", "type": "StatusIcon", "visible": True} +delete_icon_StatusIcon = {"container": mainWindow_PermissionsView, "objectName": "delete-icon", "type": "StatusIcon", "visible": True} +hide_icon_StatusIcon = {"container": mainWindow_PermissionsView, "objectName": "hide-icon", "type": "StatusIcon", "visible": True} +editPermissionView_settingsDirtyToastMessage_SettingsDirtyToastMessage = {"container": mainWindow_editPermissionView_EditPermissionView, "id": "settingsDirtyToastMessage", "type": "SettingsDirtyToastMessage", "unnamed": 1, "visible": True} +update_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "type": "StatusButton", "unnamed": 1, "visible": True} +isAllowedToEditPermissionView_StatusListItemTag = {"container": mainWindow_editPermissionView_EditPermissionView, "type": "StatusListItemTag", "unnamed": 1, "visible": True} # Edit Community mainWindow_communityEditPanelScrollView_EditSettingsPanel = {"container": statusDesktop_mainWindow, "objectName": "communityEditPanelScrollView", "type": "EditSettingsPanel", "visible": True} @@ -750,6 +757,7 @@ communityEditPanelScrollView_pinMessagesToggle_StatusCheckBox = {"checkable": Tr communityEditPanelScrollView_editCommunityIntroInput_TextEdit = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCommunityIntroInput", "type": "TextEdit", "visible": True} communityEditPanelScrollView_editCommunityOutroInput_TextEdit = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCommunityOutroInput", "type": "TextEdit", "visible": True} mainWindow_Save_changes_StatusButton = {"container": statusDesktop_mainWindow, "objectName": "settingsDirtyToastMessageSaveButton", "type": "DisabledTooltipButton", "visible": True} +editPermissionView_Save_changes_StatusButton = {"container": mainWindow_editPermissionView_EditPermissionView, "objectName": "settingsDirtyToastMessageSaveButton", "type": "DisabledTooltipButton", "visible": True} croppedImageEditLogo = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCroppedImageItem_Community logo", "type": "EditCroppedImagePanel", "visible": True} croppedImageEditBanner = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCroppedImageItem_Community banner", "type": "EditCroppedImagePanel", "visible": True} diff --git a/test/e2e/gui/screens/community_settings.py b/test/e2e/gui/screens/community_settings.py index b9251c8f76..7c9924f278 100644 --- a/test/e2e/gui/screens/community_settings.py +++ b/test/e2e/gui/screens/community_settings.py @@ -114,7 +114,8 @@ class EditCommunityView(QObject): self._select_color_button = Button(names.communityEditPanelScrollView_StatusPickerButton) self._choose_tag_button = Button(names.communityEditPanelScrollView_Choose_StatusPickerButton) self._tag_item = QObject(names.communityEditPanelScrollView_StatusCommunityTag) - self._archive_support_checkbox = CheckBox(names.communityEditPanelScrollView_archiveSupportToggle_StatusCheckBox) + self._archive_support_checkbox = CheckBox( + names.communityEditPanelScrollView_archiveSupportToggle_StatusCheckBox) self._request_to_join_checkbox = CheckBox(names.communityEditPanelScrollView_requestToJoinToggle_StatusCheckBox) self._pin_messages_checkbox = CheckBox(names.communityEditPanelScrollView_pinMessagesToggle_StatusCheckBox) self._intro_text_edit = TextEdit(names.communityEditPanelScrollView_editCommunityIntroInput_TextEdit) @@ -376,6 +377,14 @@ class PermissionsIntroView(QObject): self._welcome_checklist_1 = TextLabel(names.community_welcome_screen_checkList_element1) self._welcome_checklist_2 = TextLabel(names.community_welcome_screen_checkList_element2) self._welcome_checklist_3 = TextLabel(names.community_welcome_screen_checkList_element3) + self._edit_permission_button = QObject(names.edit_pencil_icon_StatusIcon) + self._delete_permission_button = QObject(names.delete_icon_StatusIcon) + self._hide_icon = QObject(names.hide_icon_StatusIcon) + + @property + @allure.step('Get hide icon visibility') + def is_hide_icon_visible(self) -> bool: + return self._hide_icon.is_visible @property @allure.step('Get permission welcome image path') @@ -409,6 +418,15 @@ class PermissionsIntroView(QObject): def is_add_new_permission_button_present(self) -> bool: return self._add_new_permission_button.exists + @allure.step('Open edit permission view') + def open_edit_permission_view(self): + self._edit_permission_button.click() + return PermissionsSettingsView().wait_until_appears() + + @allure.step('Click delete permission button') + def click_delete_permission(self): + self._delete_permission_button.click() + class PermissionsSettingsView(QObject): def __init__(self): @@ -429,6 +447,7 @@ class PermissionsSettingsView(QObject): self._who_holds_tag = QObject(names.whoHoldsTagListItem) self._is_allowed_tag = QObject(names.isAllowedTagListItem) self._in_community_in_channel_tag = QObject(names.inCommunityTagListItem) + self._is_allowed_to_edit_tag = QObject(names.isAllowedToEditPermissionView_StatusListItemTag) @allure.step('Get titles of Who holds tags') def get_who_holds_tags_titles(self) -> typing.List[str]: @@ -459,21 +478,32 @@ class PermissionsSettingsView(QObject): self._asset_item.click() self._who_holds_asset_field.wait_until_hidden() self._who_holds_amount_field.text = amount - self._add_button.click() + self.click_add_button() @allure.step('Choose option from Is allowed to context menu') def set_is_allowed_to(self, name): self.open_is_allowed_to_context_menu() self._is_allowed_to_option_button.real_name['objectName'] = name self._is_allowed_to_option_button.wait_until_appears().click() - self._add_button.click() + self.click_add_button() @allure.step('Choose channel from In context menu') def set_in(self, in_general): if in_general == '#general': self.open_in_context_menu() self._in_general_button.wait_until_appears().click() - self._add_button.click() + self.click_add_button() + + @allure.step('Click add button') + def click_add_button(self, attempt: int = 2): + self._add_button.click() + try: + self._add_button.wait_until_hidden() + except AssertionError as err: + if attempt: + self.click_add_button(attempt - 1) + else: + raise err @allure.step('Click create permission') def create_permission(self): @@ -503,3 +533,14 @@ class PermissionsSettingsView(QObject): driver.mouseClick(child) return raise LookupError('Add button for in not found') + + @allure.step('Switch hide permission checkbox') + def switch_hide_permission_checkbox(self, state): + self._hide_permission_checkbox.set(state) + + @allure.step('Change allowed to option from permission') + def set_allowed_to_from_permission(self, name): + self._is_allowed_to_edit_tag.click() + self._is_allowed_to_option_button.real_name['objectName'] = name + self._is_allowed_to_option_button.wait_until_appears().click() + self.click_add_button() diff --git a/test/e2e/tests/communities/test_communities_permissions.py b/test/e2e/tests/communities/test_communities_permissions.py index d45ad0235e..d2c76b03b2 100644 --- a/test/e2e/tests/communities/test_communities_permissions.py +++ b/test/e2e/tests/communities/test_communities_permissions.py @@ -2,42 +2,48 @@ import allure import pytest from allure_commons._allure import step +from gui.components.changes_detected_popup import PermissionsChangesDetectedToastMessage +from gui.components.delete_popup import DeletePermissionPopup from gui.components.toast_message import ToastMessage +from gui.screens.community_settings import PermissionsIntroView from . import marks import constants import driver -from constants.community_settings import PermissionsElements, ToastMessages -from constants.images_paths import PERMISSION_WELCOME_IMAGE_PATH +from constants.community_settings import ToastMessages from gui.main_window import MainWindow pytestmark = marks @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703632', - 'Manage community: Adding new permissions') -@pytest.mark.case(703632) + 'Manage community: Adding new permissions, Editing permissions, Deleting permission') +@pytest.mark.case(703632, 703162, 705016) @pytest.mark.parametrize('params', [constants.community_params]) @pytest.mark.parametrize( 'checkbox_state, first_asset, second_asset, amount, allowed_to, in_channel, asset_title, second_asset_title, ' 'allowed_to_title', [ - pytest.param(True, 'Dai Stablecoin', False, '10', 'becomeMember', False, '10 DAI', False, 'Become member'), - pytest.param(True, 'Ether', False, '1', 'becomeAdmin', False, '1 ETH', False, 'Become an admin'), + pytest.param(True, 'Dai Stablecoin', False, '10', 'becomeMember', False, '10 DAI', False, 'Become member', + marks=pytest.mark.critical), + pytest.param(True, 'Ether', False, '1', 'becomeAdmin', False, '1 ETH', False, 'Become an admin', + marks=pytest.mark.critical), pytest.param(True, 'Ether', 'Dai Stablecoin', '10', 'viewAndPost', '#general', '10 ETH', '10 DAI', 'View and post'), pytest.param(True, 'Ether', 'Dai Stablecoin', '10', 'viewOnly', '#general', '10 ETH', '10 DAI', 'View only'), pytest.param(False, False, False, False, 'becomeAdmin', False, False, False, 'Become an admin') ]) -@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/495") -def test_adding_permissions(main_screen: MainWindow, params, checkbox_state: bool, first_asset, second_asset, amount, - allowed_to: str, in_channel, asset_title, second_asset_title, allowed_to_title: str): +# @pytest.mark.xfail(reason="https://github.com/status-im/desktop-qa-automation/issues/495") +def test_add_edit_and_remove_permissions(main_screen: MainWindow, params, checkbox_state: bool, first_asset, + second_asset, amount, allowed_to: str, in_channel, asset_title, + second_asset_title, allowed_to_title: str): main_screen.create_community(params) with step('Open add new permission page'): community_screen = main_screen.left_panel.select_community(params['name']) community_setting = community_screen.left_panel.open_community_settings() - permissions_settings = community_setting.left_panel.open_permissions().add_new_permission() + permissions_intro_view = community_setting.left_panel.open_permissions() + permissions_settings = permissions_intro_view.add_new_permission() with step('Create new permission'): permissions_settings.set_who_holds_checkbox_state(checkbox_state) @@ -66,3 +72,44 @@ def test_adding_permissions(main_screen: MainWindow, params, checkbox_state: boo lambda: params['name'] in permissions_settings.get_in_community_in_channel_tags_titles()) if in_channel: assert driver.waitFor(lambda: in_channel in permissions_settings.get_in_community_in_channel_tags_titles()) + + with step('Edit permission'): + edit_permission_view = permissions_intro_view.open_edit_permission_view() + if allowed_to is 'becomeAdmin' and checkbox_state is True: + permissions_settings.set_who_holds_checkbox_state(False) + elif checkbox_state is False: + permissions_settings.set_allowed_to_from_permission('becomeMember') + else: + edit_permission_view.switch_hide_permission_checkbox(True) + + changes_popup = PermissionsChangesDetectedToastMessage().wait_until_appears() + + with step('Confirm changes and verify that permission was changed'): + changes_popup.update_permission() + if allowed_to is 'becomeAdmin' and checkbox_state is True: + if asset_title is not False: + assert driver.waitFor(lambda: asset_title not in permissions_settings.get_who_holds_tags_titles()) + if second_asset_title is not False: + assert driver.waitFor( + lambda: second_asset_title not in permissions_settings.get_who_holds_tags_titles()) + elif checkbox_state is False: + assert driver.waitFor(lambda: 'Become member' in permissions_settings.get_is_allowed_tags_titles()) + else: + assert driver.waitFor(lambda: permissions_intro_view.is_hide_icon_visible) + + with step('Check toast message for edited permission'): + messages = ToastMessage().get_toast_messages + assert ToastMessages.UPDATE_PERMISSION_TOAST.value in messages, \ + f"Toast message is incorrect, current message is {message}" + + with step('Delete permission'): + permissions_intro_view.click_delete_permission() + DeletePermissionPopup().wait_until_appears().delete() + + with step('Verify that permission was deleted'): + assert driver.waitFor(lambda: PermissionsIntroView().is_visible) + + with step('Check toast message for deleted permission'): + messages = ToastMessage().get_toast_messages + assert ToastMessages.DELETE_PERMISSION_TOAST.value in messages, \ + f"Toast message is incorrect, current message is {message}" diff --git a/test/e2e/tests/settings/settings_profile/test_settings_profile_edit.py b/test/e2e/tests/settings/settings_profile/test_settings_profile_edit.py index 94f1aff31d..af562eb13e 100644 --- a/test/e2e/tests/settings/settings_profile/test_settings_profile_edit.py +++ b/test/e2e/tests/settings/settings_profile/test_settings_profile_edit.py @@ -5,7 +5,7 @@ from . import marks import constants from driver.aut import AUT -from gui.components.settings.changes_detected_popup import ChangesDetectedToastMessage +from gui.components.changes_detected_popup import ChangesDetectedToastMessage from gui.main_window import MainWindow pytestmark = marks