2024-07-30 14:48:39 +00:00
|
|
|
import time
|
2024-04-08 05:25:17 +00:00
|
|
|
from copy import deepcopy
|
|
|
|
from datetime import datetime
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
import allure
|
|
|
|
import pytest
|
|
|
|
from allure_commons._allure import step
|
2024-02-19 07:18:46 +00:00
|
|
|
|
|
|
|
import driver
|
2024-04-08 05:25:17 +00:00
|
|
|
from constants import ColorCodes, UserAccount
|
|
|
|
from constants.community_settings import ToastMessages
|
2024-07-30 14:48:39 +00:00
|
|
|
from gui.screens.community import Members
|
2024-04-08 05:25:17 +00:00
|
|
|
from gui.screens.messages import MessagesScreen
|
2023-12-07 16:47:34 +00:00
|
|
|
from . import marks
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
import configs.testpath
|
2023-09-11 18:24:13 +00:00
|
|
|
import constants
|
2023-08-29 14:43:00 +00:00
|
|
|
from gui.main_window import MainWindow
|
|
|
|
|
2023-12-07 16:47:34 +00:00
|
|
|
pytestmark = marks
|
2023-08-29 14:43:00 +00:00
|
|
|
|
2023-12-13 16:16:35 +00:00
|
|
|
|
2024-02-19 07:18:46 +00:00
|
|
|
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703630', 'Create community')
|
|
|
|
@pytest.mark.case(703630)
|
2023-09-11 18:24:13 +00:00
|
|
|
@pytest.mark.parametrize('params', [constants.community_params])
|
2023-09-04 18:36:48 +00:00
|
|
|
def test_create_community(user_account, main_screen: MainWindow, params):
|
2024-05-02 15:04:06 +00:00
|
|
|
with step('Enable creation of community option'):
|
|
|
|
settings = main_screen.left_panel.open_settings()
|
|
|
|
settings.left_panel.open_advanced_settings().enable_creation_of_communities()
|
|
|
|
|
2024-02-19 07:18:46 +00:00
|
|
|
with step('Open create community popup'):
|
2023-08-29 14:43:00 +00:00
|
|
|
communities_portal = main_screen.left_panel.open_communities_portal()
|
|
|
|
create_community_form = communities_portal.open_create_community_popup()
|
2024-02-19 07:18:46 +00:00
|
|
|
|
2024-05-02 15:04:06 +00:00
|
|
|
with step('Verify next button is disabled'):
|
|
|
|
assert not driver.waitFor(lambda: create_community_form.is_next_button_enabled(),
|
|
|
|
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), 'Next button is enabled'
|
2024-02-19 07:18:46 +00:00
|
|
|
|
2024-05-02 15:04:06 +00:00
|
|
|
with step('Verify fields of create community popup and create community'):
|
|
|
|
color = ColorCodes.ORANGE.value
|
2024-02-19 07:18:46 +00:00
|
|
|
community_screen = create_community_form.create_community(params['name'], params['description'],
|
|
|
|
params['intro'], params['outro'],
|
2024-05-02 15:04:06 +00:00
|
|
|
params['logo']['fp'], params['banner']['fp'], color,
|
|
|
|
['Activism', 'Art'], constants.community_tags[:2])
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
with step('Verify community parameters in community overview'):
|
|
|
|
with step('Name is correct'):
|
2023-09-04 18:36:48 +00:00
|
|
|
assert community_screen.left_panel.name == params['name']
|
2023-08-29 14:43:00 +00:00
|
|
|
with step('Members count is correct'):
|
|
|
|
assert '1' in community_screen.left_panel.members
|
|
|
|
|
2024-02-19 07:18:46 +00:00
|
|
|
with step('Verify General channel is present for recently created community'):
|
|
|
|
community_screen.verify_channel(
|
|
|
|
'general',
|
|
|
|
'General channel for the community',
|
2024-04-30 12:49:18 +00:00
|
|
|
None
|
2024-02-19 07:18:46 +00:00
|
|
|
)
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
with step('Verify community parameters in community settings view'):
|
|
|
|
community_setting = community_screen.left_panel.open_community_settings()
|
|
|
|
overview_setting = community_setting.left_panel.open_overview()
|
|
|
|
with step('Name is correct'):
|
2023-09-04 18:36:48 +00:00
|
|
|
assert overview_setting.name == params['name']
|
2023-08-29 14:43:00 +00:00
|
|
|
with step('Description is correct'):
|
2023-09-04 18:36:48 +00:00
|
|
|
assert overview_setting.description == params['description']
|
2023-08-29 14:43:00 +00:00
|
|
|
with step('Members count is correct'):
|
|
|
|
members_settings = community_setting.left_panel.open_members()
|
|
|
|
assert user_account.name in members_settings.members
|
|
|
|
|
|
|
|
with step('Verify community parameters in community settings screen'):
|
|
|
|
settings_screen = main_screen.left_panel.open_settings()
|
2023-09-11 18:24:13 +00:00
|
|
|
community_settings = settings_screen.left_panel.open_communities_settings()
|
2023-09-04 18:36:48 +00:00
|
|
|
community = community_settings.get_community_info(params['name'])
|
|
|
|
assert community.name == params['name']
|
|
|
|
assert community.description == params['description']
|
2023-12-13 16:16:35 +00:00
|
|
|
assert '1' in community.members
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703057', 'Edit community')
|
|
|
|
@pytest.mark.case(703057)
|
2024-05-02 06:11:45 +00:00
|
|
|
# @pytest.mark.critical TODO: fix creation of community https://github.com/status-im/desktop-qa-automation/issues/658
|
2023-09-04 18:36:48 +00:00
|
|
|
@pytest.mark.parametrize('params', [
|
2023-10-09 17:04:29 +00:00
|
|
|
{
|
|
|
|
'name': 'Updated Name',
|
|
|
|
'description': 'Updated Description',
|
|
|
|
'logo': {'fp': configs.testpath.TEST_FILES / 'banner.png', 'zoom': None, 'shift': None},
|
|
|
|
'banner': {'fp': configs.testpath.TEST_FILES / 'tv_signal.png', 'zoom': None, 'shift': None},
|
|
|
|
'color': '#ff7d46',
|
|
|
|
'tags': ['Ethereum'],
|
|
|
|
'intro': 'Updated Intro',
|
|
|
|
'outro': 'Updated Outro'
|
|
|
|
}
|
2023-09-04 18:36:48 +00:00
|
|
|
])
|
2023-09-11 18:24:13 +00:00
|
|
|
def test_edit_community(main_screen: MainWindow, params):
|
2024-05-03 09:36:51 +00:00
|
|
|
with step('Enable creation of community option'):
|
|
|
|
settings = main_screen.left_panel.open_settings()
|
|
|
|
settings.left_panel.open_advanced_settings().enable_creation_of_communities()
|
2024-02-19 13:27:54 +00:00
|
|
|
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'])
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
with step('Edit community'):
|
2024-02-19 13:27:54 +00:00
|
|
|
community_screen = main_screen.left_panel.select_community(community_params['name'])
|
2023-08-29 14:43:00 +00:00
|
|
|
community_setting = community_screen.left_panel.open_community_settings()
|
|
|
|
edit_community_form = community_setting.left_panel.open_overview().open_edit_community_view()
|
2024-02-19 07:18:46 +00:00
|
|
|
edit_community_form.edit(params['name'], params['description'],
|
|
|
|
params['intro'], params['outro'],
|
|
|
|
params['logo']['fp'], params['banner']['fp'])
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
with step('Verify community parameters on settings overview'):
|
|
|
|
overview_setting = community_setting.left_panel.open_overview()
|
|
|
|
with step('Name is correct'):
|
2023-09-04 18:36:48 +00:00
|
|
|
assert overview_setting.name == params['name']
|
2023-08-29 14:43:00 +00:00
|
|
|
with step('Description is correct'):
|
2023-09-04 18:36:48 +00:00
|
|
|
assert overview_setting.description == params['description']
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
with step('Verify community parameters in community screen'):
|
|
|
|
community_setting.left_panel.back_to_community()
|
|
|
|
with step('Name is correct'):
|
2023-09-04 18:36:48 +00:00
|
|
|
assert community_screen.left_panel.name == params['name']
|
2023-08-29 14:43:00 +00:00
|
|
|
|
|
|
|
with step('Verify community parameters in community settings screen'):
|
|
|
|
settings_screen = main_screen.left_panel.open_settings()
|
2023-09-11 18:24:13 +00:00
|
|
|
community_settings = settings_screen.left_panel.open_communities_settings()
|
2023-09-04 18:36:48 +00:00
|
|
|
community_info = community_settings.communities[0]
|
|
|
|
assert community_info.name == params['name']
|
|
|
|
assert community_info.description == params['description']
|
2024-01-19 19:51:06 +00:00
|
|
|
assert '1' in community_info.members
|
2024-04-08 05:25:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
@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')
|
2024-07-30 14:48:39 +00:00
|
|
|
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/736991', 'Owner can ban member')
|
|
|
|
@pytest.mark.case(703252, 703252, 736991)
|
|
|
|
@pytest.mark.parametrize('user_data_one, user_data_two', [
|
|
|
|
(configs.testpath.TEST_USER_DATA / 'group_chat_user_2', configs.testpath.TEST_USER_DATA / 'group_chat_user_1')
|
|
|
|
])
|
|
|
|
def test_community_admin_ban_kick_member_and_delete_message(multiple_instances, user_data_one, user_data_two):
|
|
|
|
user_one: UserAccount = constants.group_chat_user_2
|
|
|
|
user_two: UserAccount = constants.group_chat_user_1
|
|
|
|
timeout = configs.timeouts.UI_LOAD_TIMEOUT_MSEC
|
2024-04-08 05:25:17 +00:00
|
|
|
community_params = deepcopy(constants.community_params)
|
|
|
|
community_params['name'] = f'{datetime.now():%d%m%Y_%H%M%S}'
|
|
|
|
main_screen = MainWindow()
|
|
|
|
|
2024-07-30 14:48:39 +00:00
|
|
|
with multiple_instances(user_data=user_data_one) as aut_one, multiple_instances(user_data=user_data_two) as aut_two:
|
2024-04-08 05:25:17 +00:00
|
|
|
with step(f'Launch multiple instances with authorized users {user_one.name} and {user_two.name}'):
|
|
|
|
for aut, account in zip([aut_one, aut_two], [user_one, user_two]):
|
|
|
|
aut.attach()
|
|
|
|
main_screen.wait_until_appears(configs.timeouts.APP_LOAD_TIMEOUT_MSEC).prepare()
|
|
|
|
main_screen.authorize_user(account)
|
|
|
|
main_screen.hide()
|
|
|
|
|
2024-07-30 14:48:39 +00:00
|
|
|
with step(f'User {user_two.name}, create community and invite {user_one.name}'):
|
2024-04-08 05:25:17 +00:00
|
|
|
aut_two.attach()
|
|
|
|
main_screen.prepare()
|
|
|
|
settings = main_screen.left_panel.open_settings()
|
2024-07-30 14:48:39 +00:00
|
|
|
settings.left_panel.open_advanced_settings().enable_creation_of_communities()
|
2024-05-03 09:36:51 +00:00
|
|
|
|
2024-06-20 10:18:10 +00:00
|
|
|
community = main_screen.create_community(community_params['name'], community_params['description'],
|
|
|
|
community_params['intro'], community_params['outro'],
|
|
|
|
community_params['logo']['fp'], community_params['banner']['fp'])
|
|
|
|
community.left_panel.invite_people_to_community([user_one.name], 'Message')
|
2024-04-08 05:25:17 +00:00
|
|
|
main_screen.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_one.name}, accept invitation from {user_two.name}'):
|
|
|
|
aut_one.attach()
|
|
|
|
main_screen.prepare()
|
|
|
|
messages_view = main_screen.left_panel.open_messages_screen()
|
2024-07-01 06:08:27 +00:00
|
|
|
assert driver.waitFor(lambda: user_two.name in messages_view.left_panel.get_chats_names,
|
2024-07-30 14:48:39 +00:00
|
|
|
10000)
|
2024-04-08 05:25:17 +00:00
|
|
|
chat = messages_view.left_panel.click_chat_by_name(user_two.name)
|
2024-07-30 14:48:39 +00:00
|
|
|
community_screen = chat.accept_community_invite(community_params['name'], 0)
|
2024-04-08 05:25:17 +00:00
|
|
|
|
|
|
|
with step(f'User {user_one.name}, verify welcome community popup'):
|
|
|
|
welcome_popup = community_screen.left_panel.open_welcome_community_popup()
|
|
|
|
assert community_params['name'] in welcome_popup.title
|
|
|
|
assert community_params['intro'] == welcome_popup.intro
|
|
|
|
welcome_popup.join().authenticate(user_one.password)
|
|
|
|
assert driver.waitFor(lambda: not community_screen.left_panel.is_join_community_visible,
|
2024-07-30 14:48:39 +00:00
|
|
|
10000), 'Join community button not hidden'
|
2024-04-08 05:25:17 +00:00
|
|
|
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_params['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()
|
2024-07-30 14:48:39 +00:00
|
|
|
assert driver.waitFor(lambda: messages_screen.chat.get_deleted_message_state, timeout)
|
2024-04-08 05:25:17 +00:00
|
|
|
main_screen.hide()
|
|
|
|
|
2024-07-30 14:48:39 +00:00
|
|
|
with step(f'User {user_two.name}, ban {user_one.name} from the community'):
|
2024-04-08 05:25:17 +00:00
|
|
|
aut_two.attach()
|
|
|
|
main_screen.prepare()
|
|
|
|
community_setting = community_screen.left_panel.open_community_settings()
|
2024-07-30 14:48:39 +00:00
|
|
|
members = community_setting.left_panel.open_members()
|
|
|
|
members.ban_member(user_one.name).confirm_banning()
|
|
|
|
|
|
|
|
with step('Check toast message about banned member'):
|
|
|
|
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.BANNED_USER_TOAST.value + community_params['name'], \
|
|
|
|
f"Toast message is incorrect, current message is {message}"
|
|
|
|
|
|
|
|
with step(f'User {user_two.name}, does not see {user_one.name} in members list'):
|
|
|
|
members_list = community_screen.right_panel.members
|
|
|
|
assert driver.waitFor(lambda: user_one.name not in members_list, timeout)
|
|
|
|
|
|
|
|
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_params['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}'):
|
|
|
|
aut_one.attach()
|
|
|
|
main_screen.prepare()
|
|
|
|
community_screen = chat.accept_community_invite(community_params['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()
|
|
|
|
|
|
|
|
|
|
|
|
with step(f'User {user_two.name}, kick {user_one.name} from the community'):
|
|
|
|
aut_two.attach()
|
|
|
|
main_screen.prepare()
|
|
|
|
Members().click_all_members_button()
|
|
|
|
members.kick_member(user_one.name)
|
2024-04-08 05:25:17 +00:00
|
|
|
|
|
|
|
with step('Check toast message about kicked member'):
|
|
|
|
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.KICKED_USER_TOAST.value + community_params['name'], \
|
|
|
|
f"Toast message is incorrect, current message is {message}"
|
|
|
|
|
|
|
|
with step(f'User {user_two.name}, does not see {user_one.name} in members list'):
|
2024-07-30 14:48:39 +00:00
|
|
|
assert driver.waitFor(lambda: user_one.name not in community_screen.right_panel.members, timeout)
|
2024-04-08 05:25:17 +00:00
|
|
|
main_screen.hide()
|
|
|
|
|
|
|
|
with step(f'User {user_one.name} is not in the community anymore'):
|
|
|
|
aut_one.attach()
|
|
|
|
main_screen.prepare()
|
2024-07-30 14:48:39 +00:00
|
|
|
assert driver.waitFor(lambda: community_params['name'] not in main_screen.left_panel.communities, timeout)
|