chore: fix community channel tests in test mode

This commit is contained in:
Anastasiya Semiankevich 2023-12-12 17:05:33 +03:00 committed by Anastasiya
parent bce460abf8
commit 01382bd16e
5 changed files with 46 additions and 21 deletions

View File

@ -34,7 +34,7 @@ class CommunityScreen(QObject):
def create_channel(self, name: str, description: str, emoji: str = None): def create_channel(self, name: str, description: str, emoji: str = None):
self.left_panel.open_create_channel_popup().create(name, description, emoji) self.left_panel.open_create_channel_popup().create(name, description, emoji)
@allure.step('Create channel') @allure.step('Edit channel')
def edit_channel(self, channel, name: str, description: str, emoji: str = None): def edit_channel(self, channel, name: str, description: str, emoji: str = None):
self.left_panel.select_channel(channel) self.left_panel.select_channel(channel)
self.tool_bar.open_edit_channel_popup().edit(name, description, emoji) self.tool_bar.open_edit_channel_popup().edit(name, description, emoji)
@ -218,9 +218,9 @@ class LeftPanel(QObject):
@allure.step('Get channel params') @allure.step('Get channel params')
def get_channel_parameters(self, name) -> UserChannel: def get_channel_parameters(self, name) -> UserChannel:
for channal in self.channels: for channel in self.channels:
if channal.name == name: if channel.name == name:
return channal return channel
raise LookupError(f'Channel not found in {self.channels}') raise LookupError(f'Channel not found in {self.channels}')
@allure.step('Open community settings') @allure.step('Open community settings')
@ -243,10 +243,16 @@ class LeftPanel(QObject):
raise LookupError('Channel not found') raise LookupError('Channel not found')
@allure.step('Open create category popup') @allure.step('Open create category popup')
def open_create_category_popup(self) -> NewCategoryPopup: def open_create_category_popup(self, attempts: int = 2) -> NewCategoryPopup:
self._channel_or_category_button.click() self._channel_or_category_button.click()
self._create_category_menu_item.click() try:
return NewCategoryPopup().wait_until_appears() self._create_category_menu_item.click()
return NewCategoryPopup().wait_until_appears()
except Exception as ex:
if attempts:
self.open_create_category_popup(attempts-1)
else:
raise ex
@allure.step('Open join community popup') @allure.step('Open join community popup')
def open_welcome_community_popup(self): def open_welcome_community_popup(self):

View File

@ -1,3 +1,4 @@
import time
import typing import typing
import allure import allure
@ -86,10 +87,16 @@ class OverviewView(QObject):
return self._description_text_label.text return self._description_text_label.text
@allure.step('Open edit community view') @allure.step('Open edit community view')
def open_edit_community_view(self) -> 'EditCommunityView': def open_edit_community_view(self, attempts: int = 2) -> 'EditCommunityView':
time.sleep(0.5)
self._edit_button.click() self._edit_button.click()
return EditCommunityView().wait_until_appears() try:
return EditCommunityView()
except Exception as ex:
if attempts:
self.open_edit_community_view(attempts-1)
else:
raise ex
class EditCommunityView(QObject): class EditCommunityView(QObject):

View File

@ -39,9 +39,15 @@ class LeftPanel(QObject):
return MessagingSettingsView() return MessagingSettingsView()
@allure.step('Open communities settings') @allure.step('Open communities settings')
def open_communities_settings(self) -> 'CommunitiesSettingsView': def open_communities_settings(self, attempts: int = 2) -> 'CommunitiesSettingsView':
self._open_settings('12-AppMenuItem') self._open_settings('12-AppMenuItem')
return CommunitiesSettingsView() try:
return CommunitiesSettingsView()
except Exception as ex:
if attempts:
self.open_communities_settings(attempts-1)
else:
raise ex
@allure.step('Open wallet settings') @allure.step('Open wallet settings')
def open_wallet_settings(self) -> WalletSettingsView: def open_wallet_settings(self) -> WalletSettingsView:

View File

@ -29,6 +29,7 @@ class CommunitiesSettingsView(QObject):
@property @property
@allure.step('Get communities') @allure.step('Get communities')
def communities(self) -> typing.List[UserCommunityInfo]: def communities(self) -> typing.List[UserCommunityInfo]:
time.sleep(0.5)
_communities = [] _communities = []
for obj in driver.findAllObjects(self._community_item.real_name): for obj in driver.findAllObjects(self._community_item.real_name):
container = driver.objectMap.realName(obj) container = driver.objectMap.realName(obj)

View File

@ -32,10 +32,11 @@ def test_create_community_channel(main_screen: MainWindow, channel_name, channel
[('Channel', 'Description', 'sunglasses', None, '#4360df')]) [('Channel', 'Description', 'sunglasses', None, '#4360df')])
def test_edit_community_channel(main_screen, channel_name, channel_description, channel_emoji, channel_emoji_image, def test_edit_community_channel(main_screen, channel_name, channel_description, channel_emoji, channel_emoji_image,
channel_color): channel_color):
main_screen.create_community(constants.community_params) with step('Create simple community'):
community_screen = CommunityScreen() main_screen.create_community(constants.community_params)
community_screen = main_screen.left_panel.select_community(constants.community_params['name'])
with step('Verify General channel'): with step('Verify General channel is present for recently created community'):
community_screen.verify_channel( community_screen.verify_channel(
'general', 'general',
'General channel for the community', 'General channel for the community',
@ -43,14 +44,15 @@ def test_edit_community_channel(main_screen, channel_name, channel_description,
channel_color channel_color
) )
community_screen.edit_channel('general', channel_name, channel_description, channel_emoji) with step('Edit general channel'):
community_screen.edit_channel('general', channel_name, channel_description, channel_emoji)
with step('Channel is correct in channels list'): with step('Verify edited channel details are correct in channels list'):
channel = community_screen.left_panel.get_channel_parameters(channel_name) channel = community_screen.left_panel.get_channel_parameters(channel_name)
assert channel.name == channel_name assert channel.name == channel_name
assert channel.selected assert channel.selected
with step('Channel is correct in community toolbar'): with step('Verify edited channel details are correct in community toolbar'):
assert community_screen.tool_bar.channel_name == channel_name assert community_screen.tool_bar.channel_name == channel_name
assert community_screen.tool_bar.channel_description == channel_description assert community_screen.tool_bar.channel_description == channel_description
assert community_screen.tool_bar.channel_emoji == '😎 ' assert community_screen.tool_bar.channel_emoji == '😎 '
@ -60,10 +62,13 @@ def test_edit_community_channel(main_screen, channel_name, channel_description,
@allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703051', 'Delete community channel') @allure.testcase('https://ethstatus.testrail.net/index.php?/cases/view/703051', 'Delete community channel')
@pytest.mark.case(703051) @pytest.mark.case(703051)
def test_delete_community_channel(main_screen): def test_delete_community_channel(main_screen):
main_screen.create_community(constants.community_params)
with step('Create simple community'):
main_screen.create_community(constants.community_params)
community_screen = main_screen.left_panel.select_community(constants.community_params['name'])
with step('Delete channel'): with step('Delete channel'):
CommunityScreen().delete_channel('general') community_screen.delete_channel('general')
with step('Verify channel is not exists'): with step('Verify channel is not exists'):
assert not CommunityScreen().left_panel.channels assert not community_screen.left_panel.channels