From d0725d451efedb12c205c127f4e08ae1ca9b155f Mon Sep 17 00:00:00 2001 From: Patryk Osmaczko Date: Wed, 23 Nov 2022 14:46:02 +0100 Subject: [PATCH] fix(ui-test/ChatFlow): retry to load stickers For some reason stickers are not loaded for the first time. User has now the ability to retry the loading procedure. Retry action loads stickers successfully in most cases. fixes: #7995 --- test/ui-test/src/screens/StatusChatScreen.py | 23 ++++++++++++++++--- .../shared/scripts/chat_names.py | 1 + .../suite_messaging/tst_ChatFlow/test.feature | 4 ++-- .../shared/status/StatusStickersPopup.qml | 20 ++++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/test/ui-test/src/screens/StatusChatScreen.py b/test/ui-test/src/screens/StatusChatScreen.py index 10a6e4df77..34fa871ed2 100644 --- a/test/ui-test/src/screens/StatusChatScreen.py +++ b/test/ui-test/src/screens/StatusChatScreen.py @@ -76,6 +76,7 @@ class ChatComponents(Enum): class ChatStickerPopup(Enum): STICKERS_POPUP_GET_STICKERS_BUTTON = "chat_StickersPopup_GetStickers_Button" + STICKERS_POPUP_RETRY_BUTTON = "chat_StickersPopup_Retry_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" @@ -272,9 +273,25 @@ class StatusChatScreen: 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") + grid_view_displayed, grid_view = is_loaded_visible_and_enabled(ChatStickerPopup.STICKERS_POPUP_MARKET_GRID_VIEW.value) + verify(grid_view_displayed, "Sticker market grid view is not loaded") + + # Stickers may not be loaded, retry to load them + stickers_not_loaded = is_displayed(ChatStickerPopup.STICKERS_POPUP_RETRY_BUTTON.value) + if (stickers_not_loaded): + click_obj_by_name(ChatStickerPopup.STICKERS_POPUP_RETRY_BUTTON.value) + + # Wait for stickers to load + stickers_grid_displayed = is_displayed(ChatStickerPopup.STICKERS_POPUP_MARKET_GRID_VIEW_DELEGATE_ITEM_1.value) + + # In the meantime popup may be closed due to external (unknown?) reason, reopen it + if (not stickers_grid_displayed): + grid_view_displayed = is_displayed(ChatStickerPopup.STICKERS_POPUP_MARKET_GRID_VIEW.value) + if (not grid_view_displayed): + click_obj_by_name(ChatComponents.CHAT_INPUT_STICKER_BUTTON.value) + click_obj_by_name(ChatStickerPopup.STICKERS_POPUP_GET_STICKERS_BUTTON.value) + grid_view_displayed, grid_view = is_loaded_visible_and_enabled(ChatStickerPopup.STICKERS_POPUP_MARKET_GRID_VIEW.value) + verify(grid_view_displayed, "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") diff --git a/test/ui-test/testSuites/suite_messaging/shared/scripts/chat_names.py b/test/ui-test/testSuites/suite_messaging/shared/scripts/chat_names.py index 1e10093da8..9c72fcca90 100644 --- a/test/ui-test/testSuites/suite_messaging/shared/scripts/chat_names.py +++ b/test/ui-test/testSuites/suite_messaging/shared/scripts/chat_names.py @@ -54,6 +54,7 @@ chatView_chatMembers_ListView = {"container": statusDesktop_mainWindow, "objectN # Stickers Popup chat_StickersPopup_GetStickers_Button = {"container": statusDesktop_mainWindow_overlay, "objectName": "stickersPopupGetStickersButton", "type": "StatusButton", "visible": True} +chat_StickersPopup_Retry_Button = {"container": statusDesktop_mainWindow_overlay, "objectName": "stickersPopupRetryButton", "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} 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 c5fdeaf9b1..6d40d40e26 100644 --- a/test/ui-test/testSuites/suite_messaging/tst_ChatFlow/test.feature +++ b/test/ui-test/testSuites/suite_messaging/tst_ChatFlow/test.feature @@ -160,8 +160,8 @@ Feature: Status Desktop Chat Basic Flows Then the last chat message contains "🙂" And the last chat message contains "Hello" - @mayfail - # TODO: It works standalone but when it runs as part of the sequence and mostly in the CI, the action of verification doesn't work. + @mayfail + # NOTE: It may be flaky due to undeterministic network conditions and 3rd party infura response. Scenario: The user can send a sticker after installing a free pack Given the user installs the sticker pack at position 4 When the user sends the sticker at position 2 in the list diff --git a/ui/imports/shared/status/StatusStickersPopup.qml b/ui/imports/shared/status/StatusStickersPopup.qml index cdfe2fdf10..67d94dc18b 100644 --- a/ui/imports/shared/status/StatusStickersPopup.qml +++ b/ui/imports/shared/status/StatusStickersPopup.qml @@ -103,6 +103,26 @@ Popup { active: d.stickerPacksLoading sourceComponent: loadingImageComponent } + + ColumnLayout { + id: failedToLoadStickersInfo + + anchors.centerIn: parent + visible: d.stickerPacksLoadFailed + + StatusBaseText { + text: qsTr("Failed to load stickers") + color: Theme.palette.dangerColor1 + } + + StatusButton { + objectName: "stickersPopupRetryButton" + Layout.alignment: Qt.AlignHCenter + text: qsTr("Try again") + + onClicked: d.loadStickers() + } + } } Item {