From a4e7b6391888518934d6d8a2a7ed8c9f0e2dadd5 Mon Sep 17 00:00:00 2001 From: Anastasiya Semenkevich Date: Tue, 8 Oct 2024 19:06:13 +0300 Subject: [PATCH] chore: stabilise test for permission management by randomisation --- test/e2e/constants/user.py | 101 +++++++++ ...est_communities_limit_to_5_permissions.py} | 46 +--- ...t_community_permissions_add_edit_delete.py | 207 ------------------ ...y_permissions_add_edit_delete_duplicate.py | 152 +++++++++++++ 4 files changed, 256 insertions(+), 250 deletions(-) rename test/e2e/tests/communities/{test_communities_permissions.py => test_communities_limit_to_5_permissions.py} (72%) delete mode 100644 test/e2e/tests/crtitical_tests_prs/test_community_permissions_add_edit_delete.py create mode 100644 test/e2e/tests/crtitical_tests_prs/test_community_permissions_add_edit_delete_duplicate.py diff --git a/test/e2e/constants/user.py b/test/e2e/constants/user.py index 014acda034..f1868bdc46 100644 --- a/test/e2e/constants/user.py +++ b/test/e2e/constants/user.py @@ -72,3 +72,104 @@ community_tags = ['Activism', 'Art', 'Blockchain', 'Books & blogs', 'Career', 'C 'Lifestyle', 'Local', 'Love', 'Markets', 'Movies & TV', 'Music', 'NFT', 'NSFW', 'News', 'Non-profit', 'Org', 'Pets', 'Play', 'Podcast', 'Politics', 'Privacy', 'Product', 'Psyche', 'Security', 'Social', 'Software dev', 'Sports', 'Tech', 'Travel', 'Vehicles', 'Web3'] + +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' + } + ] + +permission_data_member = [ + { + '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' + } + ] diff --git a/test/e2e/tests/communities/test_communities_permissions.py b/test/e2e/tests/communities/test_communities_limit_to_5_permissions.py similarity index 72% rename from test/e2e/tests/communities/test_communities_permissions.py rename to test/e2e/tests/communities/test_communities_limit_to_5_permissions.py index 4911fceb5a..8516715a15 100644 --- a/test/e2e/tests/communities/test_communities_permissions.py +++ b/test/e2e/tests/communities/test_communities_limit_to_5_permissions.py @@ -5,6 +5,7 @@ from allure_commons._allure import step import configs import constants import driver +from constants import permission_data_member from constants.community_settings import LimitWarnings from gui.main_window import MainWindow from . import marks @@ -17,6 +18,8 @@ pytestmark = marks @pytest.mark.case(739309) @pytest.mark.parametrize('params', [constants.community_params]) def test_add_5_member_role_permissions(main_screen: MainWindow, params): + + permission_data = permission_data_member with step('Enable creation of community option'): settings = main_screen.left_panel.open_settings() settings.left_panel.open_advanced_settings().enable_creation_of_communities() @@ -25,49 +28,6 @@ def test_add_5_member_role_permissions(main_screen: MainWindow, params): 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() diff --git a/test/e2e/tests/crtitical_tests_prs/test_community_permissions_add_edit_delete.py b/test/e2e/tests/crtitical_tests_prs/test_community_permissions_add_edit_delete.py deleted file mode 100644 index c88f139bac..0000000000 --- a/test/e2e/tests/crtitical_tests_prs/test_community_permissions_add_edit_delete.py +++ /dev/null @@ -1,207 +0,0 @@ -import allure -import pytest -from allure_commons._allure import step - -import configs -import constants -import driver -from constants.community_settings import ToastMessages, LimitWarnings, PermissionsElements -from gui.components.changes_detected_popup import PermissionsChangesDetectedToastMessage -from gui.components.delete_popup import DeletePermissionPopup -from gui.main_window import MainWindow -from gui.screens.community_settings import PermissionsIntroView -from . import marks - -pytestmark = marks - - -@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703632', - 'Manage community: Adding new permissions, Editing permissions, Deleting permission') -@pytest.mark.case(703632, 705014, 705016) -@pytest.mark.parametrize('params', [constants.community_params]) -@pytest.mark.critical -def test_add_edit_and_remove_permissions(main_screen: MainWindow, params): - with step('Enable creation of community option'): - settings = main_screen.left_panel.open_settings() - settings.left_panel.open_advanced_settings().enable_creation_of_communities() - - 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', - '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' - } - ] - - 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() - - 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']) - 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']) - 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: - assert driver.waitFor( - lambda: permission_data[index]['asset_title'] in permissions_settings.get_who_holds_tags_titles(), - configs.timeouts.UI_LOAD_TIMEOUT_MSEC) - if permission_data[index]['second_asset_title'] is not False: - assert driver.waitFor(lambda: permission_data[index][ - 'second_asset_title'] in permissions_settings.get_who_holds_tags_titles(), - configs.timeouts.UI_LOAD_TIMEOUT_MSEC) - if permission_data[index]['allowed_to_title'] is not False: - assert driver.waitFor(lambda: permission_data[index][ - 'allowed_to_title'] in permissions_settings.get_is_allowed_tags_titles(), - configs.timeouts.UI_LOAD_TIMEOUT_MSEC) - if permission_data[index]['in_channel'] is False: - assert driver.waitFor( - lambda: params['name'] in permissions_settings.get_in_community_in_channel_tags_titles(), - configs.timeouts.UI_LOAD_TIMEOUT_MSEC) - if permission_data[index]['in_channel']: - assert driver.waitFor(lambda: permission_data[index][ - 'in_channel'] in permissions_settings.get_in_community_in_channel_tags_titles(), - configs.timeouts.UI_LOAD_TIMEOUT_MSEC) - - with step('Edit permission'): - edit_permission_view = permissions_intro_view.open_edit_permission_view() - if permission_data[index]['allowed_to'] is 'becomeAdmin' and permission_data[index][ - 'checkbox_state'] is True: - 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() - if permission_data[index]['allowed_to'] is 'becomeAdmin' and permission_data[index][ - 'checkbox_state'] is True: - if permission_data[index]['asset_title'] is not False: - assert driver.waitFor(lambda: permission_data[index][ - 'asset_title'] not in permissions_settings.get_who_holds_tags_titles(), - configs.timeouts.UI_LOAD_TIMEOUT_MSEC) - if permission_data[index]['second_asset_title'] is not False: - assert driver.waitFor( - lambda: permission_data[index][ - 'second_asset_title'] not in permissions_settings.get_who_holds_tags_titles(), - 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}" - - with step('Create new permission'): - new_permission_data = { - 'checkbox_state': True, - 'first_asset': 'ETH', - 'amount': '6', - 'allowed_to': 'becomeMember' - } - permissions_settings = permissions_intro_view.add_new_permission() - permissions_settings.set_who_holds_checkbox_state(new_permission_data['checkbox_state']) - permissions_settings.set_who_holds_asset_and_amount(new_permission_data['first_asset'], - new_permission_data['amount']) - permissions_settings.set_is_allowed_to(new_permission_data['allowed_to']) - permissions_settings.create_permission() - - with step('Duplicate created permission and verify correct duplicate warning appears'): - permission_view = permissions_intro_view.click_duplicate_permission() - assert permission_view.get_warning_text() == PermissionsElements.DUPLICATE_WARNING.value - permissions_settings.set_who_holds_asset_and_amount('Aragon', '10') - permissions_settings.create_permission() - - with step('Duplicated permission is displayed on permission page'): - assert driver.waitFor( - lambda: '10 ANT' in permissions_settings.get_who_holds_tags_titles(), - configs.timeouts.UI_LOAD_TIMEOUT_MSEC) \ No newline at end of file diff --git a/test/e2e/tests/crtitical_tests_prs/test_community_permissions_add_edit_delete_duplicate.py b/test/e2e/tests/crtitical_tests_prs/test_community_permissions_add_edit_delete_duplicate.py new file mode 100644 index 0000000000..3cc3eaef7d --- /dev/null +++ b/test/e2e/tests/crtitical_tests_prs/test_community_permissions_add_edit_delete_duplicate.py @@ -0,0 +1,152 @@ +import random + +import allure +import pytest +from allure_commons._allure import step + +import configs +import constants +import driver +from constants import permission_data +from constants.community_settings import ToastMessages, PermissionsElements +from gui.components.changes_detected_popup import PermissionsChangesDetectedToastMessage +from gui.components.delete_popup import DeletePermissionPopup +from gui.main_window import MainWindow +from gui.screens.community_settings import PermissionsIntroView +from . import marks + +pytestmark = marks + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703632', + 'Manage community: Adding new permissions, Editing permissions, Deleting permission') +@pytest.mark.case(703632, 705014, 705016) +@pytest.mark.parametrize('params', [constants.community_params]) +@pytest.mark.critical +def test_add_edit_remove_duplicate_permissions(main_screen: MainWindow, params): + with step('Enable creation of community option'): + settings = main_screen.left_panel.open_settings() + settings.left_panel.open_advanced_settings().enable_creation_of_communities() + + main_screen.create_community(params['name'], params['description'], + params['intro'], params['outro'], + params['logo']['fp'], params['banner']['fp']) + + permission_set = random.choice(permission_data) + + 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'): + permissions_settings = permissions_intro_view.add_new_permission() + permissions_settings.set_who_holds_checkbox_state(permission_set['checkbox_state']) + permissions_settings.set_who_holds_asset_and_amount(permission_set['first_asset'], + permission_set['amount']) + permissions_settings.set_who_holds_asset_and_amount(permission_set['second_asset'], + permission_set['amount']) + permissions_settings.set_is_allowed_to(permission_set['allowed_to']) + permissions_settings.set_in(permission_set['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_set['asset_title'] is not False: + assert driver.waitFor( + lambda: permission_set['asset_title'] in permissions_settings.get_who_holds_tags_titles(), + configs.timeouts.UI_LOAD_TIMEOUT_MSEC) + if permission_set['second_asset_title'] is not False: + assert driver.waitFor(lambda: permission_set[ + 'second_asset_title'] in permissions_settings.get_who_holds_tags_titles(), + configs.timeouts.UI_LOAD_TIMEOUT_MSEC) + if permission_set['allowed_to_title'] is not False: + assert driver.waitFor(lambda: permission_set[ + 'allowed_to_title'] in permissions_settings.get_is_allowed_tags_titles(), + configs.timeouts.UI_LOAD_TIMEOUT_MSEC) + if permission_set['in_channel'] is False: + assert driver.waitFor( + lambda: params['name'] in permissions_settings.get_in_community_in_channel_tags_titles(), + configs.timeouts.UI_LOAD_TIMEOUT_MSEC) + if permission_set['in_channel']: + assert driver.waitFor(lambda: permission_set[ + 'in_channel'] in permissions_settings.get_in_community_in_channel_tags_titles(), + configs.timeouts.UI_LOAD_TIMEOUT_MSEC) + + with step('Edit permission'): + edit_permission_view = permissions_intro_view.open_edit_permission_view() + if permission_set['allowed_to'] is 'becomeAdmin' and permission_set['checkbox_state'] is True: + permissions_settings.set_who_holds_checkbox_state(False) + elif permission_set['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() + if permission_set['allowed_to'] is 'becomeAdmin' and permission_set[ + 'checkbox_state'] is True: + if permission_set['asset_title'] is not False: + assert driver.waitFor(lambda: permission_set[ + 'asset_title'] not in permissions_settings.get_who_holds_tags_titles(), + configs.timeouts.UI_LOAD_TIMEOUT_MSEC) + if permission_set['second_asset_title'] is not False: + assert driver.waitFor( + lambda: permission_set[ + 'second_asset_title'] not in permissions_settings.get_who_holds_tags_titles(), + configs.timeouts.UI_LOAD_TIMEOUT_MSEC) + elif permission_set['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}" + + with step('Create new permission'): + new_permission_data = { + 'checkbox_state': True, + 'first_asset': 'ETH', + 'amount': '6', + 'allowed_to': 'becomeMember' + } + permissions_settings = permissions_intro_view.add_new_permission() + permissions_settings.set_who_holds_checkbox_state(new_permission_data['checkbox_state']) + permissions_settings.set_who_holds_asset_and_amount(new_permission_data['first_asset'], + new_permission_data['amount']) + permissions_settings.set_is_allowed_to(new_permission_data['allowed_to']) + permissions_settings.create_permission() + + with step('Duplicate created permission and verify correct duplicate warning appears'): + permission_view = permissions_intro_view.click_duplicate_permission() + assert permission_view.get_warning_text() == PermissionsElements.DUPLICATE_WARNING.value + permissions_settings.set_who_holds_asset_and_amount('Aragon', '10') + permissions_settings.create_permission() + + with step('Duplicated permission is displayed on permission page'): + assert driver.waitFor( + lambda: '10 ANT' in permissions_settings.get_who_holds_tags_titles(), + configs.timeouts.UI_LOAD_TIMEOUT_MSEC)