feat(@DesktopApp): Basic Chat Scenario (Squish Test)

Ticket: https://github.com/status-im/status-desktop/issues/5718

Include Basic chat Scenario
This commit is contained in:
femi 2022-06-08 00:37:11 +01:00 committed by Olufemi Ade-Olusile
parent 3c81a9dcfc
commit 304fe07214
8 changed files with 97 additions and 104 deletions

View File

@ -1,6 +1,6 @@
#****************************************************************************** # ******************************************************************************
# Status.im # Status.im
#*****************************************************************************/ # *****************************************************************************/
# /** # /**
# * \file SquishDriver.py # * \file SquishDriver.py
# * # *
@ -16,7 +16,6 @@ import object
import names import names
import test import test
# The default maximum timeout to find ui object # The default maximum timeout to find ui object
_MAX_WAIT_OBJ_TIMEOUT = 5000 _MAX_WAIT_OBJ_TIMEOUT = 5000
@ -27,74 +26,84 @@ _MIN_WAIT_OBJ_TIMEOUT = 500
# Waits for the given object is loaded, visible and enabled. # 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. # 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): def is_loaded_visible_and_enabled(objName, timeout=_MAX_WAIT_OBJ_TIMEOUT):
obj = None obj = None
try: try:
obj = squish.waitForObject(getattr(names, objName), timeout) obj = squish.waitForObject(getattr(names, objName), timeout)
return True, obj return True, obj
except LookupError: except LookupError:
return False, obj return False, obj
# Waits for the given object is loaded and might be not visible and/or not enabled: # 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. # It returns a tuple: True in case it is found. Otherwise, false. And the object itself.
def is_loaded(objName): def is_loaded(objName):
obj = None obj = None
try: try:
obj = squish.findObject(getattr(names, objName)) obj = squish.findObject(getattr(names, objName))
return True, obj return True, obj
except LookupError: except LookupError:
return False, obj 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): 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. # Given a specific object, get a specific child.
def get_child(obj, child_index=None): def get_child(obj, child_index=None):
if None == child_index: if None == child_index:
return object.children(obj) return object.children(obj)
else: else:
return object.children(obj)[child_index] return object.children(obj)[child_index]
# It executes the click action into the given object: # It executes the click action into the given object:
def click_obj(obj): def click_obj(obj):
try: try:
squish.mouseClick(obj, squish.Qt.LeftButton) squish.mouseClick(obj, squish.Qt.LeftButton)
return True return True
except LookupError: except LookupError:
return False return False
# It executes the click action into object with given object name: # It executes the click action into object with given object name:
def click_obj_by_name(objName): def click_obj_by_name(objName):
try: try:
obj = squish.waitForObject(getattr(names, objName)) obj = squish.waitForObject(getattr(names, objName))
squish.mouseClick(obj, squish.Qt.LeftButton) squish.mouseClick(obj, squish.Qt.LeftButton)
return True return True
except LookupError: except LookupError:
return False return False
def check_obj_by_name(objName): def check_obj_by_name(objName):
try: try:
obj = squish.waitForObject(getattr(names, objName)) obj = squish.waitForObject(getattr(names, objName))
obj.checked = True obj.checked = True
return True return True
except LookupError: except LookupError:
return False return False
def is_text_matching(objName, text): def is_text_matching(objName, text):
try: try:
obj = squish.waitForObject(getattr(names, objName)) 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 " + text)
return True return True
except LookupError: except LookupError:
return False return False
# It types the specified text into the given object (as if the user had used the keyboard): # It types the specified text into the given object (as if the user had used the keyboard):
def type(objName, text): def type(objName, text):
try: try:
obj = squish.findObject(getattr(names, objName)) obj = squish.findObject(getattr(names, objName))
squish.type(obj, text) squish.type(obj, text)
return True return True
except LookupError: except LookupError:
return False return False
def press_enter(objName):
type(objName, "<Return>")

View File

@ -5,7 +5,7 @@
# * \file StatusChatScreen.py # * \file StatusChatScreen.py
# * # *
# * \date June 2022 # * \date June 2022
# * \brief Chat Main Screen. # * \brief Chat Screen.
# *****************************************************************************/ # *****************************************************************************/
@ -15,23 +15,17 @@ from drivers.SquishDriverVerification import *
class ChatComponents(Enum): class ChatComponents(Enum):
StatusIcon = "statusIcon_StatusIcon_2" TYPE_A_MESSAGE_PLACE_HOLDER = "scrollView_Type_a_message_PlaceholderText"
PUBLIC_CHAT_ICON = "mainWindow_dropRectangle_Rectangle" MESSAGE_INPUT = "scrollView_messageInputField_TextArea"
JOIN_PUBLIC_CHAT = "join_public_chat_StatusMenuItemDelegate"
class ChatNamePopUp(Enum):
CHAT_NAME_TEXT = "chat_name_PlaceholderText"
class StatusChatScreen: class StatusChatScreen:
def __init__(self): 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): def sendMessage(self, message):
click_obj_by_name(MainScreenComponents.PUBLIC_CHAT_ICON.value) type(ChatComponents.MESSAGE_INPUT.value, message)
click_obj_by_name(MainScreenComponents.JOIN_PUBLIC_CHAT.value) press_enter(ChatComponents.MESSAGE_INPUT.value)
type(ChatNamePopUp.CHAT_NAME_TEXT.value, room)

