chore: do not use file upload dialog for community creation and edit

This commit is contained in:
Anastasiya Semenkevich 2024-02-13 15:47:11 +03:00 committed by Anastasiya
parent 47e835e266
commit 47f8297d87
10 changed files with 47 additions and 14 deletions

View File

@ -27,8 +27,8 @@ community_params = {
string.digits, k=30)),
'description': ''.join(random.choices(string.ascii_letters +
string.digits, k=140)),
'logo': {'fp': configs.testpath.TEST_FILES / 'tv_signal.png', 'zoom': None, 'shift': None},
'banner': {'fp': configs.testpath.TEST_FILES / 'banner.png', 'zoom': None, 'shift': None},
'logo': {'fp': configs.testpath.TEST_IMAGES / 'comm_logo.jpeg', 'zoom': None, 'shift': None},
'banner': {'fp': configs.testpath.TEST_IMAGES / 'comm_banner.jpeg', 'zoom': None, 'shift': None},
'intro': ''.join(random.choices(string.ascii_letters +
string.digits, k=200)),
'outro': ''.join(random.choices(string.ascii_letters +

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -10,6 +10,7 @@ from gui.components.os.open_file_dialogs import OpenFileDialog
from gui.components.picture_edit_popup import PictureEditPopup
from gui.elements.button import Button
from gui.elements.check_box import CheckBox
from gui.elements.object import QObject
from gui.elements.scroll import Scroll
from gui.elements.text_edit import TextEdit
from gui.screens.community import CommunityScreen
@ -46,6 +47,8 @@ class CreateCommunityPopup(BasePopup):
self._intro_text_edit = TextEdit('createCommunityIntroMessageInput_TextEdit')
self._outro_text_edit = TextEdit('createCommunityOutroMessageInput_TextEdit')
self._create_community_button = Button('createCommunityFinalBtn_StatusButton')
self._cropped_image_logo_item = QObject('croppedImageLogo')
self._cropped_image_banner_item = QObject('croppedImageBanner')
@property
@allure.step('Get community name')
@ -83,7 +86,6 @@ class CreateCommunityPopup(BasePopup):
else:
raise err
@logo.setter
@allure.step('Set community logo')
def logo(self, kwargs: dict):
self._open_logo_file_dialog().open_file(kwargs['fp'])
@ -94,13 +96,22 @@ class CreateCommunityPopup(BasePopup):
def banner(self):
raise NotImplementedError
@banner.setter
@allure.step('Set community banner')
def banner(self, kwargs: dict):
self._add_banner_button.click()
OpenFileDialog().wait_until_appears().open_file(kwargs['fp'])
PictureEditPopup().wait_until_appears().make_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
@allure.step('Set community logo without file upload dialog')
def set_logo_without_file_upload_dialog(self, path):
self._cropped_image_logo_item.object.cropImage('file://' + str(path))
return PictureEditPopup()
@allure.step('Set community banner without file upload dialog')
def set_banner_without_file_upload_dialog(self, path):
self._cropped_image_banner_item.object.cropImage('file://' + str(path))
return PictureEditPopup()
@property
@allure.step('Get community color')
def color(self):
@ -149,8 +160,12 @@ class CreateCommunityPopup(BasePopup):
def open_next_form(self):
self._next_button.click()
@allure.step('Create community')
def create(self, kwargs):
@allure.step('Create community without file upload dialog usage')
def create_community(self, kwargs):
self.set_logo_without_file_upload_dialog(kwargs['logo']['fp'])
PictureEditPopup().make_picture(None, None)
self.set_banner_without_file_upload_dialog(kwargs['banner']['fp'])
PictureEditPopup().make_picture(None, None)
for key in list(kwargs):
if key in ['intro', 'outro'] and self._next_button.is_visible:
self._next_button.click()

View File

@ -210,7 +210,7 @@ class MainWindow(Window):
def create_community(self, params: dict) -> CommunityScreen:
communities_portal = self.left_panel.open_communities_portal()
create_community_form = communities_portal.open_create_community_popup()
app_screen = create_community_form.create(params)
app_screen = create_community_form.create_community(params)
return app_screen
@allure.step('Wait for notification and get text')

View File

@ -153,6 +153,8 @@ communityEditPanelScrollView_pinMessagesToggle_StatusCheckBox = {"checkable": Tr
communityEditPanelScrollView_editCommunityIntroInput_TextEdit = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCommunityIntroInput", "type": "TextEdit", "visible": True}
communityEditPanelScrollView_editCommunityOutroInput_TextEdit = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCommunityOutroInput", "type": "TextEdit", "visible": True}
mainWindow_Save_changes_StatusButton = {"container": statusDesktop_mainWindow, "objectName": "settingsDirtyToastMessageSaveButton", "type": "DisabledTooltipButton", "visible": True}
croppedImageEditLogo = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCroppedImageItem_Community logo", "type": "EditCroppedImagePanel", "visible": True}
croppedImageEditBanner = {"container": mainWindow_communityEditPanelScrollView_EditSettingsPanel, "objectName": "editCroppedImageItem_Community banner", "type": "EditCroppedImagePanel", "visible": True}
# User List Panel
mainWindow_UserListPanel = {"container": statusDesktop_mainWindow, "type": "UserListPanel", "unnamed": 1, "visible": True}

View File

@ -94,6 +94,8 @@ createCommunityIntroMessageInput_TextEdit = {"container": statusDesktop_mainWind
createCommunityOutroMessageInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createCommunityOutroMessageInput", "type": "TextEdit", "visible": True}
createCommunityFinalBtn_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "createCommunityFinalBtn", "type": "StatusButton", "visible": True}
createOrEditCommunityCategoryChannelList_StatusListView = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityCategoryChannelList", "type": "StatusListView", "visible": True}
croppedImageLogo = {"container": statusDesktop_mainWindow_overlay, "objectName": "editCroppedImageItem_Community logo", "type": "EditCroppedImagePanel", "visible": True}
croppedImageBanner = {"container": statusDesktop_mainWindow_overlay, "objectName": "editCroppedImageItem_Community banner", "type": "EditCroppedImagePanel", "visible": True}
# Community Channel Popup
createOrEditCommunityChannelNameInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "createOrEditCommunityChannelNameInput", "type": "TextEdit", "visible": True}

View File

@ -119,6 +119,8 @@ class EditCommunityView(QObject):
self._intro_text_edit = TextEdit('communityEditPanelScrollView_editCommunityIntroInput_TextEdit')
self._outro_text_edit = TextEdit('communityEditPanelScrollView_editCommunityOutroInput_TextEdit')
self._save_changes_button = Button('mainWindow_Save_changes_StatusButton')
self._cropped_image_edit_logo_item = QObject('croppedImageEditLogo')
self._cropped_image_edit_banner_item = QObject('croppedImageEditBanner')
@property
@allure.step('Get community name')
@ -145,8 +147,7 @@ class EditCommunityView(QObject):
def logo(self) -> Image:
return self._logo.image
@logo.setter
@allure.step('Set community description')
@allure.step('Set community logo')
def logo(self, kwargs: dict):
self._add_logo_button.click()
OpenFileDialog().wait_until_appears().open_file(kwargs['fp'])
@ -157,13 +158,22 @@ class EditCommunityView(QObject):
def banner(self) -> Image:
return self._banner.image
@banner.setter
@allure.step('Set community description')
@allure.step('Set community banner')
def banner(self, kwargs: dict):
self._add_banner_button.click()
OpenFileDialog().wait_until_appears().open_file(kwargs['fp'])
PictureEditPopup().wait_until_appears().make_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
@allure.step('Set community logo without file upload dialog')
def set_logo_without_file_upload_dialog(self, path):
self._cropped_image_edit_logo_item.object.cropImage('file://' + str(path))
return PictureEditPopup()
@allure.step('Set community banner without file upload dialog')
def set_banner_without_file_upload_dialog(self, path):
self._cropped_image_edit_banner_item.object.cropImage('file://' + str(path))
return PictureEditPopup()
@property
@allure.step('Get community color')
def color(self) -> str:
@ -221,6 +231,10 @@ class EditCommunityView(QObject):
@allure.step('Edit community')
def edit(self, kwargs):
self.set_logo_without_file_upload_dialog(kwargs['logo']['fp'])
PictureEditPopup().make_picture(None, None)
self.set_banner_without_file_upload_dialog(kwargs['banner']['fp'])
PictureEditPopup().make_picture(None, None)
for key in list(kwargs):
setattr(self, key, kwargs.get(key))
self._save_changes_button.click()

View File

@ -271,7 +271,7 @@ class YourProfileView(OnboardingView):
def verify_profile_view_present(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
driver.waitFor(lambda: self._view_header_title.exists, timeout_msec)
assert (getattr(self._view_header_title.object, 'text') ==
OnboardingScreensHeaders.YOUR_PROFILE_SCREEN_TITLE.value) , \
OnboardingScreensHeaders.YOUR_PROFILE_SCREEN_TITLE.value), \
f"YourProfileView is not shown or has wrong title, \
current screen title is {getattr(self._view_header_title.object, 'text')}"
return self
@ -350,7 +350,7 @@ class YourEmojihashAndIdenticonRingView(OnboardingView):
def verify_emojihash_view_present(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
driver.waitFor(lambda: self._view_header_title.exists, timeout_msec)
assert (getattr(self._view_header_title.object, 'text') ==
OnboardingScreensHeaders.YOUR_EMOJIHASH_AND_IDENTICON_RING_SCREEN_TITLE.value) , \
OnboardingScreensHeaders.YOUR_EMOJIHASH_AND_IDENTICON_RING_SCREEN_TITLE.value), \
f"YourEmojihashAndIdenticonRingView is not shown or has wrong title, \
current screen title is {getattr(self._view_header_title.object, 'text')}"
return self

View File

@ -20,7 +20,7 @@ def test_create_community(user_account, main_screen: MainWindow, params):
with step('Create community'):
communities_portal = main_screen.left_panel.open_communities_portal()
create_community_form = communities_portal.open_create_community_popup()
community_screen = create_community_form.create(params)
community_screen = create_community_form.create_community(params)
with step('Verify community parameters in community overview'):
with step('Name is correct'):