From 0da0360bebd28b232d6d5f457f251577ebda4355 Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Wed, 30 Nov 2022 10:20:25 +0100 Subject: [PATCH] fix(@desktop/tests): Fixing gif and image unfirling scenarios Fix #7912 --- test/ui-test/src/drivers/SquishDriver.py | 4 ++++ test/ui-test/src/screens/SettingsScreen.py | 23 ++++++++++++------- .../src/screens/StatusAccountsScreen.py | 2 +- test/ui-test/src/screens/StatusChatScreen.py | 21 +++++------------ test/ui-test/src/utils/ObjectAccess.py | 4 ++-- .../global_shared/scripts/settings_names.py | 1 + .../global_shared/steps/settingsSteps.py | 19 +++++++-------- .../suite_messaging/shared/steps/chatSteps.py | 2 +- .../suite_messaging/tst_ChatFlow/test.feature | 14 +++++------ .../Profile/views/MessagingView.qml | 1 + 10 files changed, 47 insertions(+), 44 deletions(-) diff --git a/test/ui-test/src/drivers/SquishDriver.py b/test/ui-test/src/drivers/SquishDriver.py index 9daefc35ef..eabaa946da 100755 --- a/test/ui-test/src/drivers/SquishDriver.py +++ b/test/ui-test/src/drivers/SquishDriver.py @@ -172,6 +172,10 @@ def scroll_obj_by_name(objName: str): obj = squish.waitForObject(getattr(names, objName)) squish.mouseWheel(obj, 206, 35, 0, -1, squish.Qt.ControlModifier) +def reset_scroll_obj_by_name(objName: str): + obj = squish.waitForObject(getattr(names, objName)) + obj.contentY = 0 + # execute do_fn until validation_fn returns True or timeout is reached def do_until_validation_with_timeout(do_fn, validation_fn, message: str, timeout_ms: int=_MAX_WAIT_OBJ_TIMEOUT * 2): start_time = time.time() diff --git a/test/ui-test/src/screens/SettingsScreen.py b/test/ui-test/src/screens/SettingsScreen.py index ff5dd44330..5dd5fc270d 100644 --- a/test/ui-test/src/screens/SettingsScreen.py +++ b/test/ui-test/src/screens/SettingsScreen.py @@ -16,6 +16,7 @@ import string from wsgiref import validate from drivers.SquishDriver import * from drivers.SquishDriverVerification import * +from utils.ObjectAccess import * from .StatusMainScreen import MainScreenComponents from .StatusMainScreen import StatusMainScreen @@ -48,6 +49,7 @@ class ENSScreen(Enum): class MessagingOptionScreen(Enum): ACTIVATE_OR_DEACTIVATE_LINK_PREVIEW: str = "displayMessageLinkPreviewItem" + LINK_PREVIEW_SWITCH: str = "linkPreviewSwitch" ACTIVATE_OR_DECTIVATE_IMAGE_UNFURLING: str = "imageUnfurlingItem" TENOR_GIFS_PREVIEW_SWITCH_ITEM: str = "tenorGifsPreviewSwitchItem" SCROLLVIEW: str = "settingsContentBase_ScrollView" @@ -160,21 +162,26 @@ class SettingsScreen: def open_messaging_settings(self): click_obj_by_name(SidebarComponents.MESSAGING_ITEM.value) - def activate_link_preview(self): + # if link preview is activated do nothing + def activate_link_preview_if_dectivated(self): click_obj_by_name(SidebarComponents.MESSAGING_ITEM.value) - scroll_item_until_item_is_visible(MessagingOptionScreen.SCROLLVIEW.value, MessagingOptionScreen.ACTIVATE_OR_DEACTIVATE_LINK_PREVIEW.value) - click_obj_by_name(MessagingOptionScreen.ACTIVATE_OR_DEACTIVATE_LINK_PREVIEW.value) + # view can be scrolled down, we need to reset scroll + reset_scroll_obj_by_name(MessagingOptionScreen.SCROLLVIEW.value) + scroll_item_until_item_is_visible(MessagingOptionScreen.SCROLLVIEW.value, MessagingOptionScreen.LINK_PREVIEW_SWITCH.value) + switch = wait_and_get_obj(MessagingOptionScreen.LINK_PREVIEW_SWITCH.value) + if not switch.checked: + click_obj_by_name(MessagingOptionScreen.LINK_PREVIEW_SWITCH.value) - # Post condition: Messaging Settings and Link Preview are visible (@see open_messaging_settings and activate_link_preview) + # Post condition: Messaging Settings is active and Link Preview is activated (@see open_messaging_settings and activate_link_preview_if_dectivated) def activate_image_unfurling(self): scroll_item_until_item_is_visible(MessagingOptionScreen.SCROLLVIEW.value, MessagingOptionScreen.ACTIVATE_OR_DECTIVATE_IMAGE_UNFURLING.value) click_obj_by_name(MessagingOptionScreen.ACTIVATE_OR_DECTIVATE_IMAGE_UNFURLING.value) - # Post condition: Messaging Settings and Link Preview are visible (@see open_messaging_settings and activate_link_preview) - def check_tenor_gif_preview_is_enabled(self): + # Post condition: Messaging Settings is active and Link Preview is activated (@see open_messaging_settings and activate_link_preview_if_dectivated) + def the_user_activates_tenor_gif_preview(self): + click_obj_by_name(SidebarComponents.MESSAGING_ITEM.value) scroll_item_until_item_is_visible(MessagingOptionScreen.SCROLLVIEW.value, MessagingOptionScreen.TENOR_GIFS_PREVIEW_SWITCH_ITEM.value) - tenorSwitch = wait_and_get_obj(MessagingOptionScreen.TENOR_GIFS_PREVIEW_SWITCH_ITEM.value) - verify(tenorSwitch.enabled, "Tenor GIFs preview is enabled") + click_obj_by_name(MessagingOptionScreen.TENOR_GIFS_PREVIEW_SWITCH_ITEM.value) def toggle_test_networks(self): # needed cause if we do it immmediately the toggle doesn't work diff --git a/test/ui-test/src/screens/StatusAccountsScreen.py b/test/ui-test/src/screens/StatusAccountsScreen.py index b62d012932..79e7f8b0f9 100755 --- a/test/ui-test/src/screens/StatusAccountsScreen.py +++ b/test/ui-test/src/screens/StatusAccountsScreen.py @@ -38,7 +38,7 @@ class StatusAccountsScreen(): account_obj = None [is_loaded, accountsList] = is_loaded_visible_and_enabled(SAccountsComponents.ACCOUNTS_POPUP.value) if is_loaded: - for child in getChildrenOfType(accountsList, "AccountMenuItemPanel"): + for child in get_children_of_type(accountsList, "AccountMenuItemPanel"): if(child.label == account): account_obj = child found = True diff --git a/test/ui-test/src/screens/StatusChatScreen.py b/test/ui-test/src/screens/StatusChatScreen.py index 93288d693a..18659a9dc1 100644 --- a/test/ui-test/src/screens/StatusChatScreen.py +++ b/test/ui-test/src/screens/StatusChatScreen.py @@ -374,24 +374,15 @@ class StatusChatScreen: last_message_obj = self.get_message_at_index(0) verify(bool(last_message_obj.isEdited), "Message is not marked as edited") - def verify_last_message_sent(self, message: str): - # Get the message text - # We don't search for StatusTextMessage_chatText directly, because there're 2 instances of it in a reply message + def get_last_message_text(self): last_message_obj = self.get_message_at_index(0) - text_message_obj = get_children_with_object_name(last_message_obj, ChatItems.STATUS_MESSAGE_TEXT_MESSAGE.value)[0] - text_edit_obj = get_children_with_object_name(text_message_obj, ChatItems.STATUS_TEXT_MESSAGE_CHAT_TEXT.value)[0] - verify(not is_null(text_edit_obj), "Checking last message sent: " + message) - verify_text_contains(str(text_edit_obj.text), str(message)) + return last_message_obj.messageText + + def verify_last_message_sent(self, message: str): + verify_text_contains(str(self.get_last_message_text()), str(message)) def verify_last_message_sent_is_not(self, message: str): - last_message_obj = self.get_message_at_index(0) - text_message_objs = get_children_with_object_name(last_message_obj, ChatItems.STATUS_MESSAGE_TEXT_MESSAGE.value) - if len(text_message_objs) == 0: - passes("Success: No message was found") - return - text_edit_obj = get_children_with_object_name(text_message_objs[0], ChatItems.STATUS_TEXT_MESSAGE_CHAT_TEXT.value)[0] - verify(not is_null(text_edit_obj), "Checking last message sent: " + message) - verify_text_does_not_contain(str(text_edit_obj.text), str(message)) + verify_text_does_not_contain(str(self.get_last_message_text()), str(message)) # This method expects to have just one mention / link in the last chat message def verify_last_message_sent_contains_mention(self, displayName: str, message: str): diff --git a/test/ui-test/src/utils/ObjectAccess.py b/test/ui-test/src/utils/ObjectAccess.py index 4eabc4512e..eca3f1cd16 100644 --- a/test/ui-test/src/utils/ObjectAccess.py +++ b/test/ui-test/src/utils/ObjectAccess.py @@ -1,13 +1,13 @@ import squish import object -def getChildrenOfType(parent, typename, depth=1000): +def get_children_of_type(parent, typename, depth=1000): children = [] for child in object.children(parent): if squish.className(child) == typename: children.append(child) if depth: - children.extend(getChildrenOfType(child, typename, depth - 1)) + children.extend(get_children_of_type(child, typename, depth - 1)) return children def get_children_with_object_name(parent, objectName, depth=1000): diff --git a/test/ui-test/testSuites/global_shared/scripts/settings_names.py b/test/ui-test/testSuites/global_shared/scripts/settings_names.py index 491791730d..9f63efac65 100644 --- a/test/ui-test/testSuites/global_shared/scripts/settings_names.py +++ b/test/ui-test/testSuites/global_shared/scripts/settings_names.py @@ -89,6 +89,7 @@ generatedAccounts_ListView = {"container": statusDesktop_mainWindow, "objectName # Messaging Settings: settingsContentBase_ScrollView = {"container": statusDesktop_mainWindow, "objectName": "settingsContentBaseScrollView", "type": "StatusScrollView", "visible": True} displayMessageLinkPreviewItem = {"container": statusDesktop_mainWindow, "objectName": "displayMessageLinkPreviewsItem", "type": "StatusListItem"} +linkPreviewSwitch = {"container": statusDesktop_mainWindow, "objectName": "MessagingView_showMessageLinksSwitch", "type": "StatusSwitch", "visible": True} imageUnfurlingItem = {"container": statusDesktop_mainWindow, "objectName": "imageUnfurlingItem", "type": "StatusListItem"} tenorGifsPreviewSwitchItem = {"container": statusDesktop_mainWindow, "objectName": "MessagingView_sitesListView_StatusListItem_tenor_gifs_subdomain", "type": "StatusListItem"} contacts_listItem_btn = {"container": statusDesktop_mainWindow, "objectName": "MessagingView_ContactsListItem_btn", "type": "StatusContactRequestsIndicatorListItem"} diff --git a/test/ui-test/testSuites/global_shared/steps/settingsSteps.py b/test/ui-test/testSuites/global_shared/steps/settingsSteps.py index a380aebd51..7cc48f428f 100644 --- a/test/ui-test/testSuites/global_shared/steps/settingsSteps.py +++ b/test/ui-test/testSuites/global_shared/steps/settingsSteps.py @@ -19,11 +19,7 @@ def step(context: any): @Given("the user opens the messaging settings") def step(context: any): the_user_opens_the_messaging_settings() - -@Given("tenor GIFs preview is enabled") -def step(context: any): - _settingsScreen.check_tenor_gif_preview_is_enabled() - + @Given("the user activates wallet and opens the wallet section") def step(context: any): init_steps.the_user_activates_wallet_and_opens_the_wallet_section() @@ -39,11 +35,20 @@ def step(context: any): @Given("the user opens the wallet settings") def step(context: any): the_user_opens_the_wallet_settings() + ######################### ### ACTIONS region: ######################### +@When("the user activates the link preview if it is deactivated") +def step(context: any): + _settingsScreen.activate_link_preview_if_dectivated() + +@When("the user activates tenor GIFs preview") +def step(context: any): + _settingsScreen.the_user_activates_tenor_gif_preview() + @When("the user opens app settings screen") def step(context: any): the_user_opens_app_settings_screen() @@ -52,10 +57,6 @@ def step(context: any): def step(context: any): the_user_opens_the_messaging_settings() -@When("the user activates link preview") -def step(context: any): - _settingsScreen.activate_link_preview() - @When("the user activates image unfurling") def step(context: any): _settingsScreen.activate_image_unfurling() diff --git a/test/ui-test/testSuites/suite_messaging/shared/steps/chatSteps.py b/test/ui-test/testSuites/suite_messaging/shared/steps/chatSteps.py index 2c5d9c48f0..b2ec49710a 100644 --- a/test/ui-test/testSuites/suite_messaging/shared/steps/chatSteps.py +++ b/test/ui-test/testSuites/suite_messaging/shared/steps/chatSteps.py @@ -207,7 +207,7 @@ def step(context): @Then("the GIF message is displayed") def step(context): - _statusChat.verify_last_message_sent("tenor.gif") + _statusChat.verify_last_message_sent("tenor.com") @Then("the image |any| is unfurled in the chat") def step(context: any, image_link: str): diff --git a/test/ui-test/testSuites/suite_messaging/tst_ChatFlow/test.feature b/test/ui-test/testSuites/suite_messaging/tst_ChatFlow/test.feature index a4a2c3eab3..92a9f2e519 100644 --- a/test/ui-test/testSuites/suite_messaging/tst_ChatFlow/test.feature +++ b/test/ui-test/testSuites/suite_messaging/tst_ChatFlow/test.feature @@ -64,23 +64,21 @@ Feature: Status Desktop Chat Basic Flows When the user clears chat history Then the chat is cleared - @mayfail - # TODO: Verification of gif sent fails. And also `tenor GIFs preview is enabled` step doesn't work. Review it. Scenario: The user can send a GIF Given the user opens app settings screen And the user opens the messaging settings - And tenor GIFs preview is enabled - When the user sends a GIF message + When the user activates the link preview if it is deactivated + And the user activates tenor GIFs preview + And the user opens the chat section + And the user sends a GIF message Then the GIF message is displayed - @mayfail - # TODO: It works standalone but when it runs as part of the sequence, the action of activates link preview doesn't work. Scenario Outline: The user can activate image unfurling Given the user sends a chat message "" And the image "" is not unfurled in the chat - When the user opens app settings screen + And the user opens app settings screen And the user opens the messaging settings - And the user activates link preview + When the user activates the link preview if it is deactivated And the user activates image unfurling And the user opens the chat section Then the image "" is unfurled in the chat diff --git a/ui/app/AppLayouts/Profile/views/MessagingView.qml b/ui/app/AppLayouts/Profile/views/MessagingView.qml index ea3e9e59a6..76ed3e1300 100644 --- a/ui/app/AppLayouts/Profile/views/MessagingView.qml +++ b/ui/app/AppLayouts/Profile/views/MessagingView.qml @@ -170,6 +170,7 @@ SettingsContentBase { components: [ StatusSwitch { id: showMessageLinksSwitch + objectName: "MessagingView_showMessageLinksSwitch" checked: previewableSites.anyWhitelisted || localAccountSensitiveSettings.displayChatImages onToggled: { if (!checked) {