2022-08-05 19:52:34 +00:00
|
|
|
from random import randint
|
2022-11-21 12:56:06 +00:00
|
|
|
import steps.commonInitSteps as init_steps
|
2022-06-07 15:19:52 +00:00
|
|
|
from screens.StatusMainScreen import StatusMainScreen
|
2022-06-07 23:37:11 +00:00
|
|
|
from screens.StatusChatScreen import StatusChatScreen
|
2022-07-20 12:14:50 +00:00
|
|
|
from screens.StatusCreateChatScreen import StatusCreateChatScreen
|
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
# Screen's creation:
|
2022-06-07 15:19:52 +00:00
|
|
|
_statusMain = StatusMainScreen()
|
2022-06-07 23:37:11 +00:00
|
|
|
_statusChat = StatusChatScreen()
|
2022-07-20 12:14:50 +00:00
|
|
|
_statusCreateChatView = StatusCreateChatScreen()
|
2022-06-07 15:19:52 +00:00
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
#########################
|
|
|
|
### PRECONDITIONS region:
|
|
|
|
#########################
|
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Given("the user sends a chat message \"|any|\"")
|
2022-10-13 16:03:10 +00:00
|
|
|
def step(context, message):
|
|
|
|
the_user_sends_a_chat_message(message)
|
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Given("the image \"|any|\" is not unfurled in the chat")
|
2022-10-13 16:03:10 +00:00
|
|
|
def step(context: any, image_link: str):
|
|
|
|
_statusChat.verify_image_unfurled_status(image_link, False)
|
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Given("the user types \"|any|\"")
|
2022-10-13 16:03:10 +00:00
|
|
|
def step(context, message):
|
|
|
|
_statusChat.type_message(message)
|
|
|
|
|
|
|
|
@Given("the user selects the emoji in the suggestion's list")
|
|
|
|
def step(contenxt):
|
|
|
|
_statusChat.select_the_emoji_in_suggestion_list()
|
|
|
|
|
|
|
|
@Given("the user installs the sticker pack at position |any|")
|
|
|
|
def step(context, pack_index):
|
|
|
|
_statusChat.install_sticker_pack(pack_index)
|
|
|
|
|
|
|
|
@Given("the user creates a group chat adding users")
|
2022-08-15 21:01:12 +00:00
|
|
|
def step(context):
|
2022-10-13 16:03:10 +00:00
|
|
|
the_user_creates_a_group_chat_adding_users(context)
|
2022-07-20 12:14:50 +00:00
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@Given("the group chat is created")
|
2022-07-20 12:14:50 +00:00
|
|
|
def step(context):
|
2022-10-13 16:03:10 +00:00
|
|
|
the_group_chat_is_created()
|
2022-10-25 18:39:21 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Given("the user clicks on \"|any|\" chat")
|
2022-07-20 12:14:50 +00:00
|
|
|
def step(context, chatName):
|
|
|
|
_statusMain.open_chat(chatName)
|
2022-08-10 06:57:34 +00:00
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@Given("the user opens the edit group chat popup")
|
2022-09-01 07:53:22 +00:00
|
|
|
def step(context):
|
|
|
|
_statusChat.open_group_chat_edit_popup()
|
2022-08-17 14:47:06 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Given("the user changes the group name to \"|any|\"")
|
2022-09-01 07:53:22 +00:00
|
|
|
def step(context, groupName):
|
|
|
|
_statusChat.group_chat_edit_name(groupName)
|
2022-10-13 16:03:10 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Given("the user changes the group color to \"|any|\"")
|
2022-09-01 07:53:22 +00:00
|
|
|
def step(context, groupColor):
|
|
|
|
_statusChat.group_chat_edit_color(groupColor)
|
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@Given("the user changes the group image")
|
2022-09-01 07:53:22 +00:00
|
|
|
def step(context):
|
|
|
|
_statusChat.group_chat_edit_image(context.userData["fixtures_root"])
|
2022-07-20 12:14:50 +00:00
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@Given("the group chat history contains \"|any|\" message")
|
2022-07-20 12:14:50 +00:00
|
|
|
def step(context, createdTxt):
|
|
|
|
_statusChat.verify_chat_created_message_is_displayed_in_history(createdTxt)
|
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@Given("the group chat contains the following members")
|
|
|
|
def step(context):
|
|
|
|
_statusChat.verify_members_added(context.table)
|
2022-10-25 12:44:28 +00:00
|
|
|
|
|
|
|
@Given("the user opens the chat section")
|
|
|
|
def step(context):
|
|
|
|
the_user_opens_the_chat_section()
|
|
|
|
|
|
|
|
@Given("the user sends a random chat message")
|
|
|
|
def step(context):
|
|
|
|
the_user_sends_a_random_chat_message(context)
|
2022-10-27 12:54:11 +00:00
|
|
|
|
|
|
|
@Given("the user saves changes")
|
|
|
|
def step(context):
|
|
|
|
the_user_saves_changes()
|
|
|
|
|
|
|
|
@Given("the chat title is \"|any|\"")
|
|
|
|
def step(context, title):
|
|
|
|
the_chat_title_is(title)
|
2022-09-01 07:53:22 +00:00
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
#########################
|
|
|
|
### ACTIONS region:
|
|
|
|
#########################
|
2022-09-01 07:53:22 +00:00
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@When("the user opens the chat section")
|
2022-07-20 12:14:50 +00:00
|
|
|
def step(context):
|
2022-10-25 12:44:28 +00:00
|
|
|
the_user_opens_the_chat_section()
|
2022-07-20 12:14:50 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@When("the user sends a chat message \"|any|\"")
|
2022-07-20 12:14:50 +00:00
|
|
|
def step(context, message):
|
2022-10-13 16:03:10 +00:00
|
|
|
the_user_sends_a_chat_message(message)
|
2022-07-28 18:58:19 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@When("the user replies to the message at index |any| with \"|any|\"")
|
2022-07-28 18:58:19 +00:00
|
|
|
def step(context, message_index, message):
|
|
|
|
_statusChat.reply_to_message_at_index(message_index, message)
|
2022-08-12 13:10:20 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@When("the user edits the message at index |any| and changes it to \"|any|\"" )
|
2022-08-12 13:10:20 +00:00
|
|
|
def step(context, message_index, message):
|
|
|
|
_statusChat.edit_message_at_index(message_index, message)
|
2022-10-13 16:03:10 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@When("the user marks the channel \"|any|\" as read")
|
2022-07-28 20:14:29 +00:00
|
|
|
def step(context, channel):
|
2022-08-02 20:04:29 +00:00
|
|
|
_statusMain.mark_as_read(channel)
|
2022-10-13 16:03:10 +00:00
|
|
|
|
|
|
|
@When("the user deletes the message at index |any|")
|
2022-08-02 20:04:29 +00:00
|
|
|
def step(context, message_index):
|
|
|
|
_statusChat.delete_message_at_index(message_index)
|
2022-08-05 19:52:34 +00:00
|
|
|
time.sleep(1)
|
2022-10-13 16:03:10 +00:00
|
|
|
|
|
|
|
@When("the user clears chat history")
|
2022-08-02 20:04:29 +00:00
|
|
|
def step(context):
|
2022-10-13 16:03:10 +00:00
|
|
|
_statusChat.clear_history()
|
2022-08-02 20:04:29 +00:00
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@When("the user sends a GIF message")
|
|
|
|
def step(context):
|
|
|
|
_statusChat.send_gif()
|
2022-08-02 20:04:29 +00:00
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@When("the user presses enter")
|
2022-08-05 19:52:34 +00:00
|
|
|
def step(context):
|
2022-10-13 16:03:10 +00:00
|
|
|
_statusChat.press_enter()
|
2022-08-12 18:42:06 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@When("the user inputs a mention to \"|any|\" with message \"|any|\"")
|
2022-10-13 16:03:10 +00:00
|
|
|
def step(context,displayName,message):
|
|
|
|
_statusChat.send_message_with_mention(displayName, message)
|
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@When("the user sends the emoji \"|any|\" as a message")
|
2022-08-12 18:42:06 +00:00
|
|
|
def step(context, emoji_short_name):
|
|
|
|
_statusChat.send_emoji(emoji_short_name, "")
|
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@When("the user sends the emoji \"|any|\" with message \"|any|\"")
|
2022-08-12 18:42:06 +00:00
|
|
|
def step(context, emoji_short_name, message):
|
|
|
|
_statusChat.send_emoji(emoji_short_name, message)
|
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
# Using position of sticker because stickers don't have ids, only hashes and it feels weird to type hashes in Gherkin
|
|
|
|
@When("the user sends the sticker at position |any| in the list")
|
|
|
|
def step(context, sticker_index):
|
|
|
|
_statusChat.send_sticker(sticker_index)
|
|
|
|
|
|
|
|
@When("the user sends a random chat message")
|
|
|
|
def step(context):
|
2022-10-25 12:44:28 +00:00
|
|
|
the_user_sends_a_random_chat_message(context)
|
2022-10-13 16:03:10 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@When("the user switches to \"|any|\" chat")
|
2022-10-13 16:03:10 +00:00
|
|
|
def step(context, chatName):
|
|
|
|
_statusChat.switch_to_chat(chatName)
|
2022-10-26 17:53:47 +00:00
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@When("the user creates a group chat adding users")
|
|
|
|
def step(context):
|
|
|
|
the_user_creates_a_group_chat_adding_users(context)
|
|
|
|
|
2022-10-26 17:53:47 +00:00
|
|
|
@When("the user creates a one to one chat with \"|any|\"")
|
|
|
|
def step(context, username):
|
|
|
|
_statusMain.open_start_chat_view()
|
|
|
|
_statusCreateChatView.create_chat([[username]])
|
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@When("the user saves changes")
|
|
|
|
def step(context):
|
2022-10-27 12:54:11 +00:00
|
|
|
the_user_saves_changes()
|
2022-10-13 16:03:10 +00:00
|
|
|
|
|
|
|
@When("the user leaves current chat")
|
|
|
|
def step(context):
|
2022-10-26 17:53:47 +00:00
|
|
|
leave_current_chat()
|
2022-10-27 12:54:11 +00:00
|
|
|
|
|
|
|
@When("the user leaves chat \"|any|\" by right click on it")
|
|
|
|
def step(context, chatName: str):
|
|
|
|
_statusMain.leave_chat(chatName)
|
2022-08-12 18:42:06 +00:00
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
#########################
|
|
|
|
### VERIFICATIONS region:
|
|
|
|
#########################
|
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Then("the last chat message contains \"|any|\"")
|
2022-08-12 18:42:06 +00:00
|
|
|
def step(context, message):
|
|
|
|
_statusChat.verify_last_message_sent(message)
|
2022-08-11 19:16:59 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Then("the chat message \"|any|\" is displayed as a reply")
|
2022-10-13 16:03:10 +00:00
|
|
|
def step(context, message):
|
2022-11-15 14:58:11 +00:00
|
|
|
_statusChat.verify_last_message_is_reply(message)
|
|
|
|
|
|
|
|
@Then("the chat message \"|any|\" is displayed as a reply of \"|any|\"")
|
|
|
|
def step(context, reply, message):
|
|
|
|
_statusChat.verify_last_message_is_reply_to(reply, message)
|
|
|
|
|
|
|
|
@Then("the chat message \"|any|\" is displayed as a reply of this user's \"|any|\"")
|
|
|
|
def step(context, reply, message):
|
|
|
|
_statusChat.verify_last_message_is_reply_to_loggedin_user_message(reply, message)
|
2022-10-13 16:03:10 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Then("the chat message \"|any|\" is displayed as an edited one")
|
2022-10-13 16:03:10 +00:00
|
|
|
def step(context, message):
|
|
|
|
_statusChat.verify_last_message_sent(message)
|
2022-11-16 12:57:43 +00:00
|
|
|
_statusChat.verify_last_message_is_edited(message)
|
2022-10-13 16:03:10 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Then("the last message displayed is not \"|any|\"")
|
2022-10-13 16:03:10 +00:00
|
|
|
def step(context, message):
|
|
|
|
_statusChat.verify_last_message_sent_is_not(message)
|
|
|
|
|
|
|
|
@Then("the chat is cleared")
|
|
|
|
def step(context):
|
|
|
|
_statusChat.verify_last_message_is_not_loaded()
|
|
|
|
|
|
|
|
@Then("the GIF message is displayed")
|
|
|
|
def step(context):
|
2022-11-30 09:20:25 +00:00
|
|
|
_statusChat.verify_last_message_sent("tenor.com")
|
2022-10-13 16:03:10 +00:00
|
|
|
|
|
|
|
@Then("the image |any| is unfurled in the chat")
|
|
|
|
def step(context: any, image_link: str):
|
|
|
|
_statusChat.verify_image_unfurled_status(image_link, True)
|
|
|
|
|
|
|
|
@Then("the user cannot delete the last message")
|
|
|
|
def step(context):
|
|
|
|
_statusChat.cannot_delete_last_message()
|
2022-08-11 19:16:59 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Then("the \"|any|\" mention with message \"|any|\" have been sent")
|
2022-10-13 16:03:10 +00:00
|
|
|
def step(context,displayName,message):
|
|
|
|
_statusChat.verify_last_message_sent_contains_mention(displayName, message)
|
2022-08-11 19:16:59 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Then("the user cannot input a mention to a not existing user \"|any|\"")
|
2022-08-10 06:57:34 +00:00
|
|
|
def step(context, displayName):
|
|
|
|
_statusChat.cannot_do_mention(displayName)
|
2022-10-13 16:03:10 +00:00
|
|
|
|
|
|
|
@Then("the last chat message is a sticker")
|
|
|
|
def step(context):
|
|
|
|
_statusChat.verify_last_message_is_sticker()
|
2022-08-10 06:57:34 +00:00
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@Then("the user chats are sorted accordingly")
|
2022-08-18 07:27:57 +00:00
|
|
|
def step(context):
|
|
|
|
table = context.table
|
|
|
|
for i, row in enumerate(table):
|
|
|
|
chatName = row[0]
|
|
|
|
_statusChat.verify_chat_order(i, chatName)
|
|
|
|
|
2022-10-13 16:03:10 +00:00
|
|
|
@Then("the random chat message is displayed")
|
|
|
|
def step(context):
|
|
|
|
message = context.userData["randomMessage"]
|
|
|
|
_statusChat.verify_last_message_sent(message)
|
|
|
|
|
|
|
|
@Then("the group chat is created")
|
|
|
|
def step(context):
|
|
|
|
the_group_chat_is_created()
|
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Then("the chat title is \"|any|\"")
|
2022-10-13 16:03:10 +00:00
|
|
|
def step(context, title):
|
2022-10-27 12:54:11 +00:00
|
|
|
the_chat_title_is(title)
|
2022-09-01 07:53:22 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Then("the chat color is \"|any|\"")
|
2022-10-13 16:03:10 +00:00
|
|
|
def step(context, color):
|
|
|
|
_statusChat.verify_chat_color(color)
|
|
|
|
|
|
|
|
@Then("the chat image is changed")
|
2022-09-01 07:53:22 +00:00
|
|
|
def step(context):
|
2022-10-13 16:03:10 +00:00
|
|
|
_statusChat.verify_chat_image(context.userData["fixtures_root"])
|
2022-09-01 07:53:22 +00:00
|
|
|
|
2022-10-19 10:39:48 +00:00
|
|
|
@Then("the chat \"|any|\" does not exist")
|
2022-09-01 07:53:22 +00:00
|
|
|
def step(context, chatName):
|
|
|
|
_statusMain.verify_chat_does_not_exist(chatName)
|
2022-10-13 16:03:10 +00:00
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
### COMMON methods used in different steps given/when/then region:
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
def the_user_sends_a_chat_message(message: str):
|
|
|
|
_statusChat.send_message(message)
|
|
|
|
|
|
|
|
def the_user_creates_a_group_chat_adding_users(context: any):
|
|
|
|
_statusMain.open_start_chat_view()
|
|
|
|
_statusCreateChatView.create_chat(context.table)
|
|
|
|
|
|
|
|
def the_group_chat_is_created():
|
2022-10-25 12:44:28 +00:00
|
|
|
_statusChat = StatusChatScreen()
|
|
|
|
|
|
|
|
def the_user_opens_the_chat_section():
|
2022-11-21 12:56:06 +00:00
|
|
|
init_steps.the_user_opens_the_chat_section()
|
2022-10-25 12:44:28 +00:00
|
|
|
|
|
|
|
def the_user_sends_a_random_chat_message(context):
|
|
|
|
random_int = randint(0, 10000)
|
|
|
|
message = "random message " + str(random_int)
|
|
|
|
_statusChat.send_message(message)
|
2022-10-26 17:53:47 +00:00
|
|
|
context.userData["randomMessage"] = message
|
|
|
|
|
|
|
|
def leave_current_chat():
|
|
|
|
_statusChat.leave_chat()
|
2022-10-27 12:54:11 +00:00
|
|
|
|
|
|
|
def the_user_saves_changes():
|
|
|
|
_statusChat.group_chat_edit_save()
|
|
|
|
|
|
|
|
def the_chat_title_is(title: str):
|
|
|
|
_statusChat.verify_chat_title(title)
|