From 6bd1cfde72f59624847d0d2d18f3be36f4cb4734 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 11 Aug 2022 15:16:59 -0400 Subject: [PATCH] test(chat): add a test that install a sticker pack and sends a sticker Fixes #6962 --- .../src/drivers/SquishDriverVerification.py | 6 +++ test/ui-test/src/screens/SettingsScreen.py | 2 +- test/ui-test/src/screens/StatusChatScreen.py | 51 +++++++++++++++++++ .../global_shared/scripts/global_names.py | 2 +- .../testSuites/suite_onboarding/suite.conf | 1 + .../shared/scripts/sections/chat_names.py | 10 +++- .../suite_status/shared/steps/chatSteps.py | 10 ++++ .../suite_status/tst_ChatFlow/test.feature | 6 +++ ui/imports/shared/popups/ModalPopup.qml | 2 +- ui/imports/shared/status/StatusChatInput.qml | 1 + .../shared/status/StatusStickerMarket.qml | 5 ++ .../shared/status/StatusStickersPopup.qml | 2 + 12 files changed, 94 insertions(+), 4 deletions(-) diff --git a/test/ui-test/src/drivers/SquishDriverVerification.py b/test/ui-test/src/drivers/SquishDriverVerification.py index 04aa80f967..991b2eea65 100644 --- a/test/ui-test/src/drivers/SquishDriverVerification.py +++ b/test/ui-test/src/drivers/SquishDriverVerification.py @@ -69,6 +69,12 @@ def process_terminated(pid): except: return True return False + +def verify_failure(errorMsg: str): + test.fail(errorMsg) + +def verify_values_equal(found: str, wanted: str, msg : str): + test.verify(found == wanted, msg + " Found: " + found + " - Wanted: " + wanted) def verify_the_app_is_closed(pid: int): closed = False diff --git a/test/ui-test/src/screens/SettingsScreen.py b/test/ui-test/src/screens/SettingsScreen.py index 53c80722ee..bee1a6fdd5 100644 --- a/test/ui-test/src/screens/SettingsScreen.py +++ b/test/ui-test/src/screens/SettingsScreen.py @@ -71,7 +71,7 @@ class ProfileSettingsScreen(Enum): TWITTER_SOCIAL_LINK: str = "twitter_StaticSocialLinkInput" PERSONAL_SITE_SOCIAL_LINK: str = "personalSite_StaticSocialLinkInput" OPEN_SOCIAL_LINKS_DIALOG: str = "addMoreSocialLinks_StatusIconTextButton" - CLOSE_SOCIAL_LINKS_DIALOG: str = "close_popup_StatusFlatRoundButton" + CLOSE_SOCIAL_LINKS_DIALOG: str = "modal_Close_Button" TWITTER_SOCIAL_LINK_IN_DIALOG: str = "twitter_popup_TextEdit" PERSONAL_SITE_LINK_IN_DIALOG: str = "personalSite_popup_TextEdit" CUSTOM_LINK_IN_DIALOG: str = "customLink_popup_TextEdit" diff --git a/test/ui-test/src/screens/StatusChatScreen.py b/test/ui-test/src/screens/StatusChatScreen.py index 87d7c53c68..39b7e7f89e 100644 --- a/test/ui-test/src/screens/StatusChatScreen.py +++ b/test/ui-test/src/screens/StatusChatScreen.py @@ -12,6 +12,7 @@ import re import copy from enum import Enum +import time from drivers.SquishDriver import * from drivers.SquishDriverVerification import * from drivers.SDKeyboardCommands import * @@ -61,6 +62,15 @@ class ChatComponents(Enum): GIF_POPUP_BUTTON = "chatView_gifPopupButton" ENABLE_GIF_BUTTON = "gifPopup_enableGifButton" GIF_MOUSEAREA = "gifPopup_gifMouseArea" + CHAT_INPUT_STICKER_BUTTON = "chat_Input_Stickers_Button" + +class ChatStickerPopup(Enum): + STICKERS_POPUP_GET_STICKERS_BUTTON = "chat_StickersPopup_GetStickers_Button" + STICKERS_POPUP_MARKET_GRID_VIEW = "chat_StickersPopup_StickerMarket_GridView" + STICKERS_POPUP_MARKET_GRID_VIEW_DELEGATE_ITEM_1 = "chat_StickersPopup_StickerMarket_DelegateItem_1" + STICKERS_POPUP_MARKET_INSTALL_BUTTON = "chat_StickersPopup_StickerMarket_Install_Button" + MODAL_CLOSE_BUTTON = "modal_Close_Button" + STICKER_LIST_GRID = "chat_StickersPopup_StickerList_Grid" class ChatMessagesHistory(Enum): CHAT_CREATED_TEXT = 1 @@ -245,6 +255,47 @@ class StatusChatScreen: break verify(found, "Checking if the following display name is in the mention's list: " + displayName) + + def install_sticker_pack(self, pack_index: str): + click_obj_by_name(ChatComponents.CHAT_INPUT_STICKER_BUTTON.value) + click_obj_by_name(ChatStickerPopup.STICKERS_POPUP_GET_STICKERS_BUTTON.value) + + # Wait for grid view to be loaded + loaded, grid_view = is_loaded_visible_and_enabled(ChatStickerPopup.STICKERS_POPUP_MARKET_GRID_VIEW.value) + if (not loaded): + verify_failure("Sticker market grid view is not loaded") + + # Wait for the items in the GridView to be loaded + verify(is_displayed(ChatStickerPopup.STICKERS_POPUP_MARKET_GRID_VIEW_DELEGATE_ITEM_1.value), "Sticker item 0 is not displayed") + + scroll_list_view_at_index(grid_view, int(pack_index)) + + sticker_pack = grid_view.itemAtIndex(int(pack_index)) + click_obj(sticker_pack) + + # Install and close + click_obj_by_name(ChatStickerPopup.STICKERS_POPUP_MARKET_INSTALL_BUTTON.value) + click_obj_by_name(ChatStickerPopup.MODAL_CLOSE_BUTTON.value) + + verify(sticker_pack.installed == True, "The sticker pack at position " + str(pack_index) + " was not installed") + + #Close sticker popup + click_obj_by_name(ChatComponents.CHAT_INPUT_STICKER_BUTTON.value) + + def send_sticker(self, sticker_index: int): + click_obj_by_name(ChatComponents.CHAT_INPUT_STICKER_BUTTON.value) + + loaded, sticker_list_grid = is_loaded_visible_and_enabled(ChatStickerPopup.STICKER_LIST_GRID.value) + + if (not loaded): + verify_failure("Sticker list grid view is not loaded") + + sticker = sticker_list_grid.itemAtIndex(int(sticker_index)) + click_obj(sticker) + + last_message_obj = get_obj(ChatComponents.CHAT_LOG.value).itemAtIndex(0) + verify_values_equal(str(last_message_obj.messageContentType), str(MessageContentType.STICKER.value), "The last message is not a sticker") + def send_emoji(self, emoji_short_name: str, message: str): if (message != ""): diff --git a/test/ui-test/testSuites/global_shared/scripts/global_names.py b/test/ui-test/testSuites/global_shared/scripts/global_names.py index bb07732eb8..4b9ce62dc3 100644 --- a/test/ui-test/testSuites/global_shared/scripts/global_names.py +++ b/test/ui-test/testSuites/global_shared/scripts/global_names.py @@ -15,7 +15,7 @@ settings_navbar_settings_icon_StatusIcon = {"container": mainWindow_navBarListVi userContextMenu_ViewMyProfile_Action = {"container": statusDesktop_mainWindow_overlay, "objectName": "userStatusViewMyProfileAction", "type": "StatusMenuItemDelegate", "visible": True} # popups -close_popup_StatusFlatRoundButton = {"container": statusDesktop_mainWindow_overlay, "id": "closeButton", "type": "StatusFlatRoundButton", "unnamed": 1, "visible": True} +modal_Close_Button = {"container": statusDesktop_mainWindow_overlay, "objectName": "modalCloseButtonRectangle", "type": "Rectangle", "visible": True} # Main Window - chat related: mainWindow_public_chat_icon_StatusIcon = {"container": statusDesktop_mainWindow, "objectName": "public-chat-icon", "source": "qrc:/StatusQ/src/assets/img/icons/public-chat.svg", "type": "StatusIcon", "visible": True} diff --git a/test/ui-test/testSuites/suite_onboarding/suite.conf b/test/ui-test/testSuites/suite_onboarding/suite.conf index 112c1b7264..7ef9d82bc2 100644 --- a/test/ui-test/testSuites/suite_onboarding/suite.conf +++ b/test/ui-test/testSuites/suite_onboarding/suite.conf @@ -1,4 +1,5 @@ AUT=nim_status_client +ENVVARS=envvars LANGUAGE=Python OBJECTMAPSTYLE=script TEST_CASES=tst_statusSignUp tst_passwordStrength diff --git a/test/ui-test/testSuites/suite_status/shared/scripts/sections/chat_names.py b/test/ui-test/testSuites/suite_status/shared/scripts/sections/chat_names.py index 1a1080e2c8..e7ba20a95f 100644 --- a/test/ui-test/testSuites/suite_status/shared/scripts/sections/chat_names.py +++ b/test/ui-test/testSuites/suite_status/shared/scripts/sections/chat_names.py @@ -16,6 +16,7 @@ chatView_TogglePinMessageButton = {"container": chatView_log, "objectName": "Mes chatInfoButton_Pin_Text = {"container": chatView_StatusChatInfoButton, "objectName": "StatusChatInfo_pinText", "type": "StatusBaseText", "visible": True} chatButtonsPanelConfirmDeleteMessageButton_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "chatButtonsPanelConfirmDeleteMessageButton", "type": "StatusButton"} mark_as_Read_StatusMenuItemDelegate = {"container": statusDesktop_mainWindow_overlay, "objectName": "chatMarkAsReadMenuItem", "type": "StatusMenuItemDelegate", "visible": True} +chat_Input_Stickers_Button = {"container": statusDesktop_mainWindow, "objectName": "statusChatInputStickersButton", "type": "StatusFlatRoundButton", "visible": True} chatView_SuggestionBoxPanel ={"container": statusDesktop_mainWindow, "objectName": "suggestionsBox", "type": "SuggestionBoxPanel"} chatView_suggestion_ListView ={"container": chatView_SuggestionBoxPanel, "objectName": "suggestionBoxList", "type": "StatusListView"} chatView_userMentioned_ProfileView ={"container": statusDesktop_mainWindow_overlay, "objectName": "profileView", "type": "ProfileView"} @@ -42,5 +43,12 @@ chat_name_PlaceholderText = {"container": statusDesktop_mainWindow_overlay, "tex createChatView_contactsList = {"container": statusDesktop_mainWindow, "objectName": "tagSelectorUserList", "type": "ListView"} createChatView_confirmBtn = {"container": statusDesktop_mainWindow, "objectName": "createChatConfirmButton", "type": "StatusButton"} -## Members panel: +# Members panel: chatView_chatMembers_ListView = {"container": statusDesktop_mainWindow, "objectName": "userListPanel", "type": "ListView"} + +# Stickers Popup +chat_StickersPopup_GetStickers_Button = {"container": statusDesktop_mainWindow_overlay, "objectName": "stickersPopupGetStickersButton", "type": "StatusButton", "visible": True} +chat_StickersPopup_StickerMarket_GridView = {"container": statusDesktop_mainWindow_overlay, "objectName": "stickerMarketStatusGridView", "type": "StatusGridView", "visible": True} +chat_StickersPopup_StickerMarket_DelegateItem_1 = {"container": chat_StickersPopup_StickerMarket_GridView, "objectName": "stickerMarketDelegateItem1", "type": "Item", "visible": True} +chat_StickersPopup_StickerMarket_Install_Button = {"container": statusDesktop_mainWindow_overlay, "objectName": "statusStickerMarketInstallButton", "type": "StatusStickerButton", "visible": True} +chat_StickersPopup_StickerList_Grid = {"container": statusDesktop_mainWindow_overlay, "objectName": "statusStickerPopupStickerGrid", "type": "StatusStickerList", "visible": True} diff --git a/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py b/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py index a14c2d9ef7..3ef98dd637 100644 --- a/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py +++ b/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py @@ -150,6 +150,16 @@ def step(context, emoji): def step(context, message): _statusChat.verify_last_message_sent(message) + +@Then("the user can install the sticker pack at position |any|") +def step(context, pack_index): + _statusChat.install_sticker_pack(pack_index) + +# Using position of sticker because stickers don't have ids, only hashes and it feels weird to type hashes in Gherkin +@Then("the user can send the sticker at position |any| in the list") +def step(context, sticker_index): + _statusChat.send_sticker(sticker_index) + @Then("the user cannot input a mention to a not existing user |any|") def step(context, displayName): _statusChat.cannot_do_mention(displayName) diff --git a/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature b/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature index 326787cf70..aa8703daa7 100644 --- a/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature +++ b/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature @@ -137,3 +137,9 @@ Feature: Status Desktop Chat When user joins chat room automation-test Then the user is able to send chat message "Hello :)" Then the message Hello 🙂 is displayed in the last message + + + Scenario: User can send a sticker after installing a free pack + When user joins chat room automation-test + Then the user can install the sticker pack at position 4 + Then the user can send the sticker at position 2 in the list diff --git a/ui/imports/shared/popups/ModalPopup.qml b/ui/imports/shared/popups/ModalPopup.qml index 3de817ab70..c2c7141888 100644 --- a/ui/imports/shared/popups/ModalPopup.qml +++ b/ui/imports/shared/popups/ModalPopup.qml @@ -80,7 +80,7 @@ Popup { Rectangle { id: closeButton - objectName: "closeButtonRectangle" + objectName: "modalCloseButtonRectangle" property bool hovered: false visible: displayCloseButton height: 32 diff --git a/ui/imports/shared/status/StatusChatInput.qml b/ui/imports/shared/status/StatusChatInput.qml index 98202dd5ea..deb32af8e0 100644 --- a/ui/imports/shared/status/StatusChatInput.qml +++ b/ui/imports/shared/status/StatusChatInput.qml @@ -1234,6 +1234,7 @@ Rectangle { StatusQ.StatusFlatRoundButton { id: stickersBtn + objectName: "statusChatInputStickersButton" implicitHeight: 32 implicitWidth: 32 width: visible ? 32 : 0 diff --git a/ui/imports/shared/status/StatusStickerMarket.qml b/ui/imports/shared/status/StatusStickerMarket.qml index a477d62792..1143e690d5 100644 --- a/ui/imports/shared/status/StatusStickerMarket.qml +++ b/ui/imports/shared/status/StatusStickerMarket.qml @@ -32,6 +32,7 @@ Item { StatusGridView { id: availableStickerPacks + objectName: "stickerMarketStatusGridView" width: parent.width height: 380 anchors.left: parent.left @@ -86,6 +87,9 @@ Item { } delegate: Item { + objectName: "stickerMarketDelegateItem" + index + readonly property string packId: model.packId // This property is necessary for the tests + readonly property bool installed: model.installed // This property is necessary for the tests width: availableStickerPacks.cellWidth height: availableStickerPacks.cellHeight RoundedImage { @@ -125,6 +129,7 @@ Item { } footer: StatusStickerButton { + objectName: "statusStickerMarketInstallButton" height: 44 anchors.right: parent.right style: StatusStickerButton.StyleType.LargeNoIcon diff --git a/ui/imports/shared/status/StatusStickersPopup.qml b/ui/imports/shared/status/StatusStickersPopup.qml index d1ac56757a..4977b561e8 100644 --- a/ui/imports/shared/status/StatusStickersPopup.qml +++ b/ui/imports/shared/status/StatusStickersPopup.qml @@ -155,6 +155,7 @@ Popup { } StatusQControls.StatusButton { + objectName: "stickersPopupGetStickersButton" visible: lblNoStickersYet.visible text: qsTr("Get Stickers") anchors.top: noStickersContainer.bottom @@ -169,6 +170,7 @@ Popup { } StatusStickerList { id: stickerGrid + objectName: "statusStickerPopupStickerGrid" model: recentStickers packId: stickerPackListView.selectedPackId onStickerClicked: {