test: check member role permission limit added
This commit is contained in:
parent
b25ec2bd1b
commit
50cb471e3c
|
@ -11,3 +11,5 @@ tmp/
|
|||
*.DS_Store
|
||||
|
||||
/local_run_results/
|
||||
/squish.ini
|
||||
|
||||
|
|
|
@ -32,4 +32,8 @@ class AirdropsElements(Enum):
|
|||
class ToastMessages(Enum):
|
||||
CREATE_PERMISSION_TOAST = 'Community permission created'
|
||||
UPDATE_PERMISSION_TOAST = 'Community permission updated'
|
||||
DELETE_PERMISSION_TOAST = 'Community permission updated'
|
||||
DELETE_PERMISSION_TOAST = 'Community permission deleted'
|
||||
|
||||
|
||||
class LimitWarnings(Enum):
|
||||
MEMBER_ROLE_LIMIT_WARNING = 'Max of 5 ‘become member’ permissions for this Community has been reached. You will need to delete an existing ‘become member’ permission before you can add a new one.'
|
||||
|
|
|
@ -137,6 +137,7 @@ hide_icon_StatusIcon = {"container": mainWindow_PermissionsView, "objectName": "
|
|||
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}
|
||||
memberRoleLimitWarning = {"container": mainWindow_editPermissionView_EditPermissionView, "id": "duplicationPanel", "type": "WarningPanel", "unnamed": 1, "visible": True}
|
||||
|
||||
# Edit Community
|
||||
mainWindow_communityEditPanelScrollView_EditSettingsPanel = {"container": statusDesktop_mainWindow, "objectName": "communityEditPanelScrollView", "type": "EditSettingsPanel", "visible": True}
|
||||
|
|
|
@ -30,7 +30,8 @@ class LeftPanel(QObject):
|
|||
|
||||
def __init__(self):
|
||||
super().__init__(communities_names.mainWindow_communityColumnView_CommunityColumnView)
|
||||
self._back_to_community_button = Button(communities_names.mainWindow_communitySettingsBackToCommunityButton_StatusBaseText)
|
||||
self._back_to_community_button = Button(
|
||||
communities_names.mainWindow_communitySettingsBackToCommunityButton_StatusBaseText)
|
||||
self._overview_button = Button(communities_names.overview_StatusNavigationListItem)
|
||||
self._members_button = Button(communities_names.members_StatusNavigationListItem)
|
||||
self._permissions_button = Button(communities_names.permissions_StatusNavigationListItem)
|
||||
|
@ -74,7 +75,8 @@ class OverviewView(QObject):
|
|||
def __init__(self):
|
||||
super().__init__(communities_names.mainWindow_OverviewSettingsPanel)
|
||||
self._name_text_label = TextLabel(communities_names.communityOverviewSettingsCommunityName_StatusBaseText)
|
||||
self._description_text_label = TextLabel(communities_names.communityOverviewSettingsCommunityDescription_StatusBaseText)
|
||||
self._description_text_label = TextLabel(
|
||||
communities_names.communityOverviewSettingsCommunityDescription_StatusBaseText)
|
||||
self._edit_button = Button(communities_names.mainWindow_Edit_Community_StatusButton)
|
||||
|
||||
@property
|
||||
|
@ -106,7 +108,8 @@ class EditCommunityView(QObject):
|
|||
super().__init__(communities_names.mainWindow_communityEditPanelScrollView_EditSettingsPanel)
|
||||
self._scroll = Scroll(communities_names.communityEditPanelScrollView_Flickable)
|
||||
self._name_text_edit = TextEdit(communities_names.communityEditPanelScrollView_communityNameInput_TextEdit)
|
||||
self._description_text_edit = TextEdit(communities_names.communityEditPanelScrollView_communityDescriptionInput_TextEdit)
|
||||
self._description_text_edit = TextEdit(
|
||||
communities_names.communityEditPanelScrollView_communityDescriptionInput_TextEdit)
|
||||
self._logo = QObject(communities_names.communityEditPanelScrollView_image_StatusImage)
|
||||
self._add_logo_button = Button(communities_names.communityEditPanelScrollView_editButton_StatusRoundButton)
|
||||
self._banner = QObject(communities_names.communityEditPanelScrollView_image_StatusImage_2)
|
||||
|
@ -116,10 +119,14 @@ class EditCommunityView(QObject):
|
|||
self._tag_item = QObject(communities_names.communityEditPanelScrollView_StatusCommunityTag)
|
||||
self._archive_support_checkbox = CheckBox(
|
||||
communities_names.communityEditPanelScrollView_archiveSupportToggle_StatusCheckBox)
|
||||
self._request_to_join_checkbox = CheckBox(communities_names.communityEditPanelScrollView_requestToJoinToggle_StatusCheckBox)
|
||||
self._pin_messages_checkbox = CheckBox(communities_names.communityEditPanelScrollView_pinMessagesToggle_StatusCheckBox)
|
||||
self._intro_text_edit = TextEdit(communities_names.communityEditPanelScrollView_editCommunityIntroInput_TextEdit)
|
||||
self._outro_text_edit = TextEdit(communities_names.communityEditPanelScrollView_editCommunityOutroInput_TextEdit)
|
||||
self._request_to_join_checkbox = CheckBox(
|
||||
communities_names.communityEditPanelScrollView_requestToJoinToggle_StatusCheckBox)
|
||||
self._pin_messages_checkbox = CheckBox(
|
||||
communities_names.communityEditPanelScrollView_pinMessagesToggle_StatusCheckBox)
|
||||
self._intro_text_edit = TextEdit(
|
||||
communities_names.communityEditPanelScrollView_editCommunityIntroInput_TextEdit)
|
||||
self._outro_text_edit = TextEdit(
|
||||
communities_names.communityEditPanelScrollView_editCommunityOutroInput_TextEdit)
|
||||
self._save_changes_button = Button(names.mainWindow_Save_changes_StatusButton)
|
||||
self._cropped_image_edit_logo_item = QObject(communities_names.croppedImageEditLogo)
|
||||
self._cropped_image_edit_banner_item = QObject(communities_names.croppedImageEditBanner)
|
||||
|
@ -153,7 +160,8 @@ class EditCommunityView(QObject):
|
|||
def logo(self, kwargs: dict):
|
||||
self._add_logo_button.click()
|
||||
OpenFileDialog().wait_until_appears().open_file(kwargs['fp'])
|
||||
PictureEditPopup().wait_until_appears().set_zoom_shift_for_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
|
||||
PictureEditPopup().wait_until_appears().set_zoom_shift_for_picture(kwargs.get('zoom', None),
|
||||
kwargs.get('shift', None))
|
||||
|
||||
@property
|
||||
@allure.step('Get community banner')
|
||||
|
@ -164,7 +172,8 @@ class EditCommunityView(QObject):
|
|||
def banner(self, kwargs: dict):
|
||||
self._add_banner_button.click()
|
||||
OpenFileDialog().wait_until_appears().open_file(kwargs['fp'])
|
||||
PictureEditPopup().wait_until_appears().set_zoom_shift_for_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
|
||||
PictureEditPopup().wait_until_appears().set_zoom_shift_for_picture(kwargs.get('zoom', None),
|
||||
kwargs.get('shift', None))
|
||||
|
||||
@allure.step('Set community logo without file upload dialog')
|
||||
def set_logo_without_file_upload_dialog(self, path):
|
||||
|
@ -451,6 +460,15 @@ class PermissionsSettingsView(QObject):
|
|||
self._is_allowed_tag = QObject(communities_names.isAllowedTagListItem)
|
||||
self._in_community_in_channel_tag = QObject(communities_names.inCommunityTagListItem)
|
||||
self._is_allowed_to_edit_tag = QObject(communities_names.isAllowedToEditPermissionView_StatusListItemTag)
|
||||
self._member_role_limit_warning = QObject(communities_names.memberRoleLimitWarning)
|
||||
|
||||
@allure.step('Verify member role limit warning is present')
|
||||
def is_member_role_warning_text_present(self):
|
||||
return self._member_role_limit_warning.exists
|
||||
|
||||
@allure.step('Get warning text')
|
||||
def get_member_role_limit_warning_text(self):
|
||||
return str(self._member_role_limit_warning.object.text)
|
||||
|
||||
@allure.step('Get titles of Who holds tags')
|
||||
def get_who_holds_tags_titles(self, attempt: int = 2) -> typing.List[str]:
|
||||
|
@ -544,7 +562,7 @@ class PermissionsSettingsView(QObject):
|
|||
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, attempt: int = 2):
|
||||
def open_is_allowed_to_context_menu(self, attempt: int = 2):
|
||||
try:
|
||||
for child in walk_children(self._is_allowed_to_list_item.object):
|
||||
if getattr(child, 'objectName', '') == 'addItemButton':
|
||||
|
|
|
@ -10,7 +10,7 @@ from . import marks
|
|||
|
||||
import constants
|
||||
import driver
|
||||
from constants.community_settings import ToastMessages
|
||||
from constants.community_settings import ToastMessages, LimitWarnings
|
||||
from gui.main_window import MainWindow
|
||||
|
||||
pytestmark = marks
|
||||
|
@ -31,7 +31,6 @@ pytestmark = marks
|
|||
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')
|
||||
])
|
||||
# TODO: (reason='https://github.com/status-im/status-desktop/issues/13621')
|
||||
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):
|
||||
|
@ -123,3 +122,91 @@ def test_add_edit_and_remove_permissions(main_screen: MainWindow, params, checkb
|
|||
messages = main_screen.wait_for_notification()
|
||||
assert ToastMessages.DELETE_PERMISSION_TOAST.value in messages, \
|
||||
f"Toast message is incorrect, current message is {message}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize('params', [constants.community_params])
|
||||
def test_add_5_member_role_permissions(main_screen: MainWindow, params):
|
||||
main_screen.create_community(params['name'], params['description'],
|
||||
params['intro'], params['outro'],
|
||||
params['logo']['fp'], params['banner']['fp'])
|
||||
|
||||
permission_data = [
|
||||
{
|
||||
'checkbox_state': True,
|
||||
'first_asset': 'Dai Stablecoin',
|
||||
'amount': '1',
|
||||
'allowed_to': 'becomeMember',
|
||||
'asset_title': '1 DAI',
|
||||
'allowed_to_title': 'Become member'
|
||||
},
|
||||
{
|
||||
'checkbox_state': True,
|
||||
'first_asset': 'Aragon',
|
||||
'amount': '2',
|
||||
'allowed_to': 'becomeMember',
|
||||
'asset_title': '2 ANT',
|
||||
'allowed_to_title': 'Become member'
|
||||
},
|
||||
{
|
||||
'checkbox_state': True,
|
||||
'first_asset': '1inch',
|
||||
'amount': '3',
|
||||
'allowed_to': 'becomeMember',
|
||||
'asset_title': '3 1INCH',
|
||||
'allowed_to_title': 'Become member'
|
||||
},
|
||||
{
|
||||
'checkbox_state': True,
|
||||
'first_asset': 'ABYSS',
|
||||
'amount': '4',
|
||||
'allowed_to': 'becomeMember',
|
||||
'asset_title': '4 ABYSS',
|
||||
'allowed_to_title': 'Become member'
|
||||
},
|
||||
{
|
||||
'checkbox_state': True,
|
||||
'first_asset': 'Bytom',
|
||||
'amount': '5',
|
||||
'allowed_to': 'becomeMember',
|
||||
'asset_title': '5 BTM',
|
||||
'allowed_to_title': 'Become member'
|
||||
}
|
||||
]
|
||||
|
||||
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_intro_view = community_setting.left_panel.open_permissions()
|
||||
|
||||
with step('Create new permission'):
|
||||
for index, item in enumerate(permission_data):
|
||||
permissions_settings = permissions_intro_view.add_new_permission()
|
||||
permissions_settings.set_who_holds_checkbox_state(permission_data[index]['checkbox_state'])
|
||||
permissions_settings.set_who_holds_asset_and_amount(permission_data[index]['first_asset'],
|
||||
permission_data[index]['amount'])
|
||||
permissions_settings.set_is_allowed_to(permission_data[index]['allowed_to'])
|
||||
permissions_settings.create_permission()
|
||||
|
||||
with step('Created permission is displayed on permission page'):
|
||||
if permission_data[index]['asset_title'] is not False:
|
||||
assert driver.waitFor(
|
||||
lambda: permission_data[index]['asset_title'] in permissions_settings.get_who_holds_tags_titles(),
|
||||
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
||||
|
||||
with step('Open form to create 6th member role permission and validate it is not allowed'):
|
||||
extra_permission_data = {
|
||||
'checkbox_state': True,
|
||||
'first_asset': 'Bytom',
|
||||
'amount': '6',
|
||||
'allowed_to': 'becomeMember'
|
||||
}
|
||||
permissions_settings = permissions_intro_view.add_new_permission()
|
||||
permissions_settings.set_who_holds_checkbox_state(extra_permission_data['checkbox_state'])
|
||||
permissions_settings.set_who_holds_asset_and_amount(extra_permission_data['first_asset'],
|
||||
extra_permission_data['amount'])
|
||||
permissions_settings.set_is_allowed_to(extra_permission_data['allowed_to'])
|
||||
|
||||
assert permissions_settings.is_member_role_warning_text_present(), 'Member role limit warning is not displayed'
|
||||
assert permissions_settings.get_member_role_limit_warning_text() \
|
||||
== LimitWarnings.MEMBER_ROLE_LIMIT_WARNING.value, \
|
||||
f'Warning text about become a member limit reached is incorrect'
|
||||
|
|
Loading…
Reference in New Issue