tests(@e2e): reimplement kick and ban member test

This commit is contained in:
Anastasiya Semiankevich 2024-12-26 20:59:34 +03:00 committed by Anastasiya
parent 72069b066b
commit 751f27498c
10 changed files with 116 additions and 61 deletions

View File

@ -60,6 +60,7 @@ class ToastMessages(Enum):
REMOVED_CONTACT_TOAST = 'Contact removed'
BANNED_USER_TOAST = ' was banned from '
UNBANNED_USER_TOAST = ' unbanned from '
UNBANNED_USER_CONFIRM = 'You were unbanned from '
class LimitWarnings(Enum):

View File

@ -27,7 +27,6 @@ class QObject:
raise LookupError(f"Object {self.real_name} was not found within {configs.timeouts.UI_LOAD_TIMEOUT_MSEC}")
return obj
def set_text_property(self, text):
self.object.forceActiveFocus()
self.object.clear()

View File

@ -32,6 +32,11 @@ channel_name_StatusBaseText = {"container": None, "type": "StatusBaseText", "unn
mainWindow_createChannelOrCategoryBtn_StatusBaseText = {"container": mainWindow_communityColumnView_CommunityColumnView, "objectName": "createChannelOrCategoryBtn", "type": "StatusBaseText", "visible": True}
create_channel_StatusMenuItem = {"container": statusDesktop_mainWindow_overlay, "enabled": True, "objectName": "createCommunityChannelBtn", "type": "StatusMenuItem", "visible": True}
mainWindow_Join_Community_StatusButton = {"checkable": False, "container": mainWindow_StatusWindow, "type": "StatusButton", "unnamed": 1, "visible": True}
# Banned Panel
mainWindow_CommunityBannedMemberPanel = {"container": statusDesktop_mainWindow, "objectName": "communityBannedMemberPanel", "type": "CommunityBannedMemberCenterPanel", "visible": True}
mainWindow_CommunityBannedMemberPanel_UserInfo = {"container": statusDesktop_mainWindow, "objectName": "userInfoPanelBase", "type": "Rectangle", "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}
@ -83,10 +88,10 @@ mainWindow_Edit_Community_StatusButton = {"container": statusDesktop_mainWindow,
# Members Settings View
mainWindow_MembersSettingsPanel = {"container": mainWindow_communityLoader_Loader, "type": "MembersSettingsPanel", "unnamed": 1, "visible": True}
membersListViews_ListView = {"container": mainWindow_MembersSettingsPanel, "objectName": "CommunityMembersTabPanel_MembersListViews", "type": "ListView", "visible": True}
membersListViews_ListView = {"container": statusDesktop_mainWindow, "objectName": "CommunityMembersTabPanel_MembersListViews", "type": "StatusListView", "visible": True}
memberItem_StatusMemberListItem = {"container": membersListViews_ListView, "id": "memberItem", "type": "StatusMemberListItem", "unnamed": 1, "visible": True}
communitySettings_MembersTab_Member_Kick_Button = {"container": membersListViews_ListView, "objectName": "MemberListItem_KickButton", "type": "StatusButton", "visible": True}
memberItem_Ban_StatusButton = {"checkable": False, "container": membersListViews_ListView, "objectName": "MemberListItem_BanButton", "type": "StatusButton", "visible": True}
memberItem_Ban_StatusButton = {"container": membersListViews_ListView, "objectName": "MemberListItem_BanButton", "type": "StatusButton", "visible": True}
memberItem_Unban_StatusButton = {"checkable": False, "container": membersListViews_ListView, "objectName": "MemberListItem_UnbanButton", "type": "StatusButton", "visible": True}
# Tokens View

View File

@ -22,6 +22,7 @@ from gui.elements.text_label import TextLabel
from gui.objects_map import names, communities_names, messaging_names
from gui.screens.community_settings import CommunitySettingsScreen
from scripts.tools.image import Image
from scripts.utils.parsers import remove_tags
class CommunityScreen(QObject):
@ -93,6 +94,21 @@ class CommunityScreen(QObject):
assert category.category_name == category_name
class BannedCommunityScreen(QObject):
def __init__(self):
super().__init__(communities_names.mainWindow_communityLoader_Loader)
self.community_header_button = Button(communities_names.mainWindow_communityHeaderButton_StatusChatInfoButton)
self.community_start_chat_button = Button(messaging_names.mainWindow_startChatButton_StatusIconTabButton)
self.community_banned_member_panel = QObject(communities_names.mainWindow_CommunityBannedMemberPanel)
self.community_banned_member_panel_user_info = QObject(
communities_names.mainWindow_CommunityBannedMemberPanel_UserInfo)
def banned_title(self):
for child in walk_children(self.community_banned_member_panel_user_info.object):
if str(getattr(child, 'objectName', '')) == 'userInfoPanelBaseText':
return remove_tags(str(child.text))
class ToolBar(QObject):
def __init__(self):

View File

@ -272,8 +272,8 @@ class MembersView(QObject):
self._unban_member_button = Button(communities_names.memberItem_Unban_StatusButton)
@property
@allure.step('Get community members')
def members(self) -> typing.List[str]:
@allure.step('Get community members names')
def members_names(self) -> typing.List[str]:
return [str(member.userName) for member in driver.findAllObjects(self._member_list_item.real_name)]
@allure.step('Get community member objects')
@ -300,29 +300,29 @@ class MembersView(QObject):
def kick_member(self, member_name: str):
member = self.get_member_object(member_name)
QObject(real_name=driver.objectMap.realName(member)).hover()
self._kick_member_button.click()
self._kick_member_button.hover()
time.sleep(1)
self._kick_member_button.native_mouse_click()
kick_member_popup = KickMemberPopup()
assert kick_member_popup.exists
kick_member_popup.confirm_kicking()
@allure.step('Ban community member')
def ban_member(self, member_name: str):
member = self.get_member_object(member_name)
QObject(real_name=driver.objectMap.realName(member)).hover()
self._ban_member_button.click()
self._ban_member_button.hover()
time.sleep(1)
self._ban_member_button.native_mouse_click()
return BanMemberPopup().wait_until_appears()
@allure.step('Unban community member')
def unban_member(self, member_name: str, attempt: int = 2):
def unban_member(self, member_name: str):
member = self.get_member_object(member_name)
QObject(real_name=driver.objectMap.realName(member)).hover()
try:
self._unban_member_button.wait_until_appears().click()
except AssertionError as er:
if attempt:
self.unban_member(member_name, attempt-1)
else:
raise er
self._unban_member_button.hover()
time.sleep(1)
self._unban_member_button.native_mouse_click()
return self
class AirdropsView(QObject):

View File

@ -27,7 +27,7 @@ from gui.elements.scroll import Scroll
from gui.elements.text_edit import TextEdit
from gui.elements.text_label import TextLabel
from gui.objects_map import messaging_names, communities_names
from gui.screens.community import CommunityScreen
from gui.screens.community import CommunityScreen, BannedCommunityScreen
from scripts.tools.image import Image
from scripts.utils.parsers import remove_tags
@ -175,6 +175,11 @@ class Message:
self.delegate_button.click()
return CommunityScreen().wait_until_appears()
def open_banned_community_invitation(self):
driver.waitFor(lambda: self.delegate_button.is_visible, configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
self.delegate_button.click()
return BannedCommunityScreen().wait_until_appears()
@allure.step('Hover message')
def hover_message(self):
self.delegate_button.hover()
@ -275,8 +280,17 @@ class ChatView(QObject):
raise LookupError(f'Message not found')
return message
@allure.step('Accept community invitation')
def accept_community_invite(self, community: str, index: int) -> 'CommunityScreen':
@allure.step('Open community invitation')
def click_community_invite(self, community: str, index: int) -> 'CommunityScreen':
message = self.search_for_invitation(community, index)
return message.open_community_invitation()
@allure.step('Open banned community invitation')
def open_banned_community(self, community, index) -> 'BannedCommunityScreen':
message = self.search_for_invitation(community, index)
return message.open_banned_community_invitation()
def search_for_invitation(self, community, index):
message = None
started_at = time.monotonic()
while message is None:
@ -286,8 +300,9 @@ class ChatView(QObject):
break
if time.monotonic() - started_at > 80:
raise LookupError(f'Community invitation was not found')
return message
return message.open_community_invitation()
class CreateChatView(QObject):

View File

@ -7,6 +7,7 @@ from allure_commons._allure import step
import driver
from constants import UserAccount, RandomUser, RandomCommunity, CommunityData
from constants.community import ToastMessages
from driver.objects_access import walk_children
from gui.screens.community import Members
from gui.screens.messages import MessagesScreen
from helpers.SettingsHelper import enable_community_creation
@ -16,11 +17,9 @@ from gui.main_window import MainWindow
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703252', 'Kick user')
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703254', 'Edit chat - Delete any message')
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/736991', 'Owner can ban member')
@pytest.mark.case(703252, 703252, 736991)
@pytest.mark.communities
@pytest.mark.skip(reason='Not possible to get floating buttons on hover for list item')
def test_community_admin_ban_kick_member_and_delete_message(multiple_instances):
user_one: UserAccount = RandomUser()
user_two: UserAccount = RandomUser()
@ -64,7 +63,6 @@ def test_community_admin_ban_kick_member_and_delete_message(multiple_instances):
with step(f'User {user_two.name}, create community and invite {user_one.name}'):
enable_community_creation(main_screen)
main_screen.create_community(community_data=community)
community_screen = main_screen.left_panel.select_community(community.name)
add_members = community_screen.left_panel.open_add_members_popup()
@ -78,7 +76,7 @@ def test_community_admin_ban_kick_member_and_delete_message(multiple_instances):
assert driver.waitFor(lambda: user_two.name in messages_view.left_panel.get_chats_names,
10000)
chat = messages_view.left_panel.click_chat_by_name(user_two.name)
community_screen = chat.accept_community_invite(community.name, 0)
community_screen = chat.click_community_invite(community.name, 0)
with step(f'User {user_one.name}, verify welcome community popup'):
welcome_popup = community_screen.left_panel.open_welcome_community_popup()
@ -87,25 +85,6 @@ def test_community_admin_ban_kick_member_and_delete_message(multiple_instances):
welcome_popup.join().authenticate(user_one.password)
assert driver.waitFor(lambda: not community_screen.left_panel.is_join_community_visible,
10000), 'Join community button not hidden'
messages_screen = MessagesScreen()
message_text = "Hi"
messages_screen.group_chat.send_message_to_group_chat(message_text)
main_screen.hide()
with step(f'User {user_two.name}, delete member message of {user_one.name} and verify it was deleted'):
aut_two.attach()
main_screen.prepare()
community_screen = main_screen.left_panel.select_community(community.name)
messages_screen = MessagesScreen()
message = messages_screen.chat.find_message_by_text(message_text, '0')
message.hover_message().delete_message()
assert messages_screen.chat.get_deleted_message_state
main_screen.hide()
with step(f'User {user_one.name} verify that message was deleted by {user_two.name}'):
aut_one.attach()
main_screen.prepare()
assert driver.waitFor(lambda: messages_screen.chat.get_deleted_message_state, timeout)
main_screen.hide()
with step(f'User {user_two.name}, ban {user_one.name} from the community'):
@ -130,27 +109,53 @@ def test_community_admin_ban_kick_member_and_delete_message(multiple_instances):
with step(f'User {user_two.name}, see {user_one.name} in banned members list'):
community_screen.right_panel.click_banned_button()
assert driver.waitFor(lambda: user_one.name not in members_list, timeout)
with step(f'User {user_two.name}, unban {user_one.name} in banned members list'):
members.unban_member(user_one.name)
time.sleep(2)
with step('Check toast message about unbanned member'):
toast_messages = main_screen.wait_for_notification()
toast_message = user_one.name + ToastMessages.UNBANNED_USER_TOAST.value + community.name
assert driver.waitFor(lambda: toast_message in toast_messages, timeout), \
f"Toast message is incorrect, current message {toast_message} is not in {toast_messages}"
main_screen.hide()
with step(f'User {user_one.name} join community again {user_two.name}'):
with step(f'User {user_one.name} tries to join community when being banned by {user_two.name}'):
aut_one.attach()
main_screen.prepare()
community_screen = chat.accept_community_invite(community.name, 0)
chat = messages_view.left_panel.click_chat_by_name(user_two.name)
banned_community_screen = chat.open_banned_community(community.name, 0)
assert banned_community_screen.community_banned_member_panel.is_visible
assert banned_community_screen.banned_title() == f"You've been banned from {community.name}"
main_screen.left_panel.open_community_context_menu(community.name).leave_community()
assert driver.waitFor(lambda: community.name not in main_screen.left_panel.communities, timeout)
main_screen.hide()
with step(f'User {user_two.name}, unban {user_one.name} in banned members list'):
aut_two.attach()
main_screen.prepare()
members.unban_member(user_one.name)
toast_messages = main_screen.wait_for_notification()
assert len(toast_messages) == 1, \
f"Multiple toast messages appeared"
message = toast_messages[0]
assert message == user_one.name + ToastMessages.UNBANNED_USER_TOAST.value + community.name, \
f"Toast message is incorrect, current message is {message}"
main_screen.hide()
with step(f'User {user_one.name} joins community again'):
aut_one.attach()
main_screen.prepare()
chat1 = messages_view.left_panel.click_chat_by_name(user_two.name)
community_screen = chat1.open_banned_community(community.name, 0)
toast_messages = main_screen.wait_for_notification(timeout_msec=10000)
assert len(toast_messages) == 1, \
f"Multiple toast messages appeared"
message = toast_messages[0]
assert message == ToastMessages.UNBANNED_USER_CONFIRM.value + community.name, \
f"Toast message is incorrect, current message is {message}"
main_screen.left_panel.open_community_context_menu(community.name).leave_community()
messages_view1 = main_screen.left_panel.open_messages_screen()
chat = messages_view1.left_panel.click_chat_by_name(user_two.name)
time.sleep(1)
community_screen = chat.click_community_invite(community.name, 0)
welcome_popup = community_screen.left_panel.open_welcome_community_popup()
welcome_popup.join().authenticate(user_one.password)
assert driver.waitFor(lambda: not community_screen.left_panel.is_join_community_visible,
10000), 'Join community button not hidden'
main_screen.hide()
10000), 'Join community button not hidden'
with step(f'User {user_two.name}, kick {user_one.name} from the community'):
aut_two.attach()
@ -170,7 +175,16 @@ def test_community_admin_ban_kick_member_and_delete_message(multiple_instances):
assert driver.waitFor(lambda: user_one.name not in community_screen.right_panel.members, timeout)
main_screen.hide()
with step(f'User {user_one.name} is not in the community anymore'):
with step(f'User {user_one.name} rejoins community after being kicked'):
aut_one.attach()
main_screen.prepare()
assert driver.waitFor(lambda: community.name not in main_screen.left_panel.communities, timeout)
messages_view = main_screen.left_panel.open_messages_screen()
chat = messages_view.left_panel.click_chat_by_name(user_two.name)
community_screen = chat.click_community_invite(community.name, 0)
welcome_popup = community_screen.left_panel.open_welcome_community_popup()
welcome_popup.join().authenticate(user_one.password)
assert driver.waitFor(lambda: not community_screen.left_panel.is_join_community_visible,
10000), 'Join community button not hidden'

View File

@ -78,7 +78,7 @@ def test_join_community_and_pin_unpin_message(multiple_instances):
main_screen.prepare()
messages_view = main_screen.left_panel.open_messages_screen()
chat = messages_view.left_panel.click_chat_by_name(user_two.name)
chat.accept_community_invite(community.name, 0)
chat.click_community_invite(community.name, 0)
with step(f'User {user_one.name}, verify welcome community popup'):
welcome_popup = community_screen.left_panel.open_welcome_community_popup()

View File

@ -107,7 +107,7 @@ def test_communities_send_accept_decline_request_remove_contact_from_profile(mul
main_screen.prepare()
messages_view = main_screen.left_panel.open_messages_screen()
chat = messages_view.left_panel.click_chat_by_name(user_two.name)
community_screen = chat.accept_community_invite(community.name, 0)
community_screen = chat.click_community_invite(community.name, 0)
with step(f'User {user_three.name}, verify welcome community popup'):
welcome_popup = community_screen.left_panel.open_welcome_community_popup()
@ -123,7 +123,7 @@ def test_communities_send_accept_decline_request_remove_contact_from_profile(mul
main_screen.prepare()
messages_view = main_screen.left_panel.open_messages_screen()
chat = messages_view.left_panel.click_chat_by_name(user_two.name)
community_screen = chat.accept_community_invite(community.name, 0)
community_screen = chat.click_community_invite(community.name, 0)
with step(f'User {user_one.name}, verify welcome community popup'):
welcome_popup = community_screen.left_panel.open_welcome_community_popup()

View File

@ -11,6 +11,8 @@ import StatusQ.Layout 0.1
ColumnLayout {
id: root
objectName: "communityBannedMemberPanel"
property string name
property string chatDateTimeText
property string listUsersText
@ -81,6 +83,8 @@ ColumnLayout {
Rectangle {
id: panelBase
objectName: "userInfoPanelBase"
Layout.fillWidth: true
Layout.fillHeight: true
color: Theme.palette.statusAppLayout.rightPanelBackgroundColor
@ -121,6 +125,7 @@ ColumnLayout {
}
StatusBaseText {
objectName: "userInfoPanelBaseText"
text: qsTr("You've been banned from <b>%1<b>").arg(root.name)
color: Theme.palette.dangerColor1
font.pixelSize: Theme.secondaryAdditionalTextSize