From ebbc55514e4bab94f9ad78b740f9f4912b7dab11 Mon Sep 17 00:00:00 2001 From: Anastasiya Semenkevich Date: Wed, 6 Nov 2024 14:05:25 +0300 Subject: [PATCH] chore(@e2e): improve category tests --- .../community/community_category_popup.py | 40 +++++++++---------- .../community/community_channel_popups.py | 8 +--- test/e2e/gui/components/context_menu.py | 14 +++++++ test/e2e/gui/components/delete_popup.py | 7 ++-- test/e2e/gui/objects_map/communities_names.py | 6 +-- test/e2e/gui/screens/community.py | 34 +++++----------- test/e2e/gui/screens/community_settings.py | 2 + .../communities/test_communities_channels.py | 2 +- ...test_community_category_add_edit_delete.py | 6 +-- ...y_permissions_add_edit_delete_duplicate.py | 4 +- 10 files changed, 62 insertions(+), 61 deletions(-) diff --git a/test/e2e/gui/components/community/community_category_popup.py b/test/e2e/gui/components/community/community_category_popup.py index a20bb83b51..21232a97e9 100644 --- a/test/e2e/gui/components/community/community_category_popup.py +++ b/test/e2e/gui/components/community/community_category_popup.py @@ -17,7 +17,7 @@ class CategoryPopup(BasePopup): def __init__(self): super(CategoryPopup, self).__init__() self._name_text_edit = TextEdit(names.createOrEditCommunityCategoryNameInput_TextEdit) - self._channel_item_checkbox = CheckBox(names.channelItemCheckbox_StatusCheckBox) + self.channel_item_checkbox = CheckBox(names.channelItemCheckbox_StatusCheckBox) self._channels_view = QObject(names.createOrEditCommunityCategoryChannelList_StatusListView) @allure.step('Wait until appears {0}') @@ -30,18 +30,6 @@ class CategoryPopup(BasePopup): self._name_text_edit.text = title return self - @allure.step('Click checkbox in edit category popup') - def click_checkbox_by_index(self, index: int): - time.sleep(1) - checkboxes = driver.findAllObjects(self._channel_item_checkbox.real_name) - if len(checkboxes) > 0: - for _index, item in enumerate(checkboxes): - if index == _index: - driver.mouseClick(item) - else: - raise AssertionError('Empty list of channels') - return self - class NewCategoryPopup(CategoryPopup): @@ -53,7 +41,7 @@ class NewCategoryPopup(CategoryPopup): def create(self, name: str, checkbox_state: bool): self._name_text_edit.text = name if checkbox_state: - self._channel_item_checkbox.click() + self.channel_item_checkbox.click() self._create_button.click() self.wait_until_hidden() @@ -61,10 +49,22 @@ class NewCategoryPopup(CategoryPopup): class EditCategoryPopup(CategoryPopup): def __init__(self): - super(EditCategoryPopup, self).__init__() - self._delete_button = Button(names.delete_Category_StatusButton) - self._save_button = Button(names.save_StatusButton) + super().__init__() + self.channel_item_checkbox = CheckBox(names.channelItemCheckbox_StatusCheckBox) + self.delete_button = Button(names.delete_Category_StatusButton) + self.save_button = Button(names.save_StatusButton) + + @allure.step('Click checkbox in edit category popup') + def click_checkbox_by_index(self, index: int): + time.sleep(1) + checkboxes = driver.findAllObjects(self.channel_item_checkbox.real_name) + if len(checkboxes) > 0: + for _index, item in enumerate(checkboxes): + if index == _index: + CheckBox(item).click() + else: + raise AssertionError('Empty list of channels') + return self + + - @allure.step('Click save in edit category popup') - def save(self): - self._save_button.click() diff --git a/test/e2e/gui/components/community/community_channel_popups.py b/test/e2e/gui/components/community/community_channel_popups.py index b0ab618fa6..b458682cd2 100644 --- a/test/e2e/gui/components/community/community_channel_popups.py +++ b/test/e2e/gui/components/community/community_channel_popups.py @@ -14,7 +14,7 @@ class ChannelPopup(BasePopup): super(ChannelPopup, self).__init__() self._name_text_edit = TextEdit(names.createOrEditCommunityChannelNameInput_TextEdit) self._description_text_edit = TextEdit(names.createOrEditCommunityChannelDescriptionInput_TextEdit) - self._save_create_button = Button(names.createOrEditCommunityChannelBtn_StatusButton) + self.save_create_button = Button(names.createOrEditCommunityChannelBtn_StatusButton) self._emoji_button = Button(names.createOrEditCommunityChannel_EmojiButton) self._add_permission_button = Button(names.add_permission_StatusButton) self._hide_channel_checkbox = CheckBox(names.hide_channel_checkbox) @@ -47,10 +47,6 @@ class NewChannelPopup(ChannelPopup): else: raise err - def save(self): - # TODO https://github.com/status-im/status-desktop/issues/15345 - self._save_create_button.click(timeout=30) - class EditChannelPopup(ChannelPopup): @@ -61,5 +57,5 @@ class EditChannelPopup(ChannelPopup): if emoji is not None: self._emoji_button.click() EmojiPopup().wait_until_appears().select(emoji) - self._save_create_button.click() + self.save_create_button.click() self.wait_until_hidden() diff --git a/test/e2e/gui/components/context_menu.py b/test/e2e/gui/components/context_menu.py index 47f33cf21a..ac0d05ff10 100644 --- a/test/e2e/gui/components/context_menu.py +++ b/test/e2e/gui/components/context_menu.py @@ -1,7 +1,9 @@ import allure +from gui.components.community.community_category_popup import CategoryPopup, EditCategoryPopup from gui.components.community.invite_contacts import InviteContactsPopup from gui.components.community.leave_community_confirmation import LeaveCommunityConfirmationPopup +from gui.components.delete_popup import DeleteCategoryPopup from gui.elements.object import QObject from gui.objects_map import names, communities_names @@ -23,6 +25,8 @@ class ContextMenu(QObject): self.invite_from_context = QObject(communities_names.invite_People_StatusMenuItem) self.mute_from_context = QObject(communities_names.mute_Community_StatusMenuItem) self.leave_community_option = QObject(communities_names.leave_Community_StatusMenuItem) + self.edit_category_item = QObject(communities_names.edit_Category_StatusMenuItem) + self.delete_category_item = QObject(communities_names.delete_Category_StatusMenuItem) @allure.step('Select in context menu') def select(self, value: str): @@ -39,4 +43,14 @@ class ContextMenu(QObject): self.leave_community_option.click() return LeaveCommunityConfirmationPopup() + @allure.step('Open edit category popup') + def open_edit_category_popup(self) -> EditCategoryPopup: + self.edit_category_item.click() + return EditCategoryPopup().wait_until_appears() + + @allure.step('Open delete category popup') + def open_delete_category_popup(self) -> DeleteCategoryPopup: + self.delete_category_item.click() + return DeleteCategoryPopup().wait_until_appears() + diff --git a/test/e2e/gui/components/delete_popup.py b/test/e2e/gui/components/delete_popup.py index e9ce15eb1b..5bc381dbb0 100644 --- a/test/e2e/gui/components/delete_popup.py +++ b/test/e2e/gui/components/delete_popup.py @@ -17,7 +17,7 @@ class DeletePopup(BasePopup): self._delete_button.click() except Exception as ex: if attempts: - self.delete(attempts-1) + self.delete(attempts - 1) else: raise ex @@ -26,14 +26,15 @@ class DeleteCategoryPopup(DeletePopup): def __init__(self): super().__init__() - self._delete_button = Button(names.confirm_StatusButton) + self.confirm_button = Button(names.confirm_StatusButton) class DeletePermissionPopup(DeletePopup): def __init__(self): super().__init__() - self._delete_button = Button(names.confirm_permission_delete_StatusButton) + self.confirm_delete_button = Button(names.confirm_permission_delete_StatusButton) + class DeleteMessagePopup(DeletePopup): diff --git a/test/e2e/gui/objects_map/communities_names.py b/test/e2e/gui/objects_map/communities_names.py index d0a598adb9..68d0e329b3 100644 --- a/test/e2e/gui/objects_map/communities_names.py +++ b/test/e2e/gui/objects_map/communities_names.py @@ -37,9 +37,9 @@ categoryItem_StatusChatListCategoryItem = {"container": mainWindow_scrollView_St delete_Category_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "deleteCategoryMenuItem", "type": "StatusMenuItem", "visible": True} create_category_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "createCommunityCategoryBtn", "type": "StatusMenuItem", "visible": True} edit_Category_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "editCategoryMenuItem", "type": "StatusMenuItem", "visible": True} -scrollView_menuButton_StatusChatListCategoryItemButton = {"container": mainWindow_scrollView_StatusScrollView, "id": "menuButton", "type": "StatusChatListCategoryItemButton", "unnamed": 1, "visible": True} -scrollView_toggleButton_StatusChatListCategoryItemButton = {"container": mainWindow_scrollView_StatusScrollView, "id": "toggleButton", "type": "StatusChatListCategoryItemButton", "unnamed": 1, "visible": True} -scrollView_addButton_StatusChatListCategoryItemButton = {"container": mainWindow_scrollView_StatusScrollView, "id": "addButton", "type": "StatusChatListCategoryItemButton", "unnamed": 1, "visible": True} +scrollView_menuButton_StatusChatListCategoryItemButton = {"container": mainWindow_scrollView_StatusScrollView, "objectName": "categoryItemButtonMore", "type": "StatusChatListCategoryItemButton", "visible": True} +scrollView_toggleButton_StatusChatListCategoryItemButton = {"container": mainWindow_scrollView_StatusScrollView, "objectName": "categoryItemButtonToggle", "type": "StatusChatListCategoryItemButton", "visible": True} +scrollView_addButton_StatusChatListCategoryItemButton = {"container": mainWindow_scrollView_StatusScrollView, "objectName": "categoryItemButtonAdd", "type": "StatusChatListCategoryItemButton", "visible": True} add_channels_StatusButton = {"checkable": False, "container": mainWindow_scrollView_StatusScrollView, "id": "addMembersBtn", "type": "StatusButton", "unnamed": 1, "visible": True} scrollView_general_StatusChatListItem = {"container": mainWindow_scrollView_StatusScrollView, "objectName": "general", "type": "StatusChatListItem", "visible": True} invite_People_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "invitePeople", "type": "StatusMenuItem", "visible": True} diff --git a/test/e2e/gui/screens/community.py b/test/e2e/gui/screens/community.py index d5a9ca5814..9f46bca89a 100644 --- a/test/e2e/gui/screens/community.py +++ b/test/e2e/gui/screens/community.py @@ -40,7 +40,7 @@ class CommunityScreen(QObject): @allure.step('Create channel') def create_channel(self, name: str, description: str, emoji: str = None): - self.left_panel.open_create_channel_popup().create(name, description, emoji).save() + self.left_panel.open_create_channel_popup().create(name, description, emoji).save_create_button.click() @allure.step('Edit channel') def edit_channel(self, channel, name: str, description: str, emoji: str = None): @@ -76,14 +76,16 @@ class CommunityScreen(QObject): @allure.step('Delete category from the list') def delete_category(self): - self.left_panel.open_more_options() - self.left_panel.open_delete_category_popup().delete() + context_menu = self.left_panel.open_more_options() + delete_pop_up = context_menu.open_delete_category_popup() + delete_pop_up.confirm_button.click() + return self @allure.step('Edit category') def edit_category(self): - self.left_panel.open_more_options() - self.left_panel.edit_category_item.click() - return EditCategoryPopup().wait_until_appears() + context_menu = self.left_panel.open_more_options() + edit_popup = context_menu.open_edit_category_popup() + return edit_popup @allure.step('Verify category in the list') def verify_category(self, category_name: str): @@ -343,16 +345,10 @@ class LeftPanel(QObject): driver.mouseClick(self.find_category_in_list(category_name).object) @allure.step('Open more options') - def open_more_options(self, attempts: int = 2): + def open_more_options(self): self._arrow_button.click() - try: - self._more_button.click() - except LookupError as err: - if attempts: - return self._more_button.click(attempts - 1) - else: - raise err - return self + self._more_button.click() + return ContextMenu() @allure.step('Get visibility state of delete item') def is_delete_item_visible(self) -> bool: @@ -362,15 +358,7 @@ class LeftPanel(QObject): def is_edit_item_visible(self) -> bool: return self.edit_category_item.is_visible - @allure.step('Open delete category popup') - def open_delete_category_popup(self) -> DeleteCategoryPopup: - self._delete_category_item.click() - return DeleteCategoryPopup().wait_until_appears() - @allure.step('Open edit category popup') - def open_edit_category_popup(self) -> EditCategoryPopup: - self.edit_category_item.click() - return CategoryPopup().wait_until_appears() @allure.step('Open new channel popup inside category') def open_new_channel_popup_in_category(self) -> NewChannelPopup: diff --git a/test/e2e/gui/screens/community_settings.py b/test/e2e/gui/screens/community_settings.py index 2727267100..d1b1da5594 100644 --- a/test/e2e/gui/screens/community_settings.py +++ b/test/e2e/gui/screens/community_settings.py @@ -9,6 +9,7 @@ import driver from gui.components.community.ban_member_popup import BanMemberPopup from gui.components.community.color_select_popup import ColorSelectPopup from gui.components.community.tags_select_popup import TagsSelectPopup +from gui.components.delete_popup import DeletePermissionPopup from gui.components.kick_member_popup import KickMemberPopup from gui.components.os.open_file_dialogs import OpenFileDialog from gui.components.picture_edit_popup import PictureEditPopup @@ -440,6 +441,7 @@ class PermissionsIntroView(QObject): @allure.step('Click delete permission button') def click_delete_permission(self): self._delete_permission_button.click() + return DeletePermissionPopup().wait_until_appears() @allure.step('Click duplicate permission button') def click_duplicate_permission(self): diff --git a/test/e2e/tests/communities/test_communities_channels.py b/test/e2e/tests/communities/test_communities_channels.py index 47b7f6d3da..bd8c061fdf 100644 --- a/test/e2e/tests/communities/test_communities_channels.py +++ b/test/e2e/tests/communities/test_communities_channels.py @@ -155,7 +155,7 @@ def test_member_cannot_see_hidden_channel(multiple_instances, user_data_one, use permission_popup.add_permission().set_who_holds_asset_and_amount(asset, amount).set_is_allowed_to( 'viewOnly').switch_hide_permission_checkbox(True).create_permission() permission_popup.hide_permission(True) - permission_popup.save() + permission_popup.save_button.click() channel = community_screen.left_panel.get_channel_parameters(channel_name) assert driver.waitFor(lambda: channel in community_screen.left_panel.channels, configs.timeouts.UI_LOAD_TIMEOUT_MSEC) diff --git a/test/e2e/tests/crtitical_tests_prs/test_community_category_add_edit_delete.py b/test/e2e/tests/crtitical_tests_prs/test_community_category_add_edit_delete.py index d52edcc3bc..875345f0d5 100644 --- a/test/e2e/tests/crtitical_tests_prs/test_community_category_add_edit_delete.py +++ b/test/e2e/tests/crtitical_tests_prs/test_community_category_add_edit_delete.py @@ -42,7 +42,7 @@ def test_create_edit_remove_community_category(main_screen: MainWindow, category with step('Create community channel inside category'): community_screen.left_panel.open_new_channel_popup_in_category().create(channel_name, channel_description, - channel_emoji).save() + channel_emoji).save_create_button.click() with step('Create community channel outside of category'): community_screen.create_channel(second_channel_name, second_channel_description, second_channel_emoji) @@ -53,7 +53,7 @@ def test_create_edit_remove_community_category(main_screen: MainWindow, category with step('Open edit category popup'): category_popup = community_screen.edit_category() category_popup.enter_category_title("New category").click_checkbox_by_index(0) - category_popup.save() + category_popup.save_button.click() with step('Verify that selected channel is now listed inside category'): assert community_screen.left_panel.get_channel_or_category_index(second_channel_name) == 3 @@ -61,7 +61,7 @@ def test_create_edit_remove_community_category(main_screen: MainWindow, category with step('Open edit category popup'): category_popup = community_screen.edit_category() category_popup.click_checkbox_by_index(2) - category_popup.save() + category_popup.save_button.click() with step('Verify that selected channel is now listed outside of category'): assert community_screen.left_panel.get_channel_or_category_index(second_channel_name) == 0 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 index e0ce8ff06f..ce73697147 100644 --- 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 @@ -113,8 +113,8 @@ def test_add_edit_remove_duplicate_permissions(main_screen: MainWindow): f"Toast message is incorrect, current message is {message}" with step('Delete permission'): - permissions_intro_view.click_delete_permission() - DeletePermissionPopup().wait_until_appears().delete() + delete_pop_up = permissions_intro_view.click_delete_permission() + delete_pop_up.confirm_delete_button.click() with step('Verify that permission was deleted'): assert driver.waitFor(lambda: PermissionsIntroView().is_visible)