diff --git a/test/ui-test/src/drivers/SquishDriver.py b/test/ui-test/src/drivers/SquishDriver.py index dd0913121d..858b7c53fa 100755 --- a/test/ui-test/src/drivers/SquishDriver.py +++ b/test/ui-test/src/drivers/SquishDriver.py @@ -1,6 +1,6 @@ -#****************************************************************************** +# ****************************************************************************** # Status.im -#*****************************************************************************/ +# *****************************************************************************/ # /** # * \file SquishDriver.py # * @@ -16,7 +16,6 @@ import object import names import test - # The default maximum timeout to find ui object _MAX_WAIT_OBJ_TIMEOUT = 5000 @@ -27,74 +26,84 @@ _MIN_WAIT_OBJ_TIMEOUT = 500 # Waits for the given object is loaded, visible and enabled. # It returns a tuple: True in case it is found. Otherwise, false. And the object itself. def is_loaded_visible_and_enabled(objName, timeout=_MAX_WAIT_OBJ_TIMEOUT): - obj = None - try: - obj = squish.waitForObject(getattr(names, objName), timeout) - return True, obj - except LookupError: - return False, obj + obj = None + try: + obj = squish.waitForObject(getattr(names, objName), timeout) + return True, obj + except LookupError: + return False, obj + # Waits for the given object is loaded and might be not visible and/or not enabled: # It returns a tuple: True in case it is found. Otherwise, false. And the object itself. def is_loaded(objName): - obj = None - try: - obj = squish.findObject(getattr(names, objName)) - return True, obj - except LookupError: - return False, obj + obj = None + try: + obj = squish.findObject(getattr(names, objName)) + return True, obj + except LookupError: + return False, obj -# It checks if the given object is visible and enabled. + +# It checks if the given object is visible and enabled. def is_visible_and_enabled(obj): - return obj.visible and obj.enabled + return obj.visible and obj.enabled + # Given a specific object, get a specific child. def get_child(obj, child_index=None): - if None == child_index: - return object.children(obj) - else: - return object.children(obj)[child_index] + if None == child_index: + return object.children(obj) + else: + return object.children(obj)[child_index] + # It executes the click action into the given object: def click_obj(obj): - try: - squish.mouseClick(obj, squish.Qt.LeftButton) - return True - except LookupError: - return False + try: + squish.mouseClick(obj, squish.Qt.LeftButton) + return True + except LookupError: + return False + # It executes the click action into object with given object name: def click_obj_by_name(objName): - try: - obj = squish.waitForObject(getattr(names, objName)) - squish.mouseClick(obj, squish.Qt.LeftButton) - return True - except LookupError: - return False - + try: + obj = squish.waitForObject(getattr(names, objName)) + squish.mouseClick(obj, squish.Qt.LeftButton) + return True + except LookupError: + return False + def check_obj_by_name(objName): - try: - obj = squish.waitForObject(getattr(names, objName)) - obj.checked = True - return True - except LookupError: - return False + try: + obj = squish.waitForObject(getattr(names, objName)) + obj.checked = True + return True + except LookupError: + return False def is_text_matching(objName, text): - try: - obj = squish.waitForObject(getattr(names, objName)) - test.compare(obj.text, text, "Found the following text " + text) - return True - except LookupError: - return False + try: + obj = squish.waitForObject(getattr(names, objName)) + test.compare(obj.text, text, "Found the following text " + text) + return True + except LookupError: + return False + # It types the specified text into the given object (as if the user had used the keyboard): def type(objName, text): - try: - obj = squish.findObject(getattr(names, objName)) - squish.type(obj, text) - return True - except LookupError: - return False + try: + obj = squish.findObject(getattr(names, objName)) + squish.type(obj, text) + return True + except LookupError: + return False + + +def press_enter(objName): + type(objName, "") diff --git a/test/ui-test/src/screens/StatusChatScreen.py b/test/ui-test/src/screens/StatusChatScreen.py index d1ac75b05b..c988794d2a 100644 --- a/test/ui-test/src/screens/StatusChatScreen.py +++ b/test/ui-test/src/screens/StatusChatScreen.py @@ -5,7 +5,7 @@ # * \file StatusChatScreen.py # * # * \date June 2022 -# * \brief Chat Main Screen. +# * \brief Chat Screen. # *****************************************************************************/ @@ -15,23 +15,17 @@ from drivers.SquishDriverVerification import * class ChatComponents(Enum): - StatusIcon = "statusIcon_StatusIcon_2" - PUBLIC_CHAT_ICON = "mainWindow_dropRectangle_Rectangle" - JOIN_PUBLIC_CHAT = "join_public_chat_StatusMenuItemDelegate" - -class ChatNamePopUp(Enum): - CHAT_NAME_TEXT = "chat_name_PlaceholderText" - + TYPE_A_MESSAGE_PLACE_HOLDER = "scrollView_Type_a_message_PlaceholderText" + MESSAGE_INPUT = "scrollView_messageInputField_TextArea" class StatusChatScreen: def __init__(self): - verify_screen_is_loaded(MainScreenComponents.SEARCH_TEXT_FIELD.value) + verify_screen_is_loaded(ChatComponents.TYPE_A_MESSAGE_PLACE_HOLDER.value) - def joinChatRoom(self, room): - click_obj_by_name(MainScreenComponents.PUBLIC_CHAT_ICON.value) - click_obj_by_name(MainScreenComponents.JOIN_PUBLIC_CHAT.value) - type(ChatNamePopUp.CHAT_NAME_TEXT.value, room) + def sendMessage(self, message): + type(ChatComponents.MESSAGE_INPUT.value, message) + press_enter(ChatComponents.MESSAGE_INPUT.value) diff --git a/test/ui-test/src/screens/StatusMainScreen.py b/test/ui-test/src/screens/StatusMainScreen.py index d721efd5a2..5e03e51b3e 100644 --- a/test/ui-test/src/screens/StatusMainScreen.py +++ b/test/ui-test/src/screens/StatusMainScreen.py @@ -15,25 +15,24 @@ from drivers.SquishDriverVerification import * class MainScreenComponents(Enum): - SEARCH_TEXT_FIELD = "mainWindow_edit_TextEdit" + STATUS_ICON = "mainWindow_statusIcon_StatusIcon_2" PUBLIC_CHAT_ICON = "mainWindow_dropRectangle_Rectangle" JOIN_PUBLIC_CHAT = "join_public_chat_StatusMenuItemDelegate" + class ChatNamePopUp(Enum): CHAT_NAME_TEXT = "chat_name_PlaceholderText" INPUT_ROOM_TOPIC_TEXT = "inputValue_StyledTextField" - + START_CHAT = "start_chat_StatusBaseText" class StatusMainScreen: def __init__(self): - verify_screen_is_loaded(MainScreenComponents.SEARCH_TEXT_FIELD.value) - + verify_screen_is_loaded(MainScreenComponents.STATUS_ICON.value) def joinChatRoom(self, room): - click_obj_by_name(MainScreenComponents.PUBLIC_CHAT_ICON.value) + click_obj_by_name(MainScreenComponents.STATUS_ICON.value) click_obj_by_name(MainScreenComponents.JOIN_PUBLIC_CHAT.value) type(ChatNamePopUp.INPUT_ROOM_TOPIC_TEXT.value, room) - #type(ChatNamePopUp.CHAT_NAME_TEXT.value, room) - + click_obj_by_name(ChatNamePopUp.START_CHAT.value) diff --git a/test/ui-test/testSuites/suite_status/shared/scripts/names.py b/test/ui-test/testSuites/suite_status/shared/scripts/names.py index 62c3de8b45..6c90fe0e0b 100644 --- a/test/ui-test/testSuites/suite_status/shared/scripts/names.py +++ b/test/ui-test/testSuites/suite_status/shared/scripts/names.py @@ -54,3 +54,5 @@ start_chat_StatusBaseText = {"container": statusDesktop_mainWindow_overlay, "tex mainWindow_scrollView_ScrollView = {"container": statusDesktop_mainWindow, "id": "scrollView", "type": "ScrollView", "unnamed": 1, "visible": True} scrollView_messageInputField_TextArea = {"container": mainWindow_scrollView_ScrollView, "id": "messageInputField", "type": "TextArea", "unnamed": 1, "visible": True} reactionImage_SVGImage = {"container": statusDesktop_mainWindow_overlay, "id": "reactionImage", "source": "qrc:/imports/assets/icons/emojiReactions/heart.svg", "type": "SVGImage", "unnamed": 1, "visible": True} +mainWindow_statusIcon_StatusIcon_2 = {"container": statusDesktop_mainWindow, "id": "statusIcon", "source": "qrc:/StatusQ/src/assets/img/icons/public-chat.svg", "type": "StatusIcon", "unnamed": 1, "visible": True} +scrollView_Type_a_message_PlaceholderText = {"container": mainWindow_scrollView_ScrollView, "text": "Type a message.", "type": "PlaceholderText", "unnamed": 1, "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 12ae276db5..c05267cdab 100644 --- a/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py +++ b/test/ui-test/testSuites/suite_status/shared/steps/chatSteps.py @@ -1,7 +1,9 @@ from screens.StatusMainScreen import StatusMainScreen +from screens.StatusChatScreen import StatusChatScreen _statusMain = StatusMainScreen() +_statusChat = StatusChatScreen() @When("user joins chat room |any|") @@ -9,6 +11,8 @@ def step(context, room): _statusMain.joinChatRoom(room) -@Then("user is able to send chat message |any|") -def step(context, message): - StatusMainScreen() \ No newline at end of file +@Then("user is able to send chat message") +def step(context): + table = context.table + for row in table[1:]: + _statusChat.sendMessage(row[0]) \ No newline at end of file diff --git a/test/ui-test/testSuites/suite_status/shared/steps/signUpSteps.py b/test/ui-test/testSuites/suite_status/shared/steps/signUpSteps.py index d51efd67ad..197b0834fb 100644 --- a/test/ui-test/testSuites/suite_status/shared/steps/signUpSteps.py +++ b/test/ui-test/testSuites/suite_status/shared/steps/signUpSteps.py @@ -1,25 +1,24 @@ - from screens.StatusWelcomeScreen import StatusWelcomeScreen from screens.StatusMainScreen import StatusMainScreen -_welcomeScreen = StatusWelcomeScreen() +_welcomeScreen = StatusWelcomeScreen() -@Given("A first time user lands on the status desktop and generates new key") + +@Given("A first time user lands on the status desktop and generates new key") def step(context): _welcomeScreen.agree_terms_conditions_and_generate_new_key() - -@When("user inputs username |any| and password |any|") + +@When("user inputs username |any| and password |any|") def step(context, username, password): _welcomeScreen.input_username_and_password_and_finalize_sign_up(username, password) - -@When("the user inputs username |any|") + +@When("the user inputs username |any|") def step(context, username): _welcomeScreen.input_username(username) - @Then("the user lands on the signed in app") def step(context): - StatusMainScreen() \ No newline at end of file + StatusMainScreen() 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 149fff9a2a..95f0cd3ac6 100644 --- a/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature +++ b/test/ui-test/testSuites/suite_status/tst_ChatFlow/test.feature @@ -10,9 +10,14 @@ Feature: Status Desktop Chat Background: Given A first time user lands on the status desktop and generates new key - When user inputs username tester123 and password TesTEr16843/!@00 + When user inputs username tester123 and password 'TesTEr16843/!@00' Then the user lands on the signed in app Scenario: User joins a room and chats When user joins chat room test - Then user is able to send chat message Hello + Then user is able to send chat message + | message | + | Hello | + | How are you | + | I am from status | + | tell me how you do? | diff --git a/test/ui-test/testSuites/suite_status/tst_case1/test.py b/test/ui-test/testSuites/suite_status/tst_case1/test.py deleted file mode 100644 index 18630346fd..0000000000 --- a/test/ui-test/testSuites/suite_status/tst_case1/test.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- - -import names - - -def main(): - startApplication("nim_status_client") - type(waitForObject(names.loginView_passwordInput), "Tester111//") - type(waitForObject(names.loginView_passwordInput), "") - type(waitForObject(names.loginView_passwordInput), "Tester111//") - type(waitForObject(names.loginView_passwordInput), "") - mouseClick(waitForObject(names.mainWindow_Enter_password_PlaceholderText), Qt.ShiftModifier, Qt.LeftButton) - type(waitForObject(names.loginView_passwordInput), "") - mouseClick(waitForObject(names.mainWindow_dropRectangle_Rectangle), 309, 75, Qt.ShiftModifier + Qt.ControlModifier, Qt.LeftButton) - mouseClick(waitForObject(names.join_public_chat_StatusMenuItemDelegate), 45, 11, Qt.ShiftModifier + Qt.ControlModifier, Qt.LeftButton) - type(waitForObject(names.inputValue_StyledTextField), "test") - mouseClick(waitForObject(names.start_chat_StatusBaseText), Qt.ShiftModifier + Qt.ControlModifier, Qt.LeftButton) - mouseClick(waitForObject(names.mainWindow_dropRectangle_Rectangle), 144, 69, Qt.ShiftModifier + Qt.ControlModifier, Qt.LeftButton) - type(waitForObject(names.edit_TextEdit), "test")