diff --git a/test/e2e/constants/permissions.py b/test/e2e/constants/permissions.py new file mode 100644 index 0000000000..3959c27376 --- /dev/null +++ b/test/e2e/constants/permissions.py @@ -0,0 +1,8 @@ +from enum import Enum + +class PermissionsElements(Enum): + WELCOME_TITLE = "Permissions" + WELCOME_SUBTITLE = 'You can manage your community by creating and issuing membership and access permissions' + WELCOME_CHECKLIST_ELEMENT_1 = 'Give individual members access to private channels' + WELCOME_CHECKLIST_ELEMENT_2 = 'Monetise your community with subscriptions and fees' + WELCOME_CHECKLIST_ELEMENT_3 = 'Require holding a token or NFT to obtain exclusive membership rights' diff --git a/test/e2e/ext/vp/communities/test_permissions/test_permissions_screen_overview/permission_welcome_image.png b/test/e2e/ext/vp/communities/test_permissions/test_permissions_screen_overview/permission_welcome_image.png new file mode 100644 index 0000000000..2b2017f7d4 Binary files /dev/null and b/test/e2e/ext/vp/communities/test_permissions/test_permissions_screen_overview/permission_welcome_image.png differ diff --git a/test/e2e/gui/objects_map/community_names.py b/test/e2e/gui/objects_map/community_names.py index d4c9c1eac7..c1c11e8b2c 100644 --- a/test/e2e/gui/objects_map/community_names.py +++ b/test/e2e/gui/objects_map/community_names.py @@ -44,6 +44,8 @@ mainWindow_communitySettingsBackToCommunityButton_StatusBaseText = {"container": mainWindow_listView_StatusListView = {"container": mainWindow_communityLoader_Loader, "id": "listView", "type": "StatusListView", "unnamed": 1, "visible": True} overview_StatusNavigationListItem = {"container": mainWindow_listView_StatusListView, "objectName": "CommunitySettingsView_NavigationListItem_Overview", "type": "StatusNavigationListItem", "visible": True} members_StatusNavigationListItem = {"container": mainWindow_listView_StatusListView, "index": 1, "objectName": "CommunitySettingsView_NavigationListItem_Members", "type": "StatusNavigationListItem", "visible": True} +permissions_StatusNavigationListItem = {"container": mainWindow_listView_StatusListView, "index": 2, "objectName": "CommunitySettingsView_NavigationListItem_Permissions", "type": "StatusNavigationListItem", "visible": True} + # Overview Settings View mainWindow_OverviewSettingsPanel = {"container": mainWindow_communityLoader_Loader, "type": "OverviewSettingsPanel", "unnamed": 1, "visible": True} communityOverviewSettingsCommunityName_StatusBaseText = {"container": mainWindow_OverviewSettingsPanel, "objectName": "communityOverviewSettingsCommunityName", "type": "StatusBaseText", "visible": True} @@ -53,8 +55,33 @@ mainWindow_Edit_Community_StatusButton = {"checkable": False, "container": mainW mainWindow_MembersSettingsPanel = {"container": mainWindow_communityLoader_Loader, "type": "MembersSettingsPanel", "unnamed": 1, "visible": True} embersListViews_ListView = {"container": mainWindow_MembersSettingsPanel, "objectName": "CommunityMembersTabPanel_MembersListViews", "type": "ListView", "visible": True} memberItem_StatusMemberListItem = {"container": embersListViews_ListView, "id": "memberItem", "type": "StatusMemberListItem", "unnamed": 1, "visible": True} +# Permissions Intro View +community_welcome_screen_image = {"container": statusDesktop_mainWindow, "objectName": "welcomeSettingsImage", "type": "Image", "visible": True} +community_welcome_screen_title = {"container": statusDesktop_mainWindow, "objectName": "welcomeSettingsTitle", "type": "StatusBaseText", "visible": True} +community_welcome_screen_subtitle = {"container": statusDesktop_mainWindow, "objectName": "welcomeSettingsSubtitle", "type": "StatusBaseText", "visible": True} +community_welcome_screen_checkList_element1 = {"container": statusDesktop_mainWindow, "objectName": "checkListText_0", "type": "StatusBaseText", "visible": True} +community_welcome_screen_checkList_element2 = {"container": statusDesktop_mainWindow, "objectName": "checkListText_1", "type": "StatusBaseText", "visible": True} +community_welcome_screen_checkList_element3 = {"container": statusDesktop_mainWindow, "objectName": "checkListText_2", "type": "StatusBaseText", "visible": True} +add_new_permission_button = {"container": statusDesktop_mainWindow, "objectName": "addNewItemButton", "type": "StatusButton", "visible": True} # Permissions Settings View -mainWindow_PermissionsSettingsPanel = {"container": mainWindow_communityLoader_Loader, "type": "PermissionsSettingsPanel", "unnamed": 1, "visible": True} +mainWindow_editPermissionView_EditPermissionView = {"container": statusDesktop_mainWindow, "id": "editPermissionView", "type": "EditPermissionView", "unnamed": 1, "visible": True} +editPermissionView_Who_holds_StatusItemSelector = {"container": mainWindow_editPermissionView_EditPermissionView, "id": "tokensSelector", "type": "StatusItemSelector", "unnamed": 1, "visible": True} +editPermissionView_Is_allowed_to_StatusFlowSelector = {"container": mainWindow_editPermissionView_EditPermissionView, "id": "permissionsSelector", "type": "StatusFlowSelector", "unnamed": 1, "visible": True} +editPermissionView_In_StatusItemSelector = {"container": mainWindow_editPermissionView_EditPermissionView, "id": "inSelector", "type": "StatusItemSelector", "unnamed": 1, "visible": True} +editPermissionView_whoHoldsSwitch_StatusSwitch = {"checkable": True, "container": mainWindow_editPermissionView_EditPermissionView, "id": "whoHoldsSwitch", "type": "StatusSwitch", "unnamed": 1, "visible": True} +edit_TextEdit = {"container": statusDesktop_mainWindow_overlay, "type": "TextEdit", "unnamed": 1, "visible": True} +inputValue_StyledTextField = {"container": statusDesktop_mainWindow_overlay, "echoMode": 0, "id": "inputValue", "type": "StyledTextField", "unnamed": 1, "visible": True} +o_TokenItem = {"container": statusDesktop_mainWindow_overlay, "index": 0, "type": "TokenItem", "unnamed": 1, "visible": True} +add_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "type": "StatusButton", "unnamed": 1, "visible": True} +customPermissionListItem = {"container": statusDesktop_mainWindow_overlay, "objectName": "becomeAdmin", "type": "CustomPermissionListItem", "visible": True} +communityItem_CommunityListItem = {"container": statusDesktop_mainWindow_overlay, "id": "communityItem", "type": "CommunityListItem", "unnamed": 1, "visible": True} +editPermissionView_switchItem_StatusSwitch = {"checkable": True, "container": mainWindow_editPermissionView_EditPermissionView, "id": "switchItem", "type": "StatusSwitch", "unnamed": 1, "visible": True} +editPermissionView_Create_permission_StatusButton = {"checkable": False, "container": mainWindow_editPermissionView_EditPermissionView, "text": "Create permission", "type": "StatusButton", "unnamed": 1, "visible": True} +mainWindow_PermissionsView = {"container": statusDesktop_mainWindow, "type": "PermissionsView", "unnamed": 1, "visible": True} +o_StatusListItemTag = {"container": mainWindow_PermissionsView, "type": "StatusListItemTag", "unnamed": 1, "visible": True} +o_IntroPanel = {"container": mainWindow_PermissionsView, "type": "IntroPanel", "unnamed": 1, "visible": True} +mainWindow_PermissionsSettingsPanel = {"container": statusDesktop_mainWindow, "type": "PermissionsSettingsPanel", "unnamed": 1, "visible": True} + # Edit Community mainWindow_communityEditPanelScrollView_EditSettingsPanel = {"container": statusDesktop_mainWindow, "objectName": "communityEditPanelScrollView", "type": "EditSettingsPanel", "visible": True} communityEditPanelScrollView_Flickable = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "type": "Flickable", "unnamed": 1, "visible": True} diff --git a/test/e2e/gui/screens/community_settings.py b/test/e2e/gui/screens/community_settings.py index 60cf372e72..fac0359bf6 100644 --- a/test/e2e/gui/screens/community_settings.py +++ b/test/e2e/gui/screens/community_settings.py @@ -3,6 +3,7 @@ import typing import allure import driver +from driver.objects_access import walk_children from gui.components.color_select_popup import ColorSelectPopup from gui.components.community.tags_select_popup import TagsSelectPopup from gui.components.os.open_file_dialogs import OpenFileDialog @@ -30,6 +31,7 @@ class LeftPanel(QObject): self._back_to_community_button = Button('mainWindow_communitySettingsBackToCommunityButton_StatusBaseText') self._overview_button = Button('overview_StatusNavigationListItem') self._members_button = Button('members_StatusNavigationListItem') + self._permissions_button = Button('permissions_StatusNavigationListItem') @allure.step('Open community main view') def back_to_community(self): @@ -47,6 +49,11 @@ class LeftPanel(QObject): self._members_button.click() return MembersView().wait_until_appears() + @allure.step('Open permissions') + def open_permissions(self) -> 'PermissionsIntroView': + self._permissions_button.click() + return PermissionsIntroView().wait_until_appears() + class OverviewView(QObject): @@ -204,3 +211,127 @@ class MembersView(QObject): @allure.step('Get community members') def members(self) -> typing.List[str]: return [str(member.title) for member in driver.findAllObjects(self._member_list_item.real_name)] + + +class PermissionsIntroView(QObject): + def __init__(self): + super(PermissionsIntroView, self).__init__('o_IntroPanel') + self._add_new_permission_button = Button('add_new_permission_button') + self._welcome_image = QObject('community_welcome_screen_image') + self._welcome_title = TextLabel('community_welcome_screen_title') + self._welcome_subtitle = TextLabel('community_welcome_screen_subtitle') + self._welcome_checklist_1 = TextLabel('community_welcome_screen_checkList_element1') + self._welcome_checklist_2 = TextLabel('community_welcome_screen_checkList_element2') + self._welcome_checklist_3 = TextLabel('community_welcome_screen_checkList_element3') + + @property + @allure.step('Get permission welcome image') + def permission_welcome_image(self) -> Image: + return self._welcome_image.image + + @property + @allure.step('Get permission welcome title') + def permission_welcome_title(self) -> str: + return self._welcome_title.text + + @property + @allure.step('Get permission welcome subtitle') + def permission_welcome_subtitle(self) -> str: + return self._welcome_subtitle.text + + @property + @allure.step('Get permission checklist') + def permission_checklist(self) -> typing.List[str]: + permission_checklist = [str(self._welcome_checklist_1.object.text), str(self._welcome_checklist_2.object.text), + str(self._welcome_checklist_3.object.text)] + return permission_checklist + + @allure.step('Click add new permission button') + def add_new_permission(self) -> 'PermissionsSettingsView': + self._add_new_permission_button.click() + return PermissionsSettingsView().wait_until_appears() + + +class PermissionsSettingsView(QObject): + def __init__(self): + super(PermissionsSettingsView, self).__init__('mainWindow_PermissionsSettingsPanel') + self._who_holds_checkbox = CheckBox('editPermissionView_whoHoldsSwitch_StatusSwitch') + self._who_holds_asset_field = TextEdit('edit_TextEdit') + self._who_holds_amount_field = TextEdit('inputValue_StyledTextField') + self._asset_item = QObject('o_TokenItem') + self._is_allowed_to_option_button = Button('customPermissionListItem') + self._in_general_button = Button('communityItem_CommunityListItem') + self._hide_permission_checkbox = CheckBox('editPermissionView_switchItem_StatusSwitch') + self._create_permission_button = Button('editPermissionView_Create_permission_StatusButton') + self._add_button = Button('add_StatusButton') + self._who_holds_list_item = QObject('editPermissionView_Who_holds_StatusItemSelector') + self._is_allowed_to_list_item = QObject('editPermissionView_Is_allowed_to_StatusFlowSelector') + self._in_list_item = QObject('editPermissionView_In_StatusItemSelector') + self._tag_item = QObject('o_StatusListItemTag') + + @property + @allure.step('Get permission tags') + def tags(self) -> typing.List[str]: + _tags = driver.findAllObjects(self._tag_item.real_name) + return [str(getattr(tag, 'title', '')) for tag in _tags] + + @allure.step('Set state of who holds checkbox') + def set_who_holds_checkbox_state(self, state): + if state is False: + self._who_holds_checkbox.set(state) + + @allure.step('Set asset and amount') + def set_who_holds_asset_and_amount(self, asset: str, amount: str): + if asset is not False: + self.open_who_holds_context_menu() + self._who_holds_asset_field.clear().text = asset + self._asset_item.click() + self._who_holds_asset_field.wait_until_hidden() + self._who_holds_amount_field.text = amount + self._add_button.click() + self._who_holds_amount_field.wait_until_hidden() + + @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._add_button.wait_until_hidden() + + @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._add_button.wait_until_hidden() + + @allure.step('Click create permission') + def create_permission(self): + self._create_permission_button.click() + self._create_permission_button.wait_until_hidden() + + @allure.step('Open Who holds context menu') + def open_who_holds_context_menu(self): + for child in walk_children(self._who_holds_list_item.object): + if getattr(child, 'id', '') == 'addItemButton': + driver.mouseClick(child) + return + raise LookupError('Add button for who holds not found') + + @allure.step('Open Is allowed to context menu') + def open_is_allowed_to_context_menu(self): + for child in walk_children(self._is_allowed_to_list_item.object): + if getattr(child, 'id', '') == 'addItemButton': + driver.mouseClick(child) + return + raise LookupError('Add button for allowed to not found') + + @allure.step('Open In context menu') + def open_in_context_menu(self): + for child in walk_children(self._in_list_item.object): + if getattr(child, 'id', '') == 'addItemButton': + driver.mouseClick(child) + return + raise LookupError('Add button for in not found') diff --git a/test/e2e/tests/communities/test_permissions.py b/test/e2e/tests/communities/test_permissions.py new file mode 100644 index 0000000000..7843ff351a --- /dev/null +++ b/test/e2e/tests/communities/test_permissions.py @@ -0,0 +1,77 @@ +import allure +import pytest +from allure_commons._allure import step + +import constants +import driver +from constants.permissions import PermissionsElements +from gui.main_window import MainWindow +from scripts.tools import image + +pytestmark = allure.suite("Communities") + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703198', + 'Manage community: Manage Permissions screen overview') +@pytest.mark.case(703198) +@pytest.mark.parametrize('params', [constants.community_params]) +def test_permissions_screen_overview(main_screen: MainWindow, params): + main_screen.create_community(params) + + with step('Open permissions in community settings'): + 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() + + with step('Verify all elements on permissions screen'): + with step('Permission welcome image is correct'): + welcome_image = permissions_settings.permission_welcome_image + image.compare(welcome_image, 'permission_welcome_image.png') + with step('Permission welcome title is correct'): + assert permissions_settings.permission_welcome_title == PermissionsElements.WELCOME_TITLE.value + with step('Permission welcome subtitle is correct'): + assert permissions_settings.permission_welcome_subtitle == PermissionsElements.WELCOME_SUBTITLE.value + with step('Permission welcome checklist is correct'): + assert PermissionsElements.WELCOME_CHECKLIST_ELEMENT_1.value == permissions_settings.permission_checklist[0] + assert PermissionsElements.WELCOME_CHECKLIST_ELEMENT_2.value == permissions_settings.permission_checklist[1] + assert PermissionsElements.WELCOME_CHECKLIST_ELEMENT_3.value == permissions_settings.permission_checklist[2] + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703632', + 'Manage community: Adding new permissions') +@pytest.mark.case(703632) +@pytest.mark.parametrize('params', [constants.community_params]) +@pytest.mark.parametrize( + 'checkbox_state, first_asset, second_asset, amount, allowed_to, in_general, 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, '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') + ]) +def test_adding_permissions(main_screen: MainWindow, params, checkbox_state: bool, first_asset, second_asset, amount, + allowed_to: str, in_general, 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() + + with step('Create new permission'): + permissions_settings.set_who_holds_checkbox_state(checkbox_state) + permissions_settings.set_who_holds_asset_and_amount(first_asset, amount) + permissions_settings.set_who_holds_asset_and_amount(second_asset, amount) + permissions_settings.set_is_allowed_to(allowed_to) + permissions_settings.set_in(in_general) + permissions_settings.create_permission() + + with step('Created permission is displayed on permission page'): + if asset_title is not False: + assert driver.waitFor(lambda: asset_title in permissions_settings.tags) + if second_asset_title is not False: + assert driver.waitFor(lambda: second_asset_title in permissions_settings.tags) + if allowed_to_title is not False: + assert driver.waitFor(lambda: allowed_to_title in permissions_settings.tags)