test(search): add test for the search feature

Fixes #6885
This commit is contained in:
Jonathan Rainville 2022-08-15 17:01:12 -04:00
parent 8624b3ae9a
commit 464476d135
14 changed files with 207 additions and 17 deletions

View File

@ -162,7 +162,7 @@ def check_obj_by_name(objName: str):
def is_text_matching(objName: str, text: str):
try:
obj = squish.waitForObject(getattr(names, objName))
test.compare(obj.text, text, "Found the following text " + text)
test.compare(obj.text, text, "Found the following text " + str(obj.text) + " Wanted: " + text)
return True
except LookupError:
print(objName + " is not found, please check app for correct object and update object mapper")
@ -187,6 +187,11 @@ def type(objName: str, text: str):
except LookupError:
return False
# It types the specified text in the currently focus input (like if the keyboard was typed on)
def native_type(text: str):
squish.nativeType(text)
# Wait for the object to appears and
# It types the specified text into the given object (as if the user had used the keyboard):
def wait_for_object_and_type(objName: str, text: str):

View File

@ -18,6 +18,7 @@ import time
class MainScreenComponents(Enum):
STATUS_ICON = "mainWindow_statusIcon_StatusIcon_2"
PUBLIC_CHAT_ICON = "mainWindow_public_chat_icon_StatusIcon"
CHAT_NAVBAR_ICON = "navBarListView_Chat_navbar_StatusNavBarTabButton"
COMMUNITY_PORTAL_BUTTON = "navBarListView_Communities_Portal_navbar_StatusNavBarTabButton"
JOIN_PUBLIC_CHAT = "join_public_chat_StatusMenuItemDelegate"
SETTINGS_BUTTON = "settings_navbar_settings_icon_StatusIcon"
@ -44,10 +45,11 @@ class StatusMainScreen:
verify_screen(MainScreenComponents.PUBLIC_CHAT_ICON.value)
# Wait for the banner to disappear otherwise the click might land badly
@staticmethod
def wait_for_banner_to_disappear():
[bannerLoaded, _] = is_loaded_visible_and_enabled(MainScreenComponents.MODULE_WARNING_BANNER.value)
if (bannerLoaded):
time.sleep(5)
StatusMainScreen.wait_for_banner_to_disappear()
def join_chat_room(self, room: str):
click_obj_by_name(MainScreenComponents.PUBLIC_CHAT_ICON.value)
@ -55,6 +57,9 @@ class StatusMainScreen:
type(ChatNamePopUp.INPUT_ROOM_TOPIC_TEXT.value, room)
click_obj_by_name(ChatNamePopUp.START_CHAT_BTN.value)
def open_chat_section(self):
click_obj_by_name(MainScreenComponents.CHAT_NAVBAR_ICON.value)
def open_community_portal(self):
click_obj_by_name(MainScreenComponents.COMMUNITY_PORTAL_BUTTON.value)

View File

