Added sanity tests for message sending verification

This commit is contained in:
yevh-berdnyk 2018-02-14 15:48:18 +02:00 committed by Eric Dvorsak
parent ce34bb4349
commit b228883de5
No known key found for this signature in database
GPG Key ID: 932AC1CE5F05DE0C
10 changed files with 261 additions and 42 deletions

View File

@ -1,3 +1,4 @@
emoji
aiohttp==2.2.3
allpairspy==2.3.0
apipkg==1.4

View File

@ -44,8 +44,7 @@ basic_user['public_key'] = "0x0448243ea6adfd2f825f083a02a1fea11e323a3ba32c9dc999
transaction_users = dict()
transaction_users['A_USER'] = dict()
transaction_users['A_USER']['password'] = "qwerty"
transaction_users['A_USER']['passphrase'] = "pet letter very ozone shop humor " \
"shuffle bounce convince soda hint brave"
transaction_users['A_USER']['passphrase'] = "pet letter very ozone shop humor shuffle bounce convince soda hint brave"
transaction_users['A_USER']['username'] = "Evergreen Handsome Cottontail"
transaction_users['A_USER']['address'] = "67a50ef1d26de6d65dbfbb88172ac1e7017e766d"
@ -53,8 +52,7 @@ transaction_users['A_USER']['public_key'] = "0x040e016b940e067997be8d91298d893ff
"8e771a763d99f60fec70edf637eb6bad9f96d3e8a544168d3ad144f83b4cf7625c"
transaction_users['B_USER'] = dict()
transaction_users['B_USER']['password'] = "qwerty"
transaction_users['B_USER']['passphrase'] = "resemble soap taxi meat reason " \
"inflict dilemma calm warrior key gloom again"
transaction_users['B_USER']['passphrase'] = "resemble soap taxi meat reason inflict dilemma calm warrior key gloom again"
transaction_users['B_USER']['username'] = "Brief Organic Xenops"
transaction_users['B_USER']['address'] = "3d672407a7e1250bbff85b7cfdb456f5015164db"
@ -64,8 +62,7 @@ transaction_users['B_USER']['public_key'] = "0x0406b17e5cdfadb2a05e84508b1a2916d
transaction_users_wallet = dict()
transaction_users_wallet['A_USER'] = dict()
transaction_users_wallet['A_USER']['password'] = "new_unique_password"
transaction_users_wallet['A_USER']['passphrase'] = "kiss catch paper awesome ecology surface " \
"trumpet quit index open stage brave"
transaction_users_wallet['A_USER']['passphrase'] = "kiss catch paper awesome ecology surface trumpet quit index open stage brave"
transaction_users_wallet['A_USER']['username'] = "Impractical Afraid Watermoccasin"
transaction_users_wallet['A_USER']['address'] = "a409e5faf758a5739f334bae186d8bc11c98ea4d"
transaction_users_wallet['A_USER']['public_key'] = "0x04630e0acd973ad448c7a54e2345d6bacaaa4de5a0ec938f802a0f503bf144e" \
@ -73,8 +70,7 @@ transaction_users_wallet['A_USER']['public_key'] = "0x04630e0acd973ad448c7a54e23
transaction_users_wallet['B_USER'] = dict()
transaction_users_wallet['B_USER']['password'] = "new_unique_password"
transaction_users_wallet['B_USER']['passphrase'] = "twenty engine fitness clay faculty supreme " \
"garbage armor broccoli agree end sad"
transaction_users_wallet['B_USER']['passphrase'] = "twenty engine fitness clay faculty supreme garbage armor broccoli agree end sad"
transaction_users_wallet['B_USER']['username'] = "Muffled Purple Milksnake"
transaction_users_wallet['B_USER']['address'] = "5261ceba31e3a7204b498b2dd20220a6057738d1"
transaction_users_wallet['B_USER']['public_key'] = "0x04cd70746f3df6cae7b45c32c211bd7e9e95ed5a1ec470db8f3b1f244eed182" \

View File

