From a529dd04b76c117700b5719ea3f489d8ef52a234 Mon Sep 17 00:00:00 2001 From: Valentina Novgorodtceva Date: Thu, 11 Jan 2024 16:18:19 +0700 Subject: [PATCH] test: test clicking category added --- test/e2e/constants/user.py | 2 +- test/e2e/gui/screens/community.py | 18 +++++++- .../test_communities_categories.py | 41 ++++++++++++++++++- 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/test/e2e/constants/user.py b/test/e2e/constants/user.py index 3cc0cf1d5c..b461d12337 100644 --- a/test/e2e/constants/user.py +++ b/test/e2e/constants/user.py @@ -36,7 +36,7 @@ community_params = { } UserCommunityInfo = namedtuple('CommunityInfo', ['name', 'description', 'members', 'image']) -UserChannel = namedtuple('Channel', ['name', 'selected']) +UserChannel = namedtuple('Channel', ['name', 'selected', 'visible']) account_list_item = namedtuple('AccountListItem', ['name', 'color', 'emoji']) wallet_account_list_item = namedtuple('WalletAccountListItem', ['name', 'icon_color', 'icon_emoji', 'object']) diff --git a/test/e2e/gui/screens/community.py b/test/e2e/gui/screens/community.py index 720e54a45c..0a13eb976a 100644 --- a/test/e2e/gui/screens/community.py +++ b/test/e2e/gui/screens/community.py @@ -153,6 +153,7 @@ class CategoryItem: self._add_category_button: typing.Optional[Button] = None self._more_button: typing.Optional[Button] = None self._arrow_button: typing.Optional[Button] = None + self._arrow_icon: typing.Optional[QObject] = None self.init_ui() def __repr__(self): @@ -168,11 +169,17 @@ class CategoryItem: 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)) + elif str(getattr(child, 'objectName', '')) == 'chevron-down-icon': + self._arrow_icon = QObject(name='', real_name=driver.objectMap.realName(child)) @allure.step('Click arrow button') def click_arrow_button(self): self._arrow_button.click() + @allure.step('Get arrow button rotation value') + def get_arrow_icon_rotation_value(self) -> int: + return self._arrow_icon.object.rotation + class LeftPanel(QObject): @@ -229,7 +236,8 @@ class LeftPanel(QObject): self._channel_icon_template.real_name['container'] = container channels_list.append(UserChannel( str(obj.objectName), - obj.item.selected + obj.item.selected, + obj.item.visible )) return channels_list @@ -238,6 +246,11 @@ class LeftPanel(QObject): def categories_items(self) -> typing.List[CategoryItem]: return [CategoryItem(item) for item in self._categories_items_list.items] + @allure.step('Get arrow button rotation value') + def get_arrow_icon_rotation_value(self, category_name) -> int: + category = self.find_category_in_list(category_name) + return int(category.get_arrow_icon_rotation_value()) + @allure.step('Get channel params') def get_channel_parameters(self, name) -> UserChannel: for channel in self.channels: @@ -315,6 +328,9 @@ class LeftPanel(QObject): assert time.monotonic() - started_at < timeout_sec, f'Category: {category_name} not found in {categories}' return category + def click_category(self, category_name: str): + driver.mouseClick(self.find_category_in_list(category_name).object) + @allure.step('Open more options') def open_more_options(self): self._arrow_button.click() diff --git a/test/e2e/tests/communities/test_communities_categories.py b/test/e2e/tests/communities/test_communities_categories.py index 2f23198a7a..ad8989bd83 100644 --- a/test/e2e/tests/communities/test_communities_categories.py +++ b/test/e2e/tests/communities/test_communities_categories.py @@ -4,7 +4,6 @@ from allure_commons._allure import step import configs import constants -from gui.components.community.community_category_popup import EditCategoryPopup, CategoryPopup from gui.components.context_menu import ContextMenu from gui.main_window import MainWindow from . import marks @@ -142,3 +141,43 @@ def test_member_role_cannot_delete_category(main_screen: MainWindow): assert not ContextMenu().is_visible with step('Verify that delete item is not present in more options context menu'): assert not community_screen.left_panel.open_more_options().is_delete_item_visible() + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/704622', 'Community category clicking') +@pytest.mark.case(704622) +@pytest.mark.parametrize('category_name, general_checkbox', + [pytest.param('Category in general', True)]) +def test_clicking_community_category(main_screen: MainWindow, category_name, general_checkbox): + with step('Create community and select it'): + main_screen.create_community(constants.community_params) + community_screen = main_screen.left_panel.select_community(constants.community_params['name']) + + with step('Create community category and verify that it displays correctly'): + community_screen.create_category(category_name, general_checkbox) + community_screen.verify_category(category_name) + + with step('Verify that general channel is listed inside category'): + assert community_screen.left_panel.get_channel_or_category_index('general') == 1 + + with step('Verify that general channel is visible and toggle button has down direction'): + general_channel = community_screen.left_panel.get_channel_parameters('general') + assert general_channel.visible + assert community_screen.left_panel.get_arrow_icon_rotation_value(category_name) == 0 + + with step('Click added category'): + community_screen.left_panel.click_category(category_name) + + with step('Verify that general channel is not visible and toggle button has right direction'): + general_channel = community_screen.left_panel.get_channel_parameters('general') + assert not general_channel.visible + assert community_screen.left_panel.get_arrow_icon_rotation_value(category_name) == 270 + + with step( + 'Click open more options button and verify that toggle button has down direction'): + community_screen.left_panel.open_more_options() + # rotation should be 0 here, because we click arrow button before open more options, otherwise it doesn't see it + assert community_screen.left_panel.get_arrow_icon_rotation_value(category_name) == 0 + + with step('Click plus button and verify that toggle button has down direction'): + community_screen.left_panel._add_channel_inside_category_item.click() + assert community_screen.left_panel.get_arrow_icon_rotation_value(category_name) == 0