test(Communities) Adding permission test automated (#11993)
This commit is contained in:
parent
1bc7eb374b
commit
d684acd835
|
@ -7,8 +7,7 @@
|
||||||
# * \date July 2022
|
# * \date July 2022
|
||||||
# * \brief Community Screen.
|
# * \brief Community Screen.
|
||||||
# *****************************************************************************/
|
# *****************************************************************************/
|
||||||
|
import typing
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import time
|
import time
|
||||||
from unittest import TestSuite
|
from unittest import TestSuite
|
||||||
|
@ -569,3 +568,82 @@ class StatusCommunityScreen:
|
||||||
button_title = get_obj(CommunityWelcomeScreenComponents.ADD_NEW_ITEM_BUTTON.value).text
|
button_title = get_obj(CommunityWelcomeScreenComponents.ADD_NEW_ITEM_BUTTON.value).text
|
||||||
verify_equals(option, str(button_title))
|
verify_equals(option, str(button_title))
|
||||||
|
|
||||||
|
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 ')
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from scripts.global_names import *
|
from scripts.global_names import *
|
||||||
|
|
||||||
# Main:
|
# Main:
|
||||||
|
mainWindow_StatusWindow = {"name": "mainWindow", "type": "StatusWindow", "visible": True}
|
||||||
mainWindow_communityColumnView_CommunityColumnView = {"container": statusDesktop_mainWindow, "objectName": "communityColumnView", "type": "CommunityColumnView", "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}
|
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}
|
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_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_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}
|
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}
|
||||||
|
|
|
@ -2,10 +2,13 @@ import steps.commonInitSteps as init_steps
|
||||||
from screens.StatusMainScreen import StatusMainScreen
|
from screens.StatusMainScreen import StatusMainScreen
|
||||||
from screens.StatusCommunityPortalScreen import StatusCommunityPortalScreen
|
from screens.StatusCommunityPortalScreen import StatusCommunityPortalScreen
|
||||||
from screens.StatusCommunityScreen import StatusCommunityScreen
|
from screens.StatusCommunityScreen import StatusCommunityScreen
|
||||||
|
from screens.StatusCommunityScreen import PermissionsView
|
||||||
|
from drivers.SquishDriver import *
|
||||||
|
|
||||||
_statusCommunityScreen = StatusCommunityScreen()
|
_statusCommunityScreen = StatusCommunityScreen()
|
||||||
_statusCommunitityPortal = StatusCommunityPortalScreen()
|
_statusCommunitityPortal = StatusCommunityPortalScreen()
|
||||||
_statusMainScreen = StatusMainScreen()
|
_statusMainScreen = StatusMainScreen()
|
||||||
|
_permissionsView = PermissionsView()
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
### PRECONDITIONS region:
|
### PRECONDITIONS region:
|
||||||
|
@ -175,11 +178,29 @@ def step(context, section_option:str):
|
||||||
_statusCommunityScreen.select_community_settings_option(section_option)
|
_statusCommunityScreen.select_community_settings_option(section_option)
|
||||||
time.sleep(1)
|
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:
|
### 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|\"")
|
@Then("the user lands on the community named \"|any|\"")
|
||||||
def step(context: any, community_name: str):
|
def step(context: any, community_name: str):
|
||||||
the_user_lands_on_the_community(community_name)
|
the_user_lands_on_the_community(community_name)
|
||||||
|
|
|
@ -21,3 +21,17 @@ Background:
|
||||||
| Monetise your community with subscriptions and fees |
|
| Monetise your community with subscriptions and fees |
|
||||||
| Require holding a token or NFT to obtain exclusive membership rights |
|
| Require holding a token or NFT to obtain exclusive membership rights |
|
||||||
And "Add new permission" button is present
|
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 "<state>", holds "<first_asset>" and "<second_asset>" in amount "<amount>" and "<allowed_to>" "<in_general>"
|
||||||
|
Then created permission with "<asset_title>" and "<second_asset_title>" and "<allowed_to_title>" 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 |
|
||||||
|
|
|
@ -106,12 +106,14 @@ StatusDropdown {
|
||||||
enabled: root.enableAdminPermission
|
enabled: root.enableAdminPermission
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
objectName: "becomeAdmin"
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomPermissionListItem {
|
CustomPermissionListItem {
|
||||||
permissionType: PermissionTypes.Type.Member
|
permissionType: PermissionTypes.Type.Member
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
objectName: "becomeMember"
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomSeparator {
|
CustomSeparator {
|
||||||
|
@ -125,12 +127,14 @@ StatusDropdown {
|
||||||
permissionType: PermissionTypes.Type.ViewAndPost
|
permissionType: PermissionTypes.Type.ViewAndPost
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
objectName: "viewAndPost"
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomPermissionListItem {
|
CustomPermissionListItem {
|
||||||
permissionType: PermissionTypes.Type.Read
|
permissionType: PermissionTypes.Type.Read
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
objectName: "viewOnly"
|
||||||
}
|
}
|
||||||
|
|
||||||
Separator {
|
Separator {
|
||||||
|
|
Loading…
Reference in New Issue