View File

@ -15,25 +15,24 @@ from drivers.SquishDriverVerification import *
class MainScreenComponents(Enum): class MainScreenComponents(Enum):
SEARCH_TEXT_FIELD = "mainWindow_edit_TextEdit" STATUS_ICON = "mainWindow_statusIcon_StatusIcon_2"
PUBLIC_CHAT_ICON = "mainWindow_dropRectangle_Rectangle" PUBLIC_CHAT_ICON = "mainWindow_dropRectangle_Rectangle"
JOIN_PUBLIC_CHAT = "join_public_chat_StatusMenuItemDelegate" JOIN_PUBLIC_CHAT = "join_public_chat_StatusMenuItemDelegate"
class ChatNamePopUp(Enum): class ChatNamePopUp(Enum):
CHAT_NAME_TEXT = "chat_name_PlaceholderText" CHAT_NAME_TEXT = "chat_name_PlaceholderText"
INPUT_ROOM_TOPIC_TEXT = "inputValue_StyledTextField" INPUT_ROOM_TOPIC_TEXT = "inputValue_StyledTextField"
START_CHAT = "start_chat_StatusBaseText"
class StatusMainScreen: class StatusMainScreen:
def __init__(self): def __init__(self):
verify_screen_is_loaded(MainScreenComponents.SEARCH_TEXT_FIELD.value) verify_screen_is_loaded(MainScreenComponents.STATUS_ICON.value)
def joinChatRoom(self, room): 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) click_obj_by_name(MainScreenComponents.JOIN_PUBLIC_CHAT.value)
type(ChatNamePopUp.INPUT_ROOM_TOPIC_TEXT.value, room) type(ChatNamePopUp.INPUT_ROOM_TOPIC_TEXT.value, room)
#type(ChatNamePopUp.CHAT_NAME_TEXT.value, room) click_obj_by_name(ChatNamePopUp.START_CHAT.value)

View File

@ -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} 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} 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} 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}

View File

@ -1,7 +1,9 @@
from screens.StatusMainScreen import StatusMainScreen from screens.StatusMainScreen import StatusMainScreen
from screens.StatusChatScreen import StatusChatScreen
_statusMain = StatusMainScreen() _statusMain = StatusMainScreen()
_statusChat = StatusChatScreen()
@When("user joins chat room |any|") @When("user joins chat room |any|")
@ -9,6 +11,8 @@ def step(context, room):
_statusMain.joinChatRoom(room) _statusMain.joinChatRoom(room)
@Then("user is able to send chat message |any|") @Then("user is able to send chat message")
def step(context, message): def step(context):
StatusMainScreen() table = context.table
for row in table[1:]:
_statusChat.sendMessage(row[0])

View File

@ -1,25 +1,24 @@
from screens.StatusWelcomeScreen import StatusWelcomeScreen from screens.StatusWelcomeScreen import StatusWelcomeScreen
from screens.StatusMainScreen import StatusMainScreen 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): def step(context):
_welcomeScreen.agree_terms_conditions_and_generate_new_key() _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): def step(context, username, password):
_welcomeScreen.input_username_and_password_and_finalize_sign_up(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): def step(context, username):
_welcomeScreen.input_username(username) _welcomeScreen.input_username(username)
@Then("the user lands on the signed in app") @Then("the user lands on the signed in app")
def step(context): def step(context):
StatusMainScreen() StatusMainScreen()

View File

@ -10,9 +10,14 @@ Feature: Status Desktop Chat
Background: Background:
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
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 Then the user lands on the signed in app
Scenario: User joins a room and chats Scenario: User joins a room and chats
When user joins chat room test 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? |

View File

@ -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), "<Return>")
type(waitForObject(names.loginView_passwordInput), "Tester111//")
type(waitForObject(names.loginView_passwordInput), "<Return>")
mouseClick(waitForObject(names.mainWindow_Enter_password_PlaceholderText), Qt.ShiftModifier, Qt.LeftButton)
type(waitForObject(names.loginView_passwordInput), "<Ctrl+V>")
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")