From 5afb3b68119c2e296c064c7af87185c2841ff314 Mon Sep 17 00:00:00 2001 From: Valentina Novgorodtceva Date: Wed, 6 Dec 2023 19:00:09 +0700 Subject: [PATCH] test: tests create and remove community category added --- .../community/community_category_popup.py | 31 ++++++ test/e2e/gui/components/delete_popup.py | 7 ++ test/e2e/gui/objects_map/community_names.py | 8 ++ test/e2e/gui/objects_map/component_names.py | 11 ++- test/e2e/gui/screens/community.py | 97 ++++++++++++++++++- .../e2e/tests/communities/test_communities.py | 63 ------------ .../test_communities_categories.py | 51 ++++++++++ .../communities/test_communities_channels.py | 68 +++++++++++++ 8 files changed, 269 insertions(+), 67 deletions(-) create mode 100644 test/e2e/gui/components/community/community_category_popup.py create mode 100644 test/e2e/tests/communities/test_communities_categories.py create mode 100644 test/e2e/tests/communities/test_communities_channels.py diff --git a/test/e2e/gui/components/community/community_category_popup.py b/test/e2e/gui/components/community/community_category_popup.py new file mode 100644 index 0000000000..682f618444 --- /dev/null +++ b/test/e2e/gui/components/community/community_category_popup.py @@ -0,0 +1,31 @@ +import configs +from gui.components.base_popup import BasePopup +from gui.elements.button import Button +from gui.elements.check_box import CheckBox +from gui.elements.text_edit import TextEdit + + +class CategoryPopup(BasePopup): + + def __init__(self): + super(CategoryPopup, self).__init__() + self._name_text_edit = TextEdit('createOrEditCommunityCategoryNameInput_TextEdit') + self._general_item_checkbox = CheckBox('channelItemCheckbox_StatusCheckBox') + + def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC): + self._name_text_edit.wait_until_appears(timeout_msec) + return self + + +class NewCategoryPopup(CategoryPopup): + + def __init__(self): + super(NewCategoryPopup, self).__init__() + self._create_button = Button('create_StatusButton') + + def create(self, name: str, checkbox_state: bool): + self._name_text_edit.text = name + if checkbox_state: + self._general_item_checkbox.click() + self._create_button.click() + self.wait_until_hidden() diff --git a/test/e2e/gui/components/delete_popup.py b/test/e2e/gui/components/delete_popup.py index 603c21501f..17128e40ca 100644 --- a/test/e2e/gui/components/delete_popup.py +++ b/test/e2e/gui/components/delete_popup.py @@ -14,3 +14,10 @@ class DeletePopup(BasePopup): def delete(self): self._delete_button.click() self.wait_until_hidden() + + +class DeleteCategoryPopup(DeletePopup): + + def __init__(self): + super().__init__() + self._delete_button = Button('confirm_StatusButton') diff --git a/test/e2e/gui/objects_map/community_names.py b/test/e2e/gui/objects_map/community_names.py index 373edac545..63cc77806e 100644 --- a/test/e2e/gui/objects_map/community_names.py +++ b/test/e2e/gui/objects_map/community_names.py @@ -24,6 +24,14 @@ mainWindow_createChannelOrCategoryBtn_StatusBaseText = {"container": mainWindow_ create_channel_StatusMenuItem = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "createCommunityChannelBtn", "type": "StatusMenuItem", "visible": True} mainWindow_Join_Community_StatusButton = {"checkable": False, "container": mainWindow_communityColumnView_CommunityColumnView, "id": "joinCommunityButton", "text": "Join Community", "type": "StatusButton", "unnamed": 1, "visible": True} +add_categories_StatusFlatButton = {"checkable": False, "container": mainWindow_scrollView_StatusScrollView, "id": "manageBtn", "type": "StatusFlatButton", "visible": True} +categoryItem_StatusChatListCategoryItem = {"container": mainWindow_scrollView_StatusScrollView, "objectName": "categoryItem", "type": "StatusChatListCategoryItem", "visible": True} +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} +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} + # Tool Bar mainWindow_statusToolBar_StatusToolBar = {"container": mainWindow_communityLoader_Loader, "objectName": "statusToolBar", "type": "StatusToolBar", "visible": True} statusToolBar_chatToolbarMoreOptionsButton = {"container": mainWindow_statusToolBar_StatusToolBar, "objectName": "chatToolbarMoreOptionsButton", "type": "StatusFlatRoundButton", "visible": True} diff --git a/test/e2e/gui/objects_map/component_names.py b/test/e2e/gui/objects_map/component_names.py index 03ab4b9c77..59f34ca141 100644 --- a/test/e2e/gui/objects_map/component_names.py +++ b/test/e2e/gui/objects_map/component_names.py @@ -95,12 +95,18 @@ createCommunityIntroMessageInput_TextEdit = {"container": statusDesktop_mainWind createCommunityOutroMessageInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createCommunityOutroMessageInput", "type": "TextEdit", "visible": True} createCommunityFinalBtn_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "createCommunityFinalBtn", "type": "StatusButton", "visible": True} -# Community Channel Popup: +# Community Channel Popup createOrEditCommunityChannelNameInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelNameInput", "type": "TextEdit", "visible": True} createOrEditCommunityChannelDescriptionInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelDescriptionInput", "type": "TextEdit", "visible": True} createOrEditCommunityChannelBtn_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelBtn", "type": "StatusButton", "visible": True} createOrEditCommunityChannel_EmojiButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "StatusChannelPopup_emojiButton", "type": "StatusRoundButton", "visible": True} +# Community Category Popup +createOrEditCommunityCategoryNameInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityCategoryNameInput", "type": "TextEdit", "visible": True} +category_item_name_general_StatusListItem = {"container": statusDesktop_mainWindow_overlay, "objectName": "category_item_name_general", "type": "StatusListItem", "visible": True} +create_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityCategoryBtn", "type": "StatusButton", "visible": True} +channelItemCheckbox_StatusCheckBox = {"checkable": True, "container": statusDesktop_mainWindow_overlay, "id": "channelItemCheckbox", "type": "StatusCheckBox", "unnamed": 1, "visible": True} + # Invite Contacts Popup communityProfilePopupInviteFrindsPanel = {"container": statusDesktop_mainWindow_overlay, "objectName": "CommunityProfilePopupInviteFrindsPanel_ColumnLayout", "type": "ProfilePopupInviteFriendsPanel", "visible": True} communityProfilePopupInviteMessagePanel = {"container": statusDesktop_mainWindow_overlay, "objectName": "CommunityProfilePopupInviteMessagePanel_ColumnLayout", "type": "ProfilePopupInviteMessagePanel", "visible": True} @@ -124,8 +130,6 @@ sendContactRequestModal_ChatKey_Input_TextEdit = {"container": statusDesktop_mai sendContactRequestModal_SayWhoYouAre_Input_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "SendContactRequestModal_SayWhoYouAre_Input", "type": "TextEdit", "visible": True} send_Contact_Request_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "SendContactRequestModal_Send_Button", "type": "StatusButton", "visible": True} - - """ Common """ edit_TextEdit = {"container": statusDesktop_mainWindow_overlay, "type": "TextEdit", "unnamed": 1, "visible": True} @@ -188,6 +192,7 @@ mainWallet_AddEditAccountPopup_AccountEmoji = {"container": statusDesktop_mainWi # Delete Popup o_StatusDialogBackground = {"container": statusDesktop_mainWindow_overlay, "type": "StatusDialogBackground", "unnamed": 1, "visible": True} delete_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "deleteChatConfirmationDialogDeleteButton", "type": "StatusButton", "visible": True} +confirm_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "confirmDeleteCategoryButton", "type": "StatusButton", "visible": True} # Authenticate Popup keycardSharedPopupContent_KeycardPopupContent = {"container": statusDesktop_mainWindow_overlay, "objectName": "KeycardSharedPopupContent", "type": "KeycardPopupContent", "visible": True} diff --git a/test/e2e/gui/screens/community.py b/test/e2e/gui/screens/community.py index 42c040e9b5..1289a49a2c 100644 --- a/test/e2e/gui/screens/community.py +++ b/test/e2e/gui/screens/community.py @@ -1,13 +1,17 @@ +import time import typing import allure from allure_commons._allure import step +import configs import driver from constants import UserChannel +from driver.objects_access import walk_children +from gui.components.community.community_category_popup import NewCategoryPopup from gui.components.community.community_channel_popups import EditChannelPopup, NewChannelPopup from gui.components.community.welcome_community import WelcomeCommunityPopup -from gui.components.delete_popup import DeletePopup +from gui.components.delete_popup import DeletePopup, DeleteCategoryPopup from gui.elements.button import Button from gui.elements.list import List from gui.elements.object import QObject @@ -58,6 +62,20 @@ class CommunityScreen(QObject): assert self.chat.channel_name == name image.compare(self.chat.channel_icon, icon_in_chat, timout_sec=5) + @allure.step('Create category') + def create_category(self, name: str, general_checkbox: bool): + self.left_panel.open_create_category_popup().create(name, general_checkbox) + + @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() + + @allure.step('Verify category in the list') + def verify_category(self, category_name: str): + category = self.left_panel.find_category_in_list(category_name) + assert category.category_name == category_name + class ToolBar(QObject): @@ -99,6 +117,35 @@ class ToolBar(QObject): return DeletePopup().wait_until_appears() +class CategoryItem: + + def __init__(self, obj): + self.object = obj + self.category_name: typing.Optional[Image] = None + self._add_category_button: typing.Optional[Button] = None + self._more_button: typing.Optional[Button] = None + self._arrow_button: typing.Optional[Button] = None + self.init_ui() + + def __repr__(self): + return self.category_name + + def init_ui(self): + for child in walk_children(self.object): + if str(getattr(child, 'id', '')) == 'statusChatListCategoryItem': + self.category_name = str(child.text) + elif str(getattr(child, 'id', '')) == 'addButton': + self._add_channel_button = Button(name='', real_name=driver.objectMap.realName(child)) + elif str(getattr(child, 'id', '')) == 'menuButton': + self._more_button = Button(name='', real_name=driver.objectMap.realName(child)) + elif str(getattr(child, 'id', '')) == 'toggleButton': + self._arrow_button = Button(name='', real_name=driver.objectMap.realName(child)) + + @allure.step('Click arrow button') + def click_arrow_button(self): + self._arrow_button.click() + + class LeftPanel(QObject): def __init__(self): @@ -111,7 +158,15 @@ class LeftPanel(QObject): self._channel_icon_template = QObject('channel_identicon_StatusSmartIdenticon') self._channel_or_category_button = Button('mainWindow_createChannelOrCategoryBtn_StatusBaseText') self._create_channel_menu_item = Button('create_channel_StatusMenuItem') + self._create_category_menu_item = Button('create_category_StatusMenuItem') self._join_community_button = Button('mainWindow_Join_Community_StatusButton') + self._categories_items_list = List('scrollView_chatListItems_StatusListView') + self._category_list_item = QObject('categoryItem_StatusChatListCategoryItem') + self._create_category_button = Button('add_categories_StatusFlatButton') + self._delete_category_item = QObject('delete_Category_StatusMenuItem') + self._add_channel_inside_category_item = QObject('scrollView_addButton_StatusChatListCategoryItemButton') + self._more_button = Button('scrollView_menuButton_StatusChatListCategoryItemButton') + self._arrow_button = Button('scrollView_toggleButton_StatusChatListCategoryItemButton') @property @allure.step('Get community logo') @@ -147,6 +202,11 @@ class LeftPanel(QObject): )) return channels_list + @property + @allure.step('Get categories') + def categories_items(self) -> typing.List[CategoryItem]: + return [CategoryItem(item) for item in self._categories_items_list.items] + @allure.step('Get channel params') def get_channel_parameters(self, name) -> UserChannel: for channal in self.channels: @@ -173,11 +233,46 @@ class LeftPanel(QObject): return raise LookupError('Channel not found') + @allure.step('Open create category popup') + def open_create_category_popup(self) -> NewCategoryPopup: + self._channel_or_category_button.click() + self._create_category_menu_item.click() + return NewCategoryPopup().wait_until_appears() + @allure.step('Open join community popup') def open_welcome_community_popup(self): self._join_community_button.click() return WelcomeCommunityPopup().wait_until_appears() + @allure.step('Find category') + def find_category_in_list( + self, category_name: str, timeout_sec: int = configs.timeouts.MESSAGING_TIMEOUT_SEC): + started_at = time.monotonic() + category = None + while category is None: + categories = self.categories_items + for _category in categories: + if _category.category_name == category_name: + category = _category + assert time.monotonic() - started_at < timeout_sec, f'Category: {category_name} not found in {categories}' + return category + + @allure.step('Open more options') + def open_more_options(self): + self._arrow_button.click() + self._more_button.click() + + @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 new channel popup inside category') + def open_new_channel_popup_in_category(self) -> NewChannelPopup: + self._arrow_button.click() + self._add_channel_inside_category_item.click() + return NewChannelPopup().wait_until_appears() + class Chat(QObject): diff --git a/test/e2e/tests/communities/test_communities.py b/test/e2e/tests/communities/test_communities.py index a1c7cd51ba..8b81bd4369 100644 --- a/test/e2e/tests/communities/test_communities.py +++ b/test/e2e/tests/communities/test_communities.py @@ -10,13 +10,11 @@ import constants import driver from constants import UserAccount from gui.main_window import MainWindow -from gui.screens.community import CommunityScreen from scripts.tools import image @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703084', 'Create community') @pytest.mark.case(703084) -#@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/167") @pytest.mark.parametrize('params', [constants.community_params]) def test_create_community(user_account, main_screen: MainWindow, params): with step('Create community'): @@ -149,67 +147,6 @@ def test_edit_community(main_screen: MainWindow, params): # image.compare(community_info.image, 'logo_in_settings_updated.png') -@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703049', 'Create community channel') -@pytest.mark.case(703049) -@pytest.mark.parametrize('channel_name, channel_description, channel_emoji', [('Channel', 'Description', 'sunglasses')]) -@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/167") -def test_create_community_channel(main_screen: MainWindow, channel_name, channel_description, channel_emoji): - main_screen.create_community(constants.community_params) - community_screen = main_screen.left_panel.select_community(constants.community_params['name']) - community_screen.create_channel(channel_name, channel_description, channel_emoji) - - with step('Verify channel'): - community_screen.verify_channel( - channel_name, - channel_description, - 'channel_icon_in_list.png', - 'channel_icon_in_toolbar.png', - 'channel_icon_in_chat.png' - ) - - -@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703050', 'Edit community channel') -@pytest.mark.case(703050) -@pytest.mark.parametrize('channel_name, channel_description, channel_emoji', [('Channel', 'Description', 'sunglasses')]) -@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/167") -def test_edit_community_channel(main_screen, channel_name, channel_description, channel_emoji): - main_screen.create_community(constants.community_params) - community_screen = CommunityScreen() - - with step('Verify General channel'): - community_screen.verify_channel( - 'general', - 'General channel for the community', - 'general_channel_icon_in_list.png', - 'general_channel_icon_in_toolbar.png', - 'general_channel_icon_in_chat.png' - ) - - community_screen.edit_channel('general', channel_name, channel_description, channel_emoji) - - with step('Verify General channel'): - community_screen.verify_channel( - channel_name, - channel_description, - 'channel_icon_in_list.png', - 'channel_icon_in_toolbar.png', - 'channel_icon_in_chat.png' - ) - - -@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703051', 'Delete community channel') -@pytest.mark.case(703051) -#@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/167") -def test_delete_community_channel(main_screen): - main_screen.create_community(constants.community_params) - - with step('Delete channel'): - CommunityScreen().delete_channel('general') - - with step('Verify channel is not exists'): - assert not CommunityScreen().left_panel.channels - - @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703510', 'Join community via owner invite') @pytest.mark.case(703510) @pytest.mark.parametrize('user_data_one, user_data_two', [ diff --git a/test/e2e/tests/communities/test_communities_categories.py b/test/e2e/tests/communities/test_communities_categories.py new file mode 100644 index 0000000000..bb663e25f4 --- /dev/null +++ b/test/e2e/tests/communities/test_communities_categories.py @@ -0,0 +1,51 @@ +import allure +import pytest +from allure_commons._allure import step + +import constants +from gui.main_window import MainWindow + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703226', 'Add category') +@pytest.mark.case(703226) +@pytest.mark.parametrize('category_name, general_checkbox', [ + pytest.param('Category in general', True), + pytest.param('Category out of general', False) +]) +def test_create_community_category(main_screen: MainWindow, category_name, general_checkbox): + main_screen.create_community(constants.community_params) + community_screen = main_screen.left_panel.select_community(constants.community_params['name']) + community_screen.create_category(category_name, general_checkbox) + + with step('Verify category'): + community_screen.verify_category(category_name) + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703227', 'Remove category') +@pytest.mark.case(703227) +@pytest.mark.parametrize('category_name, general_checkbox, channel_name, channel_description, channel_emoji', [ + pytest.param('Category in general', True, 'Channel', 'Description', 'sunglasses') +]) +def test_remove_community_category(main_screen: MainWindow, category_name, general_checkbox, channel_name, + channel_description, channel_emoji): + main_screen.create_community(constants.community_params) + community_screen = main_screen.left_panel.select_community(constants.community_params['name']) + community_screen.create_category(category_name, general_checkbox) + + with step('Verify category'): + community_screen.verify_category(category_name) + + with step('Create channel inside category'): + community_screen.left_panel.open_new_channel_popup_in_category().create(channel_name, channel_description, channel_emoji) + + with step('Delete category'): + community_screen.delete_category() + + with step('Verify category is not in the list'): + assert category_name not in community_screen.left_panel.categories_items + + with step('Verify created channel and general channel are still in the list'): + new_channel = community_screen.left_panel.get_channel_parameters(channel_name) + general_channel = community_screen.left_panel.get_channel_parameters('general') + assert new_channel in community_screen.left_panel.channels + assert general_channel in community_screen.left_panel.channels diff --git a/test/e2e/tests/communities/test_communities_channels.py b/test/e2e/tests/communities/test_communities_channels.py new file mode 100644 index 0000000000..50174bcd18 --- /dev/null +++ b/test/e2e/tests/communities/test_communities_channels.py @@ -0,0 +1,68 @@ +import allure +import pytest +from allure_commons._allure import step + +import constants +from gui.main_window import MainWindow +from gui.screens.community import CommunityScreen + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703049', 'Create community channel') +@pytest.mark.case(703049) +@pytest.mark.parametrize('channel_name, channel_description, channel_emoji', [('Channel', 'Description', 'sunglasses')]) +@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/167") +def test_create_community_channel(main_screen: MainWindow, channel_name, channel_description, channel_emoji): + main_screen.create_community(constants.community_params) + community_screen = main_screen.left_panel.select_community(constants.community_params['name']) + community_screen.create_channel(channel_name, channel_description, channel_emoji) + + with step('Verify channel'): + community_screen.verify_channel( + channel_name, + channel_description, + 'channel_icon_in_list.png', + 'channel_icon_in_toolbar.png', + 'channel_icon_in_chat.png' + ) + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703050', 'Edit community channel') +@pytest.mark.case(703050) +@pytest.mark.parametrize('channel_name, channel_description, channel_emoji', [('Channel', 'Description', 'sunglasses')]) +@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/167") +def test_edit_community_channel(main_screen, channel_name, channel_description, channel_emoji): + main_screen.create_community(constants.community_params) + community_screen = CommunityScreen() + + with step('Verify General channel'): + community_screen.verify_channel( + 'general', + 'General channel for the community', + 'general_channel_icon_in_list.png', + 'general_channel_icon_in_toolbar.png', + 'general_channel_icon_in_chat.png' + ) + + community_screen.edit_channel('general', channel_name, channel_description, channel_emoji) + + with step('Verify General channel'): + community_screen.verify_channel( + channel_name, + channel_description, + 'channel_icon_in_list.png', + 'channel_icon_in_toolbar.png', + 'channel_icon_in_chat.png' + ) + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703051', 'Delete community channel') +@pytest.mark.case(703051) +@pytest.mark.skip(reason="https://github.com/status-im/desktop-qa-automation/issues/167") +def test_delete_community_channel(main_screen): + main_screen.create_community(constants.community_params) + + with step('Delete channel'): + CommunityScreen().delete_channel('general') + + with step('Verify channel is not exists'): + assert not CommunityScreen().left_panel.channels