From dbf6447ecaf40314d2be85fcd2337dbc3dc00ca8 Mon Sep 17 00:00:00 2001 From: Anastasiya Semenkevich Date: Mon, 26 Feb 2024 19:44:55 +0300 Subject: [PATCH] chore: fix verifications so now they are working --- gui/components/context_menu.py | 13 ++++++++++- gui/screens/community.py | 9 ++++---- .../communities/test_communities_channels.py | 23 ++++++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/gui/components/context_menu.py b/gui/components/context_menu.py index 4e12569..0e4bb7a 100644 --- a/gui/components/context_menu.py +++ b/gui/components/context_menu.py @@ -1,7 +1,7 @@ import allure from gui.elements.object import QObject -from gui.objects_map import names +from gui.objects_map import names, communities_names class ContextMenu(QObject): @@ -16,6 +16,17 @@ class ContextMenu(QObject): self._context_edit_saved_address_option = QObject(names.contextSavedAddressEdit) self._context_delete_saved_address_option = QObject(names.contextSavedAddressDelete) + self._edit_channel_context_item = QObject(communities_names.edit_Channel_StatusMenuItem) + self._delete_channel_context_item = QObject(communities_names.delete_Channel_StatusMenuItem) + + @allure.step('Is edit channel option present in context menu') + def is_edit_channel_option_present(self): + return self._edit_channel_context_item.exists + + @allure.step('Is delete channel option present in context menu') + def is_delete_channel_option_present(self): + return self._delete_channel_context_item.exists + @allure.step('Select in context menu') def select(self, value: str): self._menu_item.real_name['text'] = value diff --git a/gui/screens/community.py b/gui/screens/community.py index e654442..320df54 100644 --- a/gui/screens/community.py +++ b/gui/screens/community.py @@ -135,16 +135,15 @@ class ToolBar(QObject): @allure.step('Open more options dropdown') def open_more_options_dropdown(self): self._more_options_button.click() - self._edit_channel_context_item.wait_until_appears() - return self + return ContextMenu() @allure.step('Get visibility state of edit item') def is_edit_item_visible(self) -> bool: - return self._edit_channel_context_item.is_visible + return self._edit_channel_context_item.exists @allure.step('Get visibility state of delete item') def is_delete_item_visible(self) -> bool: - return self._delete_channel_context_item.is_visible + return self._delete_channel_context_item.exists class CategoryItem: @@ -319,7 +318,7 @@ class LeftPanel(QObject): @allure.step('Open general channel context menu') def open_general_channel_context_menu(self): self._general_channel_item.open_context_menu() - ContextMenu().wait_until_appears() + return ContextMenu() @allure.step('Open category context menu') def open_category_context_menu(self): diff --git a/tests/communities/test_communities_channels.py b/tests/communities/test_communities_channels.py index 0c4b29a..940b002 100644 --- a/tests/communities/test_communities_channels.py +++ b/tests/communities/test_communities_channels.py @@ -82,6 +82,7 @@ def test_create_edit_remove_community_channel(main_screen, channel_name, channel def test_member_role_cannot_add_edit_and_delete_channels(main_screen: MainWindow): with step('Choose community user is not owner of'): community_screen = main_screen.left_panel.select_community('Super community') + with step('Verify that member cannot add new channel'): with step('Verify that create channel or category button is not present'): assert not community_screen.left_panel.is_create_channel_or_category_button_visible() @@ -90,19 +91,25 @@ def test_member_role_cannot_add_edit_and_delete_channels(main_screen: MainWindow with step('Right-click a channel on the left navigation bar'): community_screen.left_panel.right_click_on_panel() with step('Verify that context menu does not appear'): - assert not ContextMenu().is_visible + assert ContextMenu().is_visible is False, \ + f"Context menu should not appear" with step('Verify that member cannot edit and delete channel'): with step('Right-click on general channel in the left navigation bar'): - community_screen.left_panel.open_general_channel_context_menu() + general_channel_context_menu = community_screen.left_panel.open_general_channel_context_menu() with step('Verify that edit item is not present in context menu'): - assert not community_screen.tool_bar.is_edit_item_visible() + assert general_channel_context_menu.is_edit_channel_option_present() is False, \ + f'Edit channel option is present when it should not' with step('Verify that delete item is not present in context menu'): - assert not community_screen.tool_bar.is_delete_item_visible() + assert general_channel_context_menu.is_delete_channel_option_present() is False, \ + f'Delete channel option is present when it should not' - with step('Open more options context menu'): - more_options_dropdown = community_screen.tool_bar.open_more_options_dropdown() + with step('Open context menu from the tool bar'): + more_options = community_screen.tool_bar.open_more_options_dropdown() with step('Verify that edit item is not present in context menu'): - assert not more_options_dropdown.is_edit_item_visible() + assert more_options.is_edit_channel_option_present() is False, \ + f'Edit channel option is present when it should not' with step('Verify that delete item is not present in context menu'): - assert not more_options_dropdown.is_delete_item_visible() + assert more_options.is_delete_channel_option_present() is False, \ + f'Delete channel option is present when it should not' + \ No newline at end of file