@ -60,6 +60,7 @@ class AbstractTestCase:
desired_caps['deviceOrientation'] = "portrait"
desired_caps['commandTimeout'] = 600
desired_caps['idleTimeout'] = 1000
desired_caps['unicodeKeyboard'] = True
return desired_caps
@property
@ -71,7 +72,8 @@ class AbstractTestCase:
desired_caps['appiumVersion'] = '1.7.1'
desired_caps['platformVersion'] = '6.0'
desired_caps['newCommandTimeout'] = 600
desired_caps['fullReset'] = False
desired_caps['fullReset'] = True
desired_caps['unicodeKeyboard'] = True
return desired_caps
@abstractmethod
@ -95,6 +97,12 @@ class AbstractTestCase:
test_data.test_info[test_data.test_name]['jobs'] = list()
test_data.test_info[test_data.test_name]['steps'] = str()
errors = []
def verify_no_errors(self):
if self.errors:
pytest.fail('. '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
class SingleDeviceTestCase(AbstractTestCase):

View File

@ -0,0 +1,172 @@
import random
import string
import pytest
import emoji
from tests.base_test_case import MultipleDeviceTestCase
from views.console_view import ConsoleView
unicode_text_message = '%s%s%s%s %s%s%s%s%s%s%s' % (chr(355), chr(275), chr(353), chr(539), chr(1084), chr(949),
chr(349), chr(353), chr(513), chr(485), chr(283))
unicode_chinese = '%s%s' % (chr(29320), chr(22909))
emoji_name = random.choice(list(emoji.EMOJI_UNICODE))
emoji_unicode = emoji.EMOJI_UNICODE[emoji_name]
emoji_name_1 = random.choice(list(emoji.EMOJI_UNICODE))
emoji_unicode_1 = emoji.EMOJI_UNICODE[emoji_name_1]
message_with_new_line = 'message' '\n' 'with new line'
@pytest.mark.all
@pytest.mark.chat
class TestMessages(MultipleDeviceTestCase):
@pytest.mark.pr
def test_one_to_one_chat_messages_and_delete_chat(self):
self.create_drivers(2)
device_1, device_2 = ConsoleView(self.drivers[0]), ConsoleView(self.drivers[1])
for console in device_1, device_2:
console.create_user()
console.back_button.click()
device_1_home, device_2_home = device_1.get_home_view(), device_2.get_home_view()
device_2_public_key = device_2_home.get_public_key()
device_2_profile = device_2_home.get_profile_view()
device_2_username = device_2_profile.username_text.text
device_1_home.add_contact(device_2_public_key)
device_1_chat = device_1_home.get_chat_view()
message = 'hello'
device_1_chat.chat_message_input.send_keys(message)
device_1_chat.send_message_button.click()
device_2_home.home_button.click()
device_2_home.element_by_text(message, 'button').click()
device_2_chat = device_2_home.get_chat_view()
device_2_chat.chat_message_input.send_keys('~abc~ !@#$%%^&(() *bold*')
device_2_chat.send_message_button.click()
device_1_chat.wait_for_message_in_one_to_one_chat('abc !@#$%%^&(() bold', self.errors)
device_1_chat.chat_message_input.send_keys(unicode_text_message)
device_1_chat.send_message_button.click()
device_2_chat.wait_for_message_in_one_to_one_chat(unicode_text_message, self.errors)
device_2_chat.chat_message_input.send_keys(unicode_chinese)
device_2_chat.send_message_button.click()
device_1_chat.wait_for_message_in_one_to_one_chat(unicode_chinese, self.errors)
device_1_chat.chat_message_input.send_keys(emoji.emojize(emoji_name))
device_1_chat.send_message_button.click()
device_2_chat.wait_for_message_in_one_to_one_chat(emoji_unicode, self.errors)
message_with_emoji = 'message with emoji'
device_2_chat.chat_message_input.send_keys(emoji.emojize('%s %s' % (message_with_emoji, emoji_name_1)))
device_2_chat.send_message_button.click()
device_1_chat.wait_for_message_in_one_to_one_chat('%s %s' % (message_with_emoji, emoji_unicode_1), self.errors)
device_1_chat.send_as_keyevent(message_with_new_line)
device_1_chat.send_message_button.click()
device_2_chat.wait_for_message_in_one_to_one_chat(message_with_new_line, self.errors)
url_message = 'status.im'
device_2_chat.chat_message_input.send_keys(url_message)
device_2_chat.send_message_button.click()
device_1_chat.wait_for_message_in_one_to_one_chat(url_message, self.errors)
if device_1_chat.element_by_text(url_message, 'button').is_element_present():
device_1_chat.element_by_text(url_message, 'button').click()
web_view = device_1_chat.open_in_browser_button.click()
web_view.find_full_text('Browse, chat and make payments securely on the decentralized web.')
device_1_chat.back_button.click()
device_1_chat.chat_options.click()
device_1_chat.delete_chat_button.click()
if not device_1_home.plus_button.is_element_present() or \
device_1_chat.element_by_text_part(device_2_username[:25]).is_element_present():
self.errors.append('Chat was not deleted')
self.verify_no_errors()
@pytest.mark.pr
def test_group_chat_messages(self):
self.create_drivers(3)
device_1, device_2, device_3 = ConsoleView(self.drivers[0]), ConsoleView(self.drivers[1]), \
ConsoleView(self.drivers[2])
for console in device_1, device_2, device_3:
console.create_user()
console.back_button.click()
home_1, home_2, home_3 = device_1.get_home_view(), device_2.get_home_view(), \
device_3.get_home_view()
public_key_2, public_key_3 = home_2.get_public_key(), home_3.get_public_key()
profile_1 = home_1.profile_button.click()
profile_2, profile_3 = home_2.get_profile_view(), home_3.get_profile_view()
username_1, username_2, username_3 = profile_1.username_text.text, profile_2.username_text.text, \
profile_3.username_text.text
for profile in profile_1, profile_2, profile_3:
profile.home_button.click()
for public_key in public_key_2, public_key_3:
home_1.add_contact(public_key)
home_1.back_button.click()
chat_name = 'super_group_chat'
home_1.create_group_chat(sorted([username_2, username_3]), chat_name)
chat_1 = home_1.get_chat_view()
text_message = 'This is text message!'
chat_1.chat_message_input.send_keys(text_message)
chat_1.send_message_button.click()
for home in home_2, home_3:
home.element_by_text(chat_name, 'button').click()
chat_2, chat_3 = home_2.get_chat_view(), home_3.get_chat_view()
for chat in chat_2, chat_3:
chat.wait_for_messages_by_user(username_1, text_message, self.errors)
chat_2.chat_message_input.send_keys(emoji.emojize(emoji_name))
chat_2.send_message_button.click()
for chat in chat_1, chat_3:
chat.wait_for_messages_by_user(username_2, emoji_unicode, self.errors)
message_with_emoji = 'message with emoji'
chat_3.chat_message_input.send_keys(emoji.emojize('%s %s' % (message_with_emoji, emoji_name_1)))
chat_3.send_message_button.click()
for chat in chat_1, chat_2:
chat.wait_for_messages_by_user(username_3, '%s %s' % (message_with_emoji, emoji_unicode_1), self.errors)
chat_1.chat_message_input.send_keys(unicode_text_message)
chat_1.send_message_button.click()
for home in home_2, home_3:
home.element_by_text(chat_name, 'button').click()
chat_2, chat_3 = home_2.get_chat_view(), home_3.get_chat_view()
for chat in chat_2, chat_3:
chat.wait_for_messages_by_user(username_1, unicode_text_message, self.errors)
self.verify_no_errors()
@pytest.mark.pr
def test_public_chat(self):
self.create_drivers(2)
device_1, device_2 = ConsoleView(self.drivers[0]), ConsoleView(self.drivers[1])
users = []
chat_name = ''.join(random.choice(string.ascii_lowercase) for _ in range(7))
for console in device_1, device_2:
console.create_user()
console.back_button.click()
home = console.get_home_view()
profile = home.profile_button.click()
users.append(profile.username_text.text)
profile.home_button.click()
home.join_public_chat(chat_name)
chat_1, chat_2 = device_1.get_chat_view(), device_2.get_chat_view()
messages_to_send_1 = ['/command', '%s %s' % (unicode_text_message, unicode_chinese), 'This is text message.']
for message in messages_to_send_1:
chat_1.chat_message_input.send_keys(message)
chat_1.send_message_button.click()
chat_2.wait_for_messages_by_user(users[0], messages_to_send_1, self.errors)
message_with_emoji = 'message with emoji'
messages_to_send_2 = [emoji.emojize(emoji_name), emoji.emojize('%s %s' % (message_with_emoji, emoji_name_1))]
messages_to_receive_2 = [emoji_unicode, '%s %s' % (message_with_emoji, emoji_unicode_1), message_with_new_line]
for message in messages_to_send_2:
chat_2.chat_message_input.send_keys(message)
chat_2.send_message_button.click()
chat_2.send_as_keyevent(message_with_new_line)
chat_2.send_message_button.click()
chat_1.wait_for_messages_by_user(users[1], messages_to_receive_2, self.errors)
self.verify_no_errors()

View File

@ -1,39 +1,11 @@
import pytest
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from tests import api_requests
from tests.base_test_case import MultipleDeviceTestCase
from tests import transaction_users, get_current_time
from views.console_view import ConsoleView
@pytest.mark.all
class TestMultipleDevices(MultipleDeviceTestCase):
@pytest.mark.chat
def test_one_to_one_chat(self):
self.create_drivers(2)
device_1, device_2 = \
ConsoleView(self.drivers[0]), ConsoleView(self.drivers[1])
for console in device_1, device_2:
console.create_user()
console.back_button.click()
device_1_home, device_2_home = device_1.get_home_view(), device_2.get_home_view()
device_1_public_key = device_1_home.get_public_key()
device_2_home.add_contact(device_1_public_key)
device_2_chat = device_2_home.get_chat_view()
message_1 = 'SOMETHING'
device_2_chat.chat_message_input.send_keys(message_1)
device_2_chat.send_message_button.click()
message_2 = 'another SOMETHING'
device_1_home.home_button.click()
device_1_home.find_full_text(message_1)
device_1_home.element_by_text(message_1, 'button').click()
device_1_chat = device_1_home.get_chat_view()
device_1_chat.chat_message_input.send_keys(message_2)
device_1_chat.send_message_button.click()
device_2_chat.find_full_text(message_2)
@pytest.mark.chat
def test_group_chat_send_receive_messages_and_remove_user(self):
self.create_drivers(2)
device_1, device_2 = \

View File

@ -3,7 +3,7 @@ import base64
import zbarlight
from tests import info
from eth_keys import datatypes
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from selenium.common.exceptions import NoSuchElementException
from PIL import Image
from datetime import datetime
from io import BytesIO
@ -176,7 +176,7 @@ class BaseView(object):
keys = {'0': 7, '1': 8, '2': 9, '3': 10, '4': 11, '5': 12, '6': 13, '7': 14, '8': 15, '9': 16,
',': 55, '-': 69, '+': 81, '.': 56, '/': 76, '\\': 73, ';': 74, ' ': 62,
'[': 71, ']': 72, '=': 70,
'[': 71, ']': 72, '=': 70, '\n': 66,
'a': 29, 'b': 30, 'c': 31, 'd': 32, 'e': 33, 'f': 34, 'g': 35, 'h': 36, 'i': 37, 'j': 38,
'k': 39, 'l': 40, 'm': 41, 'n': 42, 'o': 43, 'p': 44, 'q': 45, 'r': 46, 's': 47, 't': 48,
@ -230,6 +230,10 @@ class BaseView(object):
from views.web_views.base_web_view import BaseWebView
return BaseWebView(self.driver)
def get_profile_view(self):
from views.profile_view import ProfileView
return ProfileView(self.driver)
def get_unique_amount(self):
return '0.0%s' % datetime.now().strftime('%-m%-d%-H%-M%-S').strip('0')

View File

@ -1,4 +1,5 @@
from selenium.common.exceptions import TimeoutException, NoSuchElementException
import time
from selenium.common.exceptions import TimeoutException
from tests import info
from views.base_element import BaseButton, BaseEditBox, BaseText
from views.base_view import BaseView
@ -69,6 +70,13 @@ class MembersButton(BaseButton):
self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="action"])[1]')
class DeleteChatButton(BaseButton):
def __init__(self, driver):
super(DeleteChatButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector('//*[@text="Delete chat"]')
class ChatSettings(BaseButton):
def __init__(self, driver):
super(ChatSettings, self).__init__(driver)
@ -120,6 +128,16 @@ class UserProfileDetails(BaseButton):
self.locator = self.Locator.xpath_selector("//*[@text='Profile']")
class OpenInBrowserButton(BaseButton):
def __init__(self, driver):
super(OpenInBrowserButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Open in browser']")
def navigate(self):
from views.web_views.base_web_view import BaseWebView
return BaseWebView(self.driver)
class ChatView(BaseView):
def __init__(self, driver):
super(ChatView, self).__init__(driver)
@ -134,6 +152,7 @@ class ChatView(BaseView):
self.chat_options = ChatOptions(self.driver)
self.members_button = MembersButton(self.driver)
self.delete_chat_button = DeleteChatButton(self.driver)
self.chat_settings = ChatSettings(self.driver)
self.more_users_button = MoreUsersButton(self.driver)
@ -145,6 +164,7 @@ class ChatView(BaseView):
self.user_profile_icon_top_right = UserProfileIconTopRight(self.driver)
self.user_profile_details = UserProfileDetails(self.driver)
self.open_in_browser_button = OpenInBrowserButton(self.driver)
def wait_for_syncing_complete(self):
info('Waiting for syncing complete:')
@ -155,8 +175,24 @@ class ChatView(BaseView):
except TimeoutException:
break
def get_messages_sent_by_user(self, username):
return MessageByUsername(self.driver, username).find_elements()
def wait_for_message_in_one_to_one_chat(self, expected_message: str, errors: list):
try:
self.find_full_text(expected_message, wait_time=20)
except TimeoutException:
errors.append('Message with text "%s" was not received' % expected_message)
def wait_for_messages_by_user(self, username: str, expected_messages: list, errors: list, wait_time: int = 30):
expected_messages = expected_messages if type(expected_messages) == list else [expected_messages]
repeat = 0
while repeat <= wait_time:
received_messages = [element.text for element in MessageByUsername(self.driver, username).find_elements()]
if not set(expected_messages) - set(received_messages):
break
time.sleep(3)
repeat += 3
if set(expected_messages) - set(received_messages):
errors.append('Not received messages from user %s: "%s"' % (username, ', '.join(
[i for i in list(set(expected_messages) - set(received_messages))])))
def send_eth_to_request(self, request, sender_password):
gas_popup = self.element_by_text_part('Send transaction')

View File

@ -86,6 +86,12 @@ class HomeView(BaseView):
start_new_chat.name_edit_box.send_keys(group_chat_name)
start_new_chat.save_button.click()
def join_public_chat(self, chat_name: str):
start_new_chat = self.plus_button.click()
start_new_chat.join_public_chat_button.click()
start_new_chat.name_edit_box.send_keys(chat_name)
start_new_chat.confirm_button.click()
def get_public_key(self):
profile_view = self.profile_button.click()
profile_view.share_my_contact_key_button.click()

View File

@ -85,6 +85,13 @@ class LogoutButton(BaseButton):
return SignInView(self.driver)
class UserNameText(BaseText):
def __init__(self, driver):
super(UserNameText, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
'//android.widget.ImageView[@content-desc="chat-icon"]/../android.widget.TextView')
class ShareMyContactKeyButton(BaseButton):
def __init__(self, driver):
@ -134,6 +141,7 @@ class ProfileView(BaseView):
# new design
self.username_text = UserNameText(self.driver)
self.share_my_contact_key_button = ShareMyContactKeyButton(self.driver)
self.edit_button = EditButton(self.driver)
self.confirm_button = ConfirmButton(self.driver)

View File

@ -17,6 +17,14 @@ class NewGroupChatButton(BaseButton):
"//android.widget.TextView[@text='Start group chat']")
class JoinPublicChatButton(BaseButton):
def __init__(self, driver):
super(JoinPublicChatButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
"//android.widget.TextView[@text='Join public chat']")
class NameEditBox(BaseEditBox):
def __init__(self, driver):
super(NameEditBox, self).__init__(driver)
@ -38,6 +46,12 @@ class OpenButton(BaseButton):
"//android.widget.TextView[@text='Open']")
class ConfirmButton(BaseButton):
def __init__(self, driver):
super(ConfirmButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[2]')
class EnterUrlEditbox(BaseEditBox):
def __init__(self, driver):
super(EnterUrlEditbox, self).__init__(driver)
@ -50,9 +64,11 @@ class StartNewChatView(ContactsView):
self.add_new_contact = AddNewContactButton(self.driver)
self.new_group_chat_button = NewGroupChatButton(self.driver)
self.join_public_chat_button = JoinPublicChatButton(self.driver)
self.open_d_app_button = OpenDAapButton(self.driver)
self.open_button = OpenButton(self.driver)
self.name_edit_box = NameEditBox(self.driver)
self.enter_url_editbox = EnterUrlEditbox(self.driver)
self.confirm_button = ConfirmButton(self.driver)