@ -0,0 +1,74 @@
from enum import Enum
from drivers.SquishDriver import *
from drivers.SquishDriverVerification import *
from drivers.SDKeyboardCommands import *
from common.Common import *
class SearchPopupComponents(Enum):
SEARCH_INPUT = "searchPopupSearchInput_TextEdit"
SEARCH_RESULT_LISTVIEW = "searchPopup_Result_ListView"
RESET_BUTTON = "searchPopup_Reset_Button"
LOADING_INDICATOR = "searchPopup_Loading_Indicator"
class StatusSearchScreen:
def __init__(self):
self._loading_done_retries = 0
def open_search_menu(self):
if sys.platform == "darwin":
native_type("<Command+f>");
else:
native_type("<Ctrl+f>");
def _do_wait_for_loading_done(self):
# Wait 10 seconds for the loading to be over, if more, throw
if (self._loading_done_retries > 10):
verify_failure("The loading indicator for the search is not going away")
[indicator_visible, _] = is_loaded_visible_and_enabled(SearchPopupComponents.LOADING_INDICATOR.value, 1000)
if (indicator_visible):
self._loading_done_retries += 1
self.wait_for_loading_done()
def wait_for_loading_done(self):
self._loading_done_retries = 0
self._do_wait_for_loading_done()
def search_for(self, search_term: str):
click_obj_by_name(SearchPopupComponents.RESET_BUTTON.value)
type(SearchPopupComponents.SEARCH_INPUT.value, search_term)
self.wait_for_loading_done()
def verify_number_of_results(self, amount: int):
list_view = get_obj(SearchPopupComponents.SEARCH_RESULT_LISTVIEW.value)
verify_values_equal(str(list_view.count), str(amount), "Not the right amount of search results were found")
def click_on_channel(self, channel_name: str):
list_view = get_obj(SearchPopupComponents.SEARCH_RESULT_LISTVIEW.value)
channel_item = None
found = False
for index in range(list_view.count):
channel_item = list_view.itemAtIndex(index)
if(channel_item.title == channel_name):
found = True
break
if (not found):
verify_failure("Channel not found in the search field, name: " + channel_name)
click_obj(channel_item)
def click_on_message(self, message: str):
list_view = get_obj(SearchPopupComponents.SEARCH_RESULT_LISTVIEW.value)
message_item = None
found = False
for index in range(list_view.count):
message_item = list_view.itemAtIndex(index)
if(message in str(message_item.subTitle)):
found = True
break
if (not found):
verify_failure("Message not found in the search field, message: " + message)
click_obj(message_item)

View File

@ -9,5 +9,6 @@ from sections.chat_names import *
from sections.community_names import *
from sections.community_portal_names import *
from sections.login_names import *
from sections.search_names import *
from sections.settings_names import *
from sections.wallet_names import *

View File

@ -1,11 +1,12 @@
from scripts.global_names import *
# Chat view:
chatView_StatusChatInfoButton = {"container": statusDesktop_mainWindow, "objectName": "chatInfoBtnInHeader", "type": "StatusChatInfoButton"}
navBarListView_Chat_navbar_StatusNavBarTabButton = {"checkable": True, "container": mainWindow_navBarListView_ListView, "objectName": "Chat-navbar", "type": "StatusNavBarTabButton", "visible": True}
chatView_StatusChatInfoButton = {"container": statusDesktop_mainWindow, "objectName": "chatInfoBtnInHeader", "type": "StatusChatInfoButton", "visible": True}
mainWindow_scrollView_ScrollView = {"container": statusDesktop_mainWindow, "id": "scrollView", "type": "StatusScrollView", "unnamed": 1, "visible": True}
chatView_messageInput = {"container": statusDesktop_mainWindow, "objectName": "messageInputField", "type": "TextArea", "visible": True}
chatView_chatLogView_lastMsg_MessageView = {"container": chatView_log, "index": 0, "type": "MessageView"}
chatView_lastChatText_Text = {"container": chatView_chatLogView_lastMsg_MessageView, "objectName": "chatText", "type": "StyledTextEdit"}
chatView_lastChatText_Text = {"container": chatView_chatLogView_lastMsg_MessageView, "objectName": "StatusTextMessage_chatText", "type": "TextEdit"}
chatView_replyToMessageButton = {"container": chatView_log, "objectName": "replyToMessageButton", "type": "StatusFlatRoundButton"}
chatView_DeleteMessageButton = {"container": chatView_log, "objectName": "chatDeleteMessageButton", "type": "StatusFlatRoundButton"}
chatButtonsPanelConfirmDeleteMessageButton_StatusButton = {"container": statusDesktop_mainWindow_overlay, "objectName": "chatButtonsPanelConfirmDeleteMessageButton", "type": "StatusButton"}

View File

