Skip to content
This repository was archived by the owner on Aug 13, 2024. It is now read-only.

Commit 15bcd01

Browse files
committed
chore: replace file dialog interactions with direct function
1 parent c896b6b commit 15bcd01

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

gui/components/community/create_community_popups.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _open_logo_file_dialog(self, attempt: int = 2):
9090
@allure.step('Set community logo')
9191
def logo(self, kwargs: dict):
9292
self._open_logo_file_dialog().open_file(kwargs['fp'])
93-
PictureEditPopup().wait_until_appears().make_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
93+
PictureEditPopup().wait_until_appears().set_zoom_shift_for_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
9494

9595
@property
9696
@allure.step('Get community banner')
@@ -101,7 +101,7 @@ def banner(self):
101101
def banner(self, kwargs: dict):
102102
self._add_banner_button.click()
103103
OpenFileDialog().wait_until_appears().open_file(kwargs['fp'])
104-
PictureEditPopup().wait_until_appears().make_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
104+
PictureEditPopup().wait_until_appears().set_zoom_shift_for_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
105105

106106
@allure.step('Set community logo without file upload dialog')
107107
def set_logo_without_file_upload_dialog(self, path):
@@ -164,9 +164,9 @@ def open_next_form(self):
164164
@allure.step('Create community without file upload dialog usage')
165165
def create_community(self, kwargs):
166166
self.set_logo_without_file_upload_dialog(kwargs['logo']['fp'])
167-
PictureEditPopup().make_picture(None, None)
167+
PictureEditPopup().set_zoom_shift_for_picture(None, None)
168168
self.set_banner_without_file_upload_dialog(kwargs['banner']['fp'])
169-
PictureEditPopup().make_picture(None, None)
169+
PictureEditPopup().set_zoom_shift_for_picture(None, None)
170170
for key in list(kwargs):
171171
if key in ['intro', 'outro'] and self._next_button.is_visible:
172172
self._next_button.click()

gui/components/picture_edit_popup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self):
2323
self._slider_handler = QObject(names.o_DropShadow)
2424

2525
@allure.step('Make picture')
26-
def make_picture(
26+
def set_zoom_shift_for_picture(
2727
self,
2828
zoom: int = None,
2929
shift: shift_image = None

gui/objects_map/names.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@
906906
mainWindow_EmojiHash = {"container": statusDesktop_mainWindow, "objectName": "publicKeyEmojiHash", "type": "EmojiHash", "visible": True}
907907
mainWindow_Header_Title = {"container": statusDesktop_mainWindow, "objectName": "onboardingHeaderText", "type": "StyledText", "visible": True}
908908
mainWindow_userImageCopy_StatusSmartIdenticon = {"container": mainWindow_InsertDetailsView, "id": "userImageCopy", "type": "StatusSmartIdenticon", "unnamed": 1, "visible": True}
909-
909+
profileImageCropper = {"container": statusDesktop_mainWindow, "objectName": "imageCropWorkflow", "type": "ImageCropWorkflow", "visible": True}
910910

911911
# Create Password View
912912
mainWindow_CreatePasswordView = {"container": statusDesktop_mainWindow, "type": "CreatePasswordView", "unnamed": 1, "visible": True}

gui/screens/community_settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def logo(self) -> Image:
152152
def logo(self, kwargs: dict):
153153
self._add_logo_button.click()
154154
OpenFileDialog().wait_until_appears().open_file(kwargs['fp'])
155-
PictureEditPopup().wait_until_appears().make_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
155+
PictureEditPopup().wait_until_appears().set_zoom_shift_for_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
156156

157157
@property
158158
@allure.step('Get community banner')
@@ -163,7 +163,7 @@ def banner(self) -> Image:
163163
def banner(self, kwargs: dict):
164164
self._add_banner_button.click()
165165
OpenFileDialog().wait_until_appears().open_file(kwargs['fp'])
166-
PictureEditPopup().wait_until_appears().make_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
166+
PictureEditPopup().wait_until_appears().set_zoom_shift_for_picture(kwargs.get('zoom', None), kwargs.get('shift', None))
167167

168168
@allure.step('Set community logo without file upload dialog')
169169
def set_logo_without_file_upload_dialog(self, path):
@@ -233,9 +233,9 @@ def pin_message_checkbox_state(self) -> bool:
233233
@allure.step('Edit community')
234234
def edit(self, kwargs):
235235
self.set_logo_without_file_upload_dialog(kwargs['logo']['fp'])
236-
PictureEditPopup().make_picture(None, None)
236+
PictureEditPopup().set_zoom_shift_for_picture(None, None)
237237
self.set_banner_without_file_upload_dialog(kwargs['banner']['fp'])
238-
PictureEditPopup().make_picture(None, None)
238+
PictureEditPopup().set_zoom_shift_for_picture(None, None)
239239
for key in list(kwargs):
240240
setattr(self, key, kwargs.get(key))
241241
self._save_changes_button.click()

gui/screens/onboarding.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ def __init__(self):
268268
self._clear_icon = QObject(names.mainWindow_clear_icon_StatusIcon)
269269
self._identicon_ring = QObject(names.mainWindow_IdenticonRing)
270270
self._view_header_title = TextLabel(names.mainWindow_Header_Title)
271+
self._image_crop_workflow = QObject(names.profileImageCropper)
271272

272273
def verify_profile_view_present(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
273274
driver.waitFor(lambda: self._view_header_title.exists, timeout_msec)
@@ -311,6 +312,12 @@ def clear_field(self):
311312
self._clear_icon.click()
312313
return self
313314

315+
@allure.step('Set profile picture without file upload dialog')
316+
def set_profile_picture(self, path):
317+
image_cropper = driver.waitForObjectExists(self._image_crop_workflow.real_name)
318+
image_cropper.cropImage(('file://' + str(path)))
319+
return PictureEditPopup()
320+
314321
@allure.step('Set user image')
315322
def set_user_image(self, fp: SystemPath) -> PictureEditPopup:
316323
allure.attach(name='User image', body=fp.read_bytes(), attachment_type=allure.attachment_type.PNG)

tests/onboarding/test_onboarding_generate_new_keys.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import configs.timeouts
1111
from gui.components.onboarding.before_started_popup import BeforeStartedPopUp
1212
from gui.components.onboarding.beta_consent_popup import BetaConsentPopup
13-
from gui.components.picture_edit_popup import shift_image
13+
from gui.components.picture_edit_popup import shift_image, PictureEditPopup
1414
from gui.components.splash_screen import SplashScreen
1515
from gui.screens.onboarding import AllowNotificationsView, WelcomeToStatusView, BiometricsView, KeysView
1616

@@ -59,9 +59,8 @@ def test_generate_new_keys(main_window, keys_screen, user_name: str, password, u
5959
f'Error message {profile_view.get_error_message} is present when it should not'
6060

6161
with step('Click plus button and add user picture'):
62-
if user_image is not None:
63-
profile_picture_popup = profile_view.set_user_image(configs.testpath.TEST_IMAGES / user_image)
64-
profile_picture_popup.make_picture(zoom=zoom, shift=shift)
62+
profile_view.set_profile_picture(configs.testpath.TEST_IMAGES / user_image)
63+
PictureEditPopup().set_zoom_shift_for_picture(zoom=zoom, shift=shift)
6564
# TODO: find a way to verify the picture is there (changed to the custom one)
6665
assert profile_view.get_profile_image is not None, f'Profile picture was not set / applied'
6766
assert profile_view.is_identicon_ring_visible, f'Identicon ring is not present when it should'

0 commit comments

Comments
 (0)