From 034b29d12e188795afe92d5fc9933036805b5902 Mon Sep 17 00:00:00 2001 From: Valentina Novgorodtceva Date: Fri, 31 May 2024 17:45:47 +0700 Subject: [PATCH] test: share community link test --- gui/components/community/invite_contacts.py | 7 +++++ gui/components/context_menu.py | 8 ++++++ gui/main_window.py | 4 +-- gui/objects_map/communities_names.py | 2 ++ gui/objects_map/names.py | 1 + scripts/utils/browser.py | 13 +++++++++ .../test_communities_share_link.py | 27 +++++++++++++++++++ 7 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 scripts/utils/browser.py create mode 100644 tests/communities/test_communities_share_link.py diff --git a/gui/components/community/invite_contacts.py b/gui/components/community/invite_contacts.py index 3dc2771..045af77 100644 --- a/gui/components/community/invite_contacts.py +++ b/gui/components/community/invite_contacts.py @@ -1,6 +1,7 @@ import typing import allure +import pyperclip import configs.timeouts import driver @@ -20,6 +21,7 @@ class InviteContactsPopup(BasePopup): self._message_text_edit = TextEdit(names.communityProfilePopupInviteMessagePanel_MessageInput_TextEdit) self._invited_member_item = QObject(names.o_StatusMemberListItem_2) self._send_button = Button(names.send_1_invite_StatusButton) + self._copy_button = Button(names.copy_icon_StatusIcon) @property @allure.step('Get contacts') @@ -53,3 +55,8 @@ class InviteContactsPopup(BasePopup): self._send_button.click() self.wait_until_hidden() + + @allure.step('Copy community link') + def copy_community_link(self): + self._copy_button.click() + return str(pyperclip.paste()) diff --git a/gui/components/context_menu.py b/gui/components/context_menu.py index dd30015..98b4238 100644 --- a/gui/components/context_menu.py +++ b/gui/components/context_menu.py @@ -1,5 +1,6 @@ import allure +from gui.components.community.invite_contacts import InviteContactsPopup from gui.elements.object import QObject from gui.objects_map import names, communities_names @@ -17,6 +18,8 @@ class ContextMenu(QObject): 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) + self._invite_people_item = QObject(communities_names.invite_People_StatusMenuItem) + self._mute_community_item = QObject(communities_names.mute_Community_StatusMenuItem) @allure.step('Is edit channel option present in context menu') def is_edit_channel_option_present(self): @@ -58,3 +61,8 @@ class ContextMenu(QObject): @allure.step('Check delete option visibility in context menu') def is_delete_account_option_present(self): return self._context_delete_account_option.is_visible + + @allure.step('Select invite people to community') + def select_invite_people(self): + self._invite_people_item.click() + return InviteContactsPopup() diff --git a/gui/main_window.py b/gui/main_window.py index aa85b66..1b5904a 100644 --- a/gui/main_window.py +++ b/gui/main_window.py @@ -129,8 +129,8 @@ class LeftPanel(QObject): @allure.step('Open context menu for community') def open_community_context_menu(self, name: str) -> ContextMenu: - driver.objectMap.realName(self._get_community(name))['name'] = name - self._get_community(name).right_click() + community = QObject(driver.objectMap.realName(self._get_community(name))) + community.right_click() return ContextMenu().wait_until_appears() @allure.step('Invite people in community') diff --git a/gui/objects_map/communities_names.py b/gui/objects_map/communities_names.py index 5f5dc09..4e6db79 100644 --- a/gui/objects_map/communities_names.py +++ b/gui/objects_map/communities_names.py @@ -35,6 +35,8 @@ scrollView_toggleButton_StatusChatListCategoryItemButton = {"container": mainWin scrollView_addButton_StatusChatListCategoryItemButton = {"container": mainWindow_scrollView_StatusScrollView, "id": "addButton", "type": "StatusChatListCategoryItemButton", "unnamed": 1, "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} +mute_Community_StatusMenuItem = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "StatusMenuItemDelegate", "type": "StatusMenuItem", "visible": True} # Tool Bar mainWindow_statusToolBar_StatusToolBar = {"container": mainWindow_StatusWindow, "objectName": "statusToolBar", "type": "StatusToolBar", "visible": True} diff --git a/gui/objects_map/names.py b/gui/objects_map/names.py index f8405f6..59036ad 100644 --- a/gui/objects_map/names.py +++ b/gui/objects_map/names.py @@ -155,6 +155,7 @@ next_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_o communityProfilePopupInviteMessagePanel_MessageInput_TextEdit = {"container": communityProfilePopupInviteMessagePanel, "objectName": "CommunityProfilePopupInviteMessagePanel_MessageInput", "type": "TextEdit", "visible": True} send_1_invite_StatusButton = {"checkable": False, "container": statusDesktop_mainWindow_overlay, "objectName": "InviteFriendsToCommunityPopup_SendButton", "text": "Send 1 invite", "type": "StatusButton", "visible": True} o_StatusMemberListItem_2 = {"container": communityProfilePopupInviteMessagePanel, "type": "StatusMemberListItem", "unnamed": 1, "visible": True} +copy_icon_StatusIcon = {"container": statusDesktop_mainWindow_overlay, "objectName": "copy-icon", "type": "StatusIcon", "visible": True} # Welcome community o_ColumnLayout = {"container": statusDesktop_mainWindow_overlay, "type": "ColumnLayout", "unnamed": 1, "visible": True} diff --git a/scripts/utils/browser.py b/scripts/utils/browser.py new file mode 100644 index 0000000..319f27b --- /dev/null +++ b/scripts/utils/browser.py @@ -0,0 +1,13 @@ +import webbrowser + +import requests + + +def open_link(url): + webbrowser.open(url) + + +def get_response(url): + response = requests.get( + url) + return response diff --git a/tests/communities/test_communities_share_link.py b/tests/communities/test_communities_share_link.py new file mode 100644 index 0000000..6ab655c --- /dev/null +++ b/tests/communities/test_communities_share_link.py @@ -0,0 +1,27 @@ +import allure +import pytest +from allure_commons._allure import step + +import constants +from gui.main_window import MainWindow +from scripts.utils.browser import open_link, get_response +from . import marks + +pytestmark = marks + + +@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/736382', 'Share community link') +@pytest.mark.case(736382) +def test_share_community_link(main_screen: MainWindow): + with step('Enable creation of community option'): + settings = main_screen.left_panel.open_settings() + settings.left_panel.open_advanced_settings().enable_creation_of_communities() + with step('Create community and select it'): + community_params = constants.community_params + main_screen.create_community(community_params['name'], community_params['description'], + community_params['intro'], community_params['outro'], + community_params['logo']['fp'], community_params['banner']['fp']) + with step('Copy community link and verify that it does not give 404 error'): + community_link = main_screen.left_panel.open_community_context_menu( + community_params['name']).select_invite_people().copy_community_link() + assert get_response(community_link).status_code != 404