@ -0,0 +1,7 @@
from scripts.global_names import *
searchPopupSearchInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "searchPopupSearchInput", "type": "TextEdit", "visible": True}
searchPopup_Result_ListView = {"container": statusDesktop_mainWindow_overlay, "objectName": "searchResultListView", "type": "ListView", "visible": True}
searchPopup_Reset_Button = {"container": statusDesktop_mainWindow_overlay, "objectName": "searchModalResetSearchButton", "type": "StatusFlatRoundButton", "visible": True}
searchPopup_Loading_Indicator = {"container": statusDesktop_mainWindow_overlay, "objectName": "searchPopupLoadingIndicator", "type": "StatusLoadingIndicator", "visible": True}

View File

@ -11,6 +11,10 @@ _statusMain = StatusMainScreen()
_statusChat = StatusChatScreen()
_statusCreateChatView = StatusCreateChatScreen()
@When("the user opens the chat section")
def step(context):
_statusMain.open_chat_section()
@When("user joins chat room |any|")
def step(context, room):
_statusMain.join_chat_room(room)
@ -52,7 +56,7 @@ def step(context):
def step(context, createdTxt):
_statusChat.verify_chat_created_message_is_displayed_in_history(createdTxt)
@Then("the group chat title is |any|")
@Then("the chat title is |any|")
def step(context, title):
_statusChat.verify_chat_title(title)

View File

@ -8,7 +8,7 @@ _statusCommunitityPortal = StatusCommunityPortalScreen()
_statusMainScreen = StatusMainScreen()
@Then("the user opens the community portal section")
@When("the user opens the community portal section")
def step(context: any):
_statusMainScreen.open_community_portal()
@ -32,9 +32,9 @@ def step(context, community_channel_name, community_channel_description, method)
@When("the admin edits the current community channel to the name |any|")
def step(context, new_community_channel_name):
_statusCommunityScreen.edit_community_channel(new_community_channel_name)
@Then("the user lands on the community channel named |any|")
def step(context, community_channel_name):
@Then("the user lands on the channel named |any|")
def step(context, community_channel_name):
_statusCommunityScreen.verify_channel_name(community_channel_name)
@When("the admin creates a community category named |any|, with channels |any| and with the method |any|")

View File

@ -0,0 +1,28 @@
from screens.StatusSearchScreen import StatusSearchScreen
_searchScreen = StatusSearchScreen()
@When("the user opens the search menu")
def step(context):
_searchScreen.open_search_menu()
@When("the user searches for |any|")
def step(context, search_term):
_searchScreen.search_for(search_term)
@When("the user searches the random message")
def step(context):
_searchScreen.search_for(context.userData["randomMessage"])
@Then("the search menu shows |any| results")
def step(context, amount):
_searchScreen.verify_number_of_results(amount)
@When("the user clicks on the search result for channel |any|")
def step(context, channel_name):
_searchScreen.click_on_channel(channel_name)
@When("the user clicks on the search result for the random message")
def step(context):
_searchScreen.click_on_message(context.userData["randomMessage"])

View File

@ -5,6 +5,6 @@ HOOK_SUB_PROCESSES=false
IMPLICITAUTSTART=0
LANGUAGE=Python
OBJECTMAPSTYLE=script
TEST_CASES=tst_statusLoginPassword tst_basicChatFlow tst_wallet tst_communityFlows tst_groupChat tst_transaction tst_settingsMenu tst_userIdentity tst_languageSettings
TEST_CASES=tst_statusLoginPassword tst_basicChatFlow tst_wallet tst_communityFlows tst_groupChat tst_transaction tst_settingsMenu tst_userIdentity tst_languageSettings tst_searchFlows
VERSION=3
WRAPPERS=Qt

View File

