2023-10-11 12:00:17 +00:00
|
|
|
import allure
|
|
|
|
import pytest
|
|
|
|
from allure_commons._allure import step
|
2023-12-28 16:22:50 +00:00
|
|
|
|
2024-02-16 06:33:56 +00:00
|
|
|
import configs
|
2024-02-16 05:08:57 +00:00
|
|
|
from gui.components.changes_detected_popup import PermissionsChangesDetectedToastMessage
|
|
|
|
from gui.components.delete_popup import DeletePermissionPopup
|
|
|
|
from gui.screens.community_settings import PermissionsIntroView
|
2023-12-07 16:47:34 +00:00
|
|
|
from . import marks
|
2023-10-11 12:00:17 +00:00
|
|
|
|
|
|
|
import constants
|
|
|
|
import driver
|
2024-03-29 14:49:05 +00:00
|
|
|
from constants.community_settings import ToastMessages, LimitWarnings
|
2023-10-11 12:00:17 +00:00
|
|
|
from gui.main_window import MainWindow
|
|
|
|
|
2023-12-07 16:47:34 +00:00
|
|
|
pytestmark = marks
|
2023-10-11 12:00:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703632',
|
2024-02-16 05:08:57 +00:00
|
|
|
'Manage community: Adding new permissions, Editing permissions, Deleting permission')
|
2024-02-16 07:54:10 +00:00
|
|
|
@pytest.mark.case(703632, 705014, 705016)
|
2023-10-11 12:00:17 +00:00
|
|
|
@pytest.mark.parametrize('params', [constants.community_params])
|
2024-04-08 13:59:37 +00:00
|
|
|
def test_add_edit_and_remove_permissions(main_screen: MainWindow, params):
|
2024-05-03 09:36:51 +00:00
|
|
|
with step('Enable creation of community option'):
|
|
|
|
settings = main_screen.left_panel.open_settings()
|
|
|
|
settings.left_panel.open_advanced_settings().enable_creation_of_communities()
|
|
|
|
|
2024-02-19 13:27:54 +00:00
|
|
|
main_screen.create_community(params['name'], params['description'],
|
|
|
|
params['intro'], params['outro'],
|
|
|
|
params['logo']['fp'], params['banner']['fp'])
|
2023-10-11 12:00:17 +00:00
|
|
|
|
2024-04-08 13:59:37 +00:00
|
|
|
permission_data = [
|
|
|
|
{
|
|
|
|
'checkbox_state': True,
|
|
|
|
'first_asset': 'Dai Stablecoin',
|
|
|
|
'second_asset': False,
|
|
|
|
'amount': '10',
|
|
|
|
'allowed_to': 'becomeMember',
|
|
|
|
'in_channel': False,
|
|
|
|
'asset_title': '10 DAI',
|
|
|
|
'second_asset_title': False,
|
|
|
|
'allowed_to_title': 'Become member'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'checkbox_state': True,
|
|
|
|
'first_asset': 'Ether',
|
|
|
|
'second_asset': False,
|
|
|
|
'amount': '1',
|
|
|
|
'allowed_to': 'becomeAdmin',
|
|
|
|
'in_channel': False,
|
|
|
|
'asset_title': '1 ETH',
|
|
|
|
'second_asset_title': False,
|
|
|
|
'allowed_to_title': 'Become an admin'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'checkbox_state': True,
|
|
|
|
'first_asset': 'Ether',
|
|
|
|
'second_asset': 'Dai Stablecoin',
|
|
|
|
'amount': '10',
|
|
|
|
'allowed_to': 'viewAndPost',
|
|
|
|
'in_channel': '#general',
|
|
|
|
'asset_title': '10 ETH',
|
|
|
|
'second_asset_title': '10 DAI',
|
|
|
|
'allowed_to_title': 'View and post'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'checkbox_state': True,
|
|
|
|
'first_asset': 'Ether',
|
|
|
|
'second_asset': 'Dai Stablecoin',
|
|
|
|
'amount': '10',
|
|
|
|
'allowed_to': 'viewOnly',
|
|
|
|
'in_channel': '#general',
|
|
|
|
'asset_title': '10 ETH',
|
|
|
|
'second_asset_title': '10 DAI',
|
|
|
|
'allowed_to_title': 'View only'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'checkbox_state': False,
|
|
|
|
'first_asset': False,
|
|
|
|
'second_asset': False,
|
|
|
|
'amount': False,
|
|
|
|
'allowed_to': 'becomeAdmin',
|
|
|
|
'in_channel': False,
|
|
|
|
'asset_title': False,
|
|
|
|
'second_asset_title': False,
|
|
|
|
'allowed_to_title': 'Become an admin'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2023-10-11 12:00:17 +00:00
|
|
|
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()
|
2024-02-16 05:08:57 +00:00
|
|
|
permissions_intro_view = community_setting.left_panel.open_permissions()
|
2024-04-08 13:59:37 +00:00
|
|
|
|
|
|
|
for index, item in enumerate(permission_data):
|
|
|
|
with step('Create new permission'):
|
|
|
|
permissions_settings = permissions_intro_view.add_new_permission()
|
|
|
|
permissions_settings.set_who_holds_checkbox_state(permission_data[index]['checkbox_state'])
|
2024-05-03 09:36:51 +00:00
|
|
|
permissions_settings.set_who_holds_asset_and_amount(permission_data[index]['first_asset'],
|
|
|
|
permission_data[index]['amount'])
|
|
|
|
permissions_settings.set_who_holds_asset_and_amount(permission_data[index]['second_asset'],
|
|
|
|
permission_data[index]['amount'])
|
2024-04-08 13:59:37 +00:00
|
|
|
permissions_settings.set_is_allowed_to(permission_data[index]['allowed_to'])
|
|
|
|
permissions_settings.set_in(permission_data[index]['in_channel'])
|
|
|
|
permissions_settings.create_permission()
|
|
|
|
|
|
|
|
with step('Check toast message for permission creation'):
|
|
|
|
toast_messages = main_screen.wait_for_notification()
|
|
|
|
message = toast_messages[0]
|
|
|
|
assert ToastMessages.CREATE_PERMISSION_TOAST.value in toast_messages, \
|
|
|
|
f"Toast message is incorrect, current message is {message}"
|
|
|
|
|
|
|
|
with step('Created permission is displayed on permission page'):
|
|
|
|
if permission_data[index]['asset_title'] is not False:
|
2024-05-03 09:36:51 +00:00
|
|
|
assert driver.waitFor(
|
|
|
|
lambda: permission_data[index]['asset_title'] in permissions_settings.get_who_holds_tags_titles(),
|
|
|
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
2024-04-08 13:59:37 +00:00
|
|
|
if permission_data[index]['second_asset_title'] is not False:
|
2024-05-03 09:36:51 +00:00
|
|
|
assert driver.waitFor(lambda: permission_data[index][
|
|
|
|
'second_asset_title'] in permissions_settings.get_who_holds_tags_titles(),
|
2024-02-19 13:27:54 +00:00
|
|
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
2024-04-08 13:59:37 +00:00
|
|
|
if permission_data[index]['allowed_to_title'] is not False:
|
2024-05-03 09:36:51 +00:00
|
|
|
assert driver.waitFor(lambda: permission_data[index][
|
|
|
|
'allowed_to_title'] in permissions_settings.get_is_allowed_tags_titles(),
|
2024-04-08 13:59:37 +00:00
|
|
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
|
|
|
if permission_data[index]['in_channel'] is False:
|
2024-02-16 05:08:57 +00:00
|
|
|
assert driver.waitFor(
|
2024-04-08 13:59:37 +00:00
|
|
|
lambda: params['name'] in permissions_settings.get_in_community_in_channel_tags_titles(),
|
2024-02-19 13:27:54 +00:00
|
|
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
2024-04-08 13:59:37 +00:00
|
|
|
if permission_data[index]['in_channel']:
|
2024-05-03 09:36:51 +00:00
|
|
|
assert driver.waitFor(lambda: permission_data[index][
|
|
|
|
'in_channel'] in permissions_settings.get_in_community_in_channel_tags_titles(),
|
2024-04-08 13:59:37 +00:00
|
|
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
|
|
|
|
|
|
|
with step('Edit permission'):
|
|
|
|
edit_permission_view = permissions_intro_view.open_edit_permission_view()
|
2024-05-03 09:36:51 +00:00
|
|
|
if permission_data[index]['allowed_to'] is 'becomeAdmin' and permission_data[index][
|
|
|
|
'checkbox_state'] is True:
|
2024-04-08 13:59:37 +00:00
|
|
|
permissions_settings.set_who_holds_checkbox_state(False)
|
|
|
|
elif permission_data[index]['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()
|
2024-05-03 09:36:51 +00:00
|
|
|
if permission_data[index]['allowed_to'] is 'becomeAdmin' and permission_data[index][
|
|
|
|
'checkbox_state'] is True:
|
2024-04-08 13:59:37 +00:00
|
|
|
if permission_data[index]['asset_title'] is not False:
|
2024-05-03 09:36:51 +00:00
|
|
|
assert driver.waitFor(lambda: permission_data[index][
|
|
|
|
'asset_title'] not in permissions_settings.get_who_holds_tags_titles(),
|
2024-04-08 13:59:37 +00:00
|
|
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
|
|
|
if permission_data[index]['second_asset_title'] is not False:
|
|
|
|
assert driver.waitFor(
|
2024-05-03 09:36:51 +00:00
|
|
|
lambda: permission_data[index][
|
|
|
|
'second_asset_title'] not in permissions_settings.get_who_holds_tags_titles(),
|
2024-04-08 13:59:37 +00:00
|
|
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
|
|
|
elif permission_data[index]['checkbox_state'] is False:
|
|
|
|
assert driver.waitFor(lambda: 'Become member' in permissions_settings.get_is_allowed_tags_titles(),
|
|
|
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
|
|
|
else:
|
|
|
|
assert driver.waitFor(lambda: permissions_intro_view.is_hide_icon_visible,
|
|
|
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
|
|
|
|
|
|
|
|
with step('Check toast message for edited permission'):
|
|
|
|
messages = main_screen.wait_for_notification()
|
|
|
|
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 = main_screen.wait_for_notification()
|
|
|
|
assert ToastMessages.DELETE_PERMISSION_TOAST.value in messages, \
|
|
|
|
f"Toast message is incorrect, current message is {message}"
|
2024-03-29 14:49:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('params', [constants.community_params])
|
|
|
|
def test_add_5_member_role_permissions(main_screen: MainWindow, params):
|
2024-05-03 09:36:51 +00:00
|
|
|
with step('Enable creation of community option'):
|
|
|
|
settings = main_screen.left_panel.open_settings()
|
|
|
|
settings.left_panel.open_advanced_settings().enable_creation_of_communities()
|
|
|
|
|
2024-03-29 14:49:05 +00:00
|
|
|
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'
|