diff --git a/test/ui-test/src/screens/StatusCommunityScreen.py b/test/ui-test/src/screens/StatusCommunityScreen.py index ef13136d59..343a6faf39 100644 --- a/test/ui-test/src/screens/StatusCommunityScreen.py +++ b/test/ui-test/src/screens/StatusCommunityScreen.py @@ -7,8 +7,7 @@ # * \date July 2022 # * \brief Community Screen. # *****************************************************************************/ - - +import typing from enum import Enum import time from unittest import TestSuite @@ -568,4 +567,83 @@ class StatusCommunityScreen: assert button.is_disabled button_title = get_obj(CommunityWelcomeScreenComponents.ADD_NEW_ITEM_BUTTON.value).text verify_equals(option, str(button_title)) - \ No newline at end of file + +class PermissionsView(BaseElement): + def __init__(self): + super(PermissionsView, self).__init__('mainWindow_editPermissionView_EditPermissionView') + self._add_new_permission_button = Button('community_welcome_screen_add_new_item') + 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 = BaseElement('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 = BaseElement('editPermissionView_Who_holds_StatusItemSelector') + self._is_allowed_to_list_item = BaseElement('editPermissionView_Is_allowed_to_StatusFlowSelector') + self._in_list_item = BaseElement('editPermissionView_In_StatusItemSelector') + self._tag_item = BaseElement('o_StatusListItemTag') + + @property + def tags(self) -> typing.List[str]: + _tags = get_objects(self._tag_item.symbolic_name) + return [str(getattr(tag, 'title', '')) for tag in _tags] + + def add_new_permission(self): + self._add_new_permission_button.click() + return PermissionsView().wait_until_appears() + + def set_who_holds_checkbox_state(self, state): + if state == 'Off': + self._who_holds_checkbox.set(False) + + def set_who_holds_asset_and_amount(self, asset: str, amount: str): + if asset != 'No': + 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() + + def set_is_allowed_to(self, name): + self.open_is_allowed_to_context_menu() + self._is_allowed_to_option_button.object_name['objectName'] = name + self._is_allowed_to_option_button.wait_until_appears().click() + self._add_button.click() + self._add_button.wait_until_hidden() + + def set_in_community(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() + + def create_permission(self): + self._create_permission_button.click() + self._create_permission_button.wait_until_hidden() + + def open_who_holds_context_menu(self): + for child in walk_children(self._who_holds_list_item.object): + if getattr(child, 'id', '') == 'addItemButton': + click_obj(child) + return + raise LookupError('Add button for who holds not found ') + + 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': + click_obj(child) + return + raise LookupError('Add button for allowed to not found ') + + def open_in_context_menu(self): + for child in walk_children(self._in_list_item.object): + if getattr(child, 'id', '') == 'addItemButton': + click_obj(child) + return + raise LookupError('Add button for in not found ') diff --git a/test/ui-test/testSuites/suite_communities/shared/scripts/community_names.py b/test/ui-test/testSuites/suite_communities/shared/scripts/community_names.py index c789d6b348..3d5076974b 100644 --- a/test/ui-test/testSuites/suite_communities/shared/scripts/community_names.py +++ b/test/ui-test/testSuites/suite_communities/shared/scripts/community_names.py @@ -1,6 +1,7 @@ from scripts.global_names import * # Main: +mainWindow_StatusWindow = {"name": "mainWindow", "type": "StatusWindow", "visible": True} mainWindow_communityColumnView_CommunityColumnView = {"container": statusDesktop_mainWindow, "objectName": "communityColumnView", "type": "CommunityColumnView", "visible": True} mainWindow_communityHeader_StatusChatInfoButton = {"container": statusDesktop_mainWindow, "objectName": "communityHeaderButton", "type": "StatusChatInfoButton", "visible": True} community_ChatInfo_Name_Text = {"container": mainWindow_communityHeader_StatusChatInfoButton, "objectName": "statusChatInfoButtonNameText", "type": "StatusBaseText", "visible": True} @@ -95,3 +96,21 @@ community_welcome_screen_checkList_element1 = {"container": statusDesktop_mainWi 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} community_welcome_screen_add_new_item = {"container": statusDesktop_mainWindow, "objectName": "addNewItemButton", "type": "StatusButton", "visible": True} + +# Permissions view +mainWindow_editPermissionView_EditPermissionView = {"container": mainWindow_StatusWindow, "id": "stackLayout", "type": "StackLayout", "unnamed": 1, "visible": True} +mainWindow_editPermissionView_EditPermissionView_2 = {"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_2, "id": "permissionsSelector", "type": "StatusFlowSelector", "unnamed": 1, "visible": True} +editPermissionView_In_StatusItemSelector = {"container": mainWindow_editPermissionView_EditPermissionView_2, "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": mainWindow_StatusWindow, "type": "PermissionsView", "unnamed": 1, "visible": True} +o_StatusListItemTag = {"container": mainWindow_PermissionsView, "type": "StatusListItemTag", "unnamed": 1, "visible": True} diff --git a/test/ui-test/testSuites/suite_communities/shared/steps/communitySteps.py b/test/ui-test/testSuites/suite_communities/shared/steps/communitySteps.py index 52c46e6f91..d5d30da427 100644 --- a/test/ui-test/testSuites/suite_communities/shared/steps/communitySteps.py +++ b/test/ui-test/testSuites/suite_communities/shared/steps/communitySteps.py @@ -2,10 +2,13 @@ import steps.commonInitSteps as init_steps from screens.StatusMainScreen import StatusMainScreen from screens.StatusCommunityPortalScreen import StatusCommunityPortalScreen from screens.StatusCommunityScreen import StatusCommunityScreen +from screens.StatusCommunityScreen import PermissionsView +from drivers.SquishDriver import * _statusCommunityScreen = StatusCommunityScreen() _statusCommunitityPortal = StatusCommunityPortalScreen() _statusMainScreen = StatusMainScreen() +_permissionsView = PermissionsView() ######################### ### PRECONDITIONS region: @@ -170,16 +173,34 @@ def step(context, community_sidebar_option:str): _statusCommunityScreen.click_sidebar_option(community_sidebar_option) time.sleep(1) -@When("\"|any|\" section is selected") +@When("\"|any|\" section is selected") def step(context, section_option:str): _statusCommunityScreen.select_community_settings_option(section_option) time.sleep(1) +@When("the user adds new permission with anyone checkbox \"|any|\", holds \"|any|\" and \"|any|\" in amount \"|any|\" and \"|any|\" \"|any|\"") +def step(context, state, first_asset, second_asset, amount, allowed_to, in_general): + permission_view = _permissionsView.add_new_permission() + permission_view.set_who_holds_checkbox_state(state) + permission_view.set_who_holds_asset_and_amount(first_asset, amount) + permission_view.set_who_holds_asset_and_amount(second_asset, amount) + permission_view.set_is_allowed_to(allowed_to) + permission_view.set_in_community(in_general) + permission_view.create_permission() ######################### ### VERIFICATIONS region: ######################### +@Then("created permission with \"|any|\" and \"|any|\" and \"|any|\" is on permission page") +def step(context, title, second_title, third_title): + if title != 'No': + assert wait_for(title in _permissionsView.tags) + if second_title != 'No': + assert wait_for(second_title in _permissionsView.tags) + if third_title != 'No': + assert wait_for(third_title in _permissionsView.tags) + @Then("the user lands on the community named \"|any|\"") def step(context: any, community_name: str): the_user_lands_on_the_community(community_name) diff --git a/test/ui-test/testSuites/suite_communities/tst_communityManagePermissions/test.feature b/test/ui-test/testSuites/suite_communities/tst_communityManagePermissions/test.feature index 5896423ae8..dc1b193f11 100644 --- a/test/ui-test/testSuites/suite_communities/tst_communityManagePermissions/test.feature +++ b/test/ui-test/testSuites/suite_communities/tst_communityManagePermissions/test.feature @@ -20,4 +20,18 @@ Background: | Give individual members access to private channels | | Monetise your community with subscriptions and fees | | Require holding a token or NFT to obtain exclusive membership rights | - And "Add new permission" button is present \ No newline at end of file + And "Add new permission" button is present + + + Scenario Outline: Adding permissions + When "Manage Community" is clicked in the community sidebar + And "Permissions" section is selected + And the user adds new permission with anyone checkbox "", holds "" and "" in amount "" and "" "" + Then created permission with "" and "" and "" is on permission page + Examples: + |state| first_asset | second_asset | amount | allowed_to |in_general |asset_title | second_asset_title|allowed_to_title | + |On | Dai Stablecoin| No | 10 | becomeMember |No |10 DAI | No |Become member | + |On | Ether | No | 1 | becomeAdmin |No |1 ETH | No |Become admin | + |On | Ether | Dai Stablecoin| 10 | viewAndPost |#general |10 ETH | 10 DAI |View and post | + |On | Ether | Dai Stablecoin| 10 | viewOnly |#general |10 ETH | 10 DAI |View only | + |Off | No | No | No | becomeAdmin |No |No | No |Become admin | diff --git a/ui/app/AppLayouts/Communities/popups/PermissionsDropdown.qml b/ui/app/AppLayouts/Communities/popups/PermissionsDropdown.qml index eaed104290..36e5f9c2cf 100644 --- a/ui/app/AppLayouts/Communities/popups/PermissionsDropdown.qml +++ b/ui/app/AppLayouts/Communities/popups/PermissionsDropdown.qml @@ -106,12 +106,14 @@ StatusDropdown { enabled: root.enableAdminPermission Layout.fillWidth: true + objectName: "becomeAdmin" } CustomPermissionListItem { permissionType: PermissionTypes.Type.Member Layout.fillWidth: true + objectName: "becomeMember" } CustomSeparator { @@ -125,12 +127,14 @@ StatusDropdown { permissionType: PermissionTypes.Type.ViewAndPost Layout.fillWidth: true + objectName: "viewAndPost" } CustomPermissionListItem { permissionType: PermissionTypes.Type.Read Layout.fillWidth: true + objectName: "viewOnly" } Separator {