@ -19,7 +19,7 @@ Feature: Status Desktop community
Given A first time user lands on the status desktop and generates new key
When user signs up with username tester123 and password TesTEr16843/!@00
Then the user lands on the signed in app
Then the user opens the community portal section
When the user opens the community portal section
Then the user lands on the community portal section
Scenario Outline: User creates a community
@ -35,7 +35,7 @@ Feature: Status Desktop community
When the user creates a community named myCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named myCommunity
When the admin creates a community channel named <community_channel_name>, with description <community_channel_description> with the method <method>
Then the user lands on the community channel named <community_channel_name>
Then the user lands on the channel named <community_channel_name>
Examples:
| community_channel_name | community_channel_description | method |
@ -47,9 +47,9 @@ Feature: Status Desktop community
When the user creates a community named myCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named myCommunity
When the admin creates a community channel named test-channel, with description My description with the method bottom_menu
Then the user lands on the community channel named test-channel
Then the user lands on the channel named test-channel
When the admin edits the current community channel to the name <new_community_channel_name>
Then the user lands on the community channel named <new_community_channel_name>
Then the user lands on the channel named <new_community_channel_name>
Examples:
| community_channel_name | community_channel_description | new_community_channel_name |
@ -59,7 +59,7 @@ Feature: Status Desktop community
When the user creates a community named myCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named myCommunity
When the admin creates a community channel named test-channel, with description My description with the method bottom_menu
Then the user lands on the community channel named test-channel
Then the user lands on the channel named test-channel
And the channel count is 2
When the admin deletes current channel
Then the channel count is 1
@ -124,7 +124,7 @@ Feature: Status Desktop community
When the user creates a community named myCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named myCommunity
When the admin creates a community channel named test-channel, with description My description with the method bottom_menu
Then the user lands on the community channel named test-channel
Then the user lands on the channel named test-channel
When the user changes emoji of the current community channel with emoji by description <new_emoji_description>
Then the community channel has emoji <new_emoji>

View File

@ -16,7 +16,7 @@ Feature: Status Desktop Group Chat
| Nervous |
Then the group chat is created
And the group chat history contains "created the group" message
And the group chat title is Athletic&Nervous
And the chat title is Athletic&Nervous
And the group chat contains the following members
| Athletic |
| Nervous |

View File

@ -0,0 +1,55 @@
#******************************************************************************
# Status.im
#*****************************************************************************/
#/**
# * \file test.feature
# *
# * \test Status Desktop - Search flows
# * \date August 2022
# **
# *****************************************************************************/
Feature: Search feature (ctrl+F)
As a user, I want to search the different chats and messages of the app
Covers the search flows
Background:
Given A first time user lands on the status desktop and generates new key
When user signs up with username tester123 and password TesTEr16843/!@00
Then the user lands on the signed in app
When user joins chat room search-automation-test-1
And user joins chat room search-automation-test-2
When the user opens the community portal section
Then the user lands on the community portal section
When the user creates a community named myCommunity, with description My community description, intro Community Intro and outro Community Outro
Then the user lands on the community named myCommunity
When the admin creates a community channel named automation-community, with description My description with the method bottom_menu
Then the user lands on the channel named automation-community
# Go back to the portal so that we see if the search really redirects
When the user opens the community portal section
Scenario: User can search for a community channel
When the user opens the search menu
And the user searches for automation
And the user clicks on the search result for channel automation-community
Then the user lands on the channel named automation-community
Scenario: User can search for a public channel
When the user opens the search menu
And the user searches for automation
And the user clicks on the search result for channel search-automation-test-2
Then the chat title is search-automation-test-2
Scenario: User can search for a message in a public channel
When the user opens the chat section
And user joins chat room search-automation-test-1
Then user is able to send a random chat message
# Go back to the portal so that we see if the search really redirects
When the user opens the community portal section
And the user opens the search menu
And the user searches the random message
Then the search menu shows 1 results
When the user clicks on the search result for the random message
Then the chat title is search-automation-test-1

View File

@ -0,0 +1,10 @@
source(findFile('scripts', 'python/bdd.py'))
setupHooks('../../global_shared/scripts/bdd_hooks.py')
collectStepDefinitions('./steps', '../shared/steps/', '../../global_shared/steps/', '../../suite_onboarding/shared/steps/')
def main():
testSettings.throwOnFailure = True
runFeatureFile('test.feature')