Added atomic tests for chats and sigh in
Signed-off-by: yevh-berdnyk <ie.berdnyk@gmail.com>
This commit is contained in:
parent
73dab568ff
commit
8bf083cf88
|
@ -0,0 +1,46 @@
|
|||
from tests import marks, transaction_users, common_password
|
||||
from tests.base_test_case import MultipleDeviceTestCase
|
||||
from views.sign_in_view import SignInView
|
||||
|
||||
|
||||
@marks.chat
|
||||
@marks.transaction
|
||||
class TestCommands(MultipleDeviceTestCase):
|
||||
|
||||
@marks.skip
|
||||
@marks.testrail_case_id(3697)
|
||||
def test_network_mismatch_for_send_request_commands(self):
|
||||
recipient = transaction_users['C_USER']
|
||||
sender = self.senders['d_user'] = transaction_users['D_USER']
|
||||
self.create_drivers(2)
|
||||
device_1_sign_in, device_2_sign_in = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
||||
for user_details in (sender, device_1_sign_in), (recipient, device_2_sign_in):
|
||||
user_details[1].recover_access(passphrase=user_details[0]['passphrase'],
|
||||
password=user_details[0]['password'])
|
||||
device_1_home, device_2_home = device_1_sign_in.get_home_view(), device_2_sign_in.get_home_view()
|
||||
|
||||
device_2_profile = device_2_home.profile_button.click()
|
||||
device_2_profile.switch_network('Mainnet with upstream RPC')
|
||||
device_2_sign_in.click_account_by_position(0)
|
||||
device_2_sign_in.sign_in()
|
||||
|
||||
device_1_chat = device_1_home.add_contact(recipient['public_key'])
|
||||
amount_1 = device_1_chat.get_unique_amount()
|
||||
device_1_chat.send_transaction_in_1_1_chat(amount_1, common_password, wallet_set_up=True)
|
||||
assert device_1_chat.chat_element_by_text(amount_1).status.text == 'Sent'
|
||||
|
||||
device_2_chat = device_2_home.get_chat_with_user(sender['username']).click()
|
||||
chat_element_1 = device_2_chat.chat_element_by_text(amount_1)
|
||||
chat_element_1.wait_for_visibility_of_element(120)
|
||||
assert chat_element_1.status.text == 'Network mismatch'
|
||||
assert chat_element_1.contains_text('On testnet')
|
||||
|
||||
amount_2 = device_1_chat.get_unique_amount()
|
||||
device_1_chat.request_transaction_in_1_1_chat(amount_2)
|
||||
assert device_1_chat.chat_element_by_text(amount_2).status.text == 'Sent'
|
||||
|
||||
chat_element_2 = device_2_chat.chat_element_by_text(amount_2)
|
||||
chat_element_2.wait_for_visibility_of_element(120)
|
||||
assert chat_element_2.status.text == 'Network mismatch'
|
||||
assert chat_element_2.contains_text('On testnet')
|
||||
assert chat_element_2.contains_text('Transaction Request')
|
|
@ -0,0 +1,147 @@
|
|||
import random
|
||||
import string
|
||||
|
||||
import pytest
|
||||
|
||||
from tests import marks, get_current_time
|
||||
from tests.base_test_case import MultipleDeviceTestCase
|
||||
from views.sign_in_view import SignInView
|
||||
|
||||
|
||||
@marks.all
|
||||
@marks.chat
|
||||
class TestMessagesOneToOneChat(MultipleDeviceTestCase):
|
||||
|
||||
@marks.skip
|
||||
@marks.testrail_case_id(764)
|
||||
def test_text_message_1_1_chat(self):
|
||||
self.create_drivers(2)
|
||||
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
||||
for sign_in in device_1, device_2:
|
||||
sign_in.create_user()
|
||||
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_home.home_button.click()
|
||||
|
||||
device_1_chat = device_1_home.add_contact(device_2_public_key)
|
||||
|
||||
message = 'hello'
|
||||
device_1_chat.chat_message_input.send_keys(message)
|
||||
device_1_chat.send_message_button.click()
|
||||
|
||||
device_2_home.element_by_text(message, 'button').click()
|
||||
|
||||
if device_1_chat.chat_element_by_text(message).status.text != 'Seen':
|
||||
pytest.fail("'Seen' status is shown under the sent text message")
|
||||
|
||||
@marks.skip
|
||||
@marks.testrail_case_id(772)
|
||||
def test_offline_messaging_1_1_chat(self):
|
||||
self.create_drivers(2, offline_mode=True)
|
||||
device_1, device_2 = self.drivers[0], self.drivers[1]
|
||||
sign_in_1, sign_in_2 = SignInView(device_1), SignInView(device_2)
|
||||
sign_in_1.create_user()
|
||||
username_2 = sign_in_2.create_user()
|
||||
home_1, home_2 = sign_in_1.get_home_view(), sign_in_2.get_home_view()
|
||||
public_key_1 = home_1.get_public_key()
|
||||
home_1.home_button.click()
|
||||
|
||||
device_1.set_network_connection(1) # airplane mode on primary device
|
||||
|
||||
chat_2 = home_2.add_contact(public_key_1)
|
||||
message_1 = 'test message'
|
||||
chat_2.chat_message_input.send_keys(message_1)
|
||||
chat_2.send_message_button.click()
|
||||
device_2.set_network_connection(1) # airplane mode on secondary device
|
||||
|
||||
device_1.set_network_connection(2) # turning on WiFi connection on primary device
|
||||
|
||||
chat_element = home_1.get_chat_with_user(username_2)
|
||||
chat_element.wait_for_visibility_of_element(20)
|
||||
chat_1 = chat_element.click()
|
||||
chat_1.chat_element_by_text(message_1).wait_for_visibility_of_element(2)
|
||||
|
||||
device_2.set_network_connection(2) # turning on WiFi connection on secondary device
|
||||
device_1.set_network_connection(1) # airplane mode on primary device
|
||||
|
||||
chat_2.element_by_text('Connecting to peers...').wait_for_invisibility_of_element(60)
|
||||
message_2 = 'one more message'
|
||||
chat_2.chat_message_input.send_keys(message_2)
|
||||
chat_2.send_message_button.click()
|
||||
|
||||
device_1.set_network_connection(2) # turning on WiFi connection on primary device
|
||||
|
||||
chat_1 = chat_element.click()
|
||||
chat_1.chat_element_by_text(message_2).wait_for_visibility_of_element(180)
|
||||
|
||||
@marks.testrail_case_id(3701)
|
||||
def test_resend_message_offline(self):
|
||||
self.create_drivers(2, offline_mode=True)
|
||||
device_1, device_2 = self.drivers[0], self.drivers[1]
|
||||
sign_in_1, sign_in_2 = SignInView(device_1), SignInView(device_2)
|
||||
username_1 = 'user_%s' % get_current_time()
|
||||
sign_in_1.create_user(username_1)
|
||||
sign_in_2.create_user()
|
||||
home_1, home_2 = sign_in_1.get_home_view(), sign_in_2.get_home_view()
|
||||
public_key_2 = home_2.get_public_key()
|
||||
home_2.home_button.click()
|
||||
|
||||
device_1.set_network_connection(1) # airplane mode on primary device
|
||||
|
||||
chat_1 = home_1.add_contact(public_key_2)
|
||||
message = 'test message'
|
||||
chat_1.chat_message_input.send_keys(message)
|
||||
chat_1.send_message_button.click()
|
||||
progress_time = chat_1.chat_element_by_text(message).progress_bar.measure_time_while_element_is_shown()
|
||||
if not 9 < progress_time < 11:
|
||||
self.errors.append('Progress indicator is shown during %s seconds' % progress_time)
|
||||
|
||||
device_1.set_network_connection(2) # turning on WiFi connection
|
||||
|
||||
chat_1.element_by_text('Not sent. Tap for options').click()
|
||||
if not chat_1.element_by_text('Delete message').is_element_displayed():
|
||||
self.errors.append("'Delete message' button is not shown for not sent message")
|
||||
|
||||
chat_1.connection_status.wait_for_invisibility_of_element(60)
|
||||
chat_1.element_by_text('Resend').click()
|
||||
if chat_1.chat_element_by_text(message).status.text != 'Sent':
|
||||
self.errors.append("Message status is not 'Sent' after resending the message")
|
||||
|
||||
chat_2 = home_2.get_chat_with_user(username_1).click()
|
||||
if not chat_2.chat_element_by_text(message).is_element_displayed(10):
|
||||
self.errors.append("Message with text '%s' is not received" % message)
|
||||
|
||||
self.verify_no_errors()
|
||||
|
||||
@marks.testrail_case_id(3710)
|
||||
def test_messaging_in_different_networks(self):
|
||||
self.create_drivers(2, offline_mode=True)
|
||||
device_1, device_2 = self.drivers[0], self.drivers[1]
|
||||
sign_in_1, sign_in_2 = SignInView(device_1), SignInView(device_2)
|
||||
username_1 = 'user_%s' % get_current_time()
|
||||
sign_in_1.create_user(username_1)
|
||||
sign_in_2.create_user()
|
||||
home_1, home_2 = sign_in_1.get_home_view(), sign_in_2.get_home_view()
|
||||
public_key_2 = home_2.get_public_key()
|
||||
profile_2 = home_2.get_profile_view()
|
||||
profile_2.switch_network('Mainnet with upstream RPC')
|
||||
sign_in_2.click_account_by_position(0)
|
||||
sign_in_2.sign_in()
|
||||
|
||||
chat_1 = home_1.add_contact(public_key_2)
|
||||
message = 'test message'
|
||||
chat_1.chat_message_input.send_keys(message)
|
||||
chat_1.send_message_button.click()
|
||||
|
||||
chat_2 = home_2.get_chat_with_user(username_1).click()
|
||||
chat_2.chat_element_by_text(message).wait_for_visibility_of_element()
|
||||
|
||||
public_chat_name = ''.join(random.choice(string.ascii_lowercase) for _ in range(7))
|
||||
chat_1.get_back_to_home_view()
|
||||
home_1.join_public_chat(public_chat_name)
|
||||
chat_2.get_back_to_home_view()
|
||||
home_2.join_public_chat(public_chat_name)
|
||||
|
||||
chat_1.chat_message_input.send_keys(message)
|
||||
chat_1.send_message_button.click()
|
||||
chat_2.chat_element_by_text(message).wait_for_visibility_of_element()
|
|
@ -0,0 +1,33 @@
|
|||
import random
|
||||
import string
|
||||
|
||||
from tests import marks
|
||||
from tests.base_test_case import MultipleDeviceTestCase
|
||||
from views.sign_in_view import SignInView
|
||||
|
||||
|
||||
@marks.chat
|
||||
class TestMessagesPublicChat(MultipleDeviceTestCase):
|
||||
|
||||
@marks.skip
|
||||
@marks.testrail_case_id(1383)
|
||||
def test_public_chat(self):
|
||||
self.create_drivers(2)
|
||||
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
||||
users = list()
|
||||
chats = list()
|
||||
chat_name = ''.join(random.choice(string.ascii_lowercase) for _ in range(7))
|
||||
for sign_in in device_1, device_2:
|
||||
users.append(sign_in.create_user())
|
||||
home = sign_in.get_home_view()
|
||||
chats.append(home.join_public_chat(chat_name))
|
||||
chat_1, chat_2 = chats[0], chats[1]
|
||||
|
||||
if chat_1.connection_status.text != 'Fetching messages...':
|
||||
self.errors.append("'Fetching messages...' status is not shown")
|
||||
|
||||
message = 'hello'
|
||||
chat_1.chat_message_input.send_keys(message)
|
||||
chat_1.send_message_button.click()
|
||||
|
||||
chat_2.verify_message_is_under_today_text(message, self.errors)
|
|
@ -0,0 +1,24 @@
|
|||
from tests import marks
|
||||
from tests.base_test_case import MultipleDeviceTestCase
|
||||
from views.sign_in_view import SignInView
|
||||
|
||||
|
||||
@marks.all
|
||||
@marks.sign_in
|
||||
class TestSignIn(MultipleDeviceTestCase):
|
||||
|
||||
@marks.testrail_case_id(1432)
|
||||
def test_offline_login(self):
|
||||
self.create_drivers(1, offline_mode=True)
|
||||
driver = self.drivers[0]
|
||||
sign_in = SignInView(driver)
|
||||
sign_in.create_user()
|
||||
|
||||
driver.close_app()
|
||||
driver.set_network_connection(1) # airplane mode
|
||||
|
||||
driver.launch_app()
|
||||
sign_in.accept_agreements()
|
||||
home = sign_in.sign_in()
|
||||
home.home_button.wait_for_visibility_of_element()
|
||||
assert home.connection_status.text == 'Offline'
|
|
@ -10,4 +10,5 @@ chat_management = pytest.mark.chat_management
|
|||
message_reliability = pytest.mark.message_reliability
|
||||
transaction = pytest.mark.transaction
|
||||
wallet = pytest.mark.wallet
|
||||
sign_in = pytest.mark.sign_in
|
||||
skip = pytest.mark.skip
|
||||
|
|
|
@ -290,10 +290,10 @@ class TestOfflineMessages(MultipleDeviceTestCase):
|
|||
sign_in_2.click_account_by_position(0)
|
||||
sign_in_2.sign_in()
|
||||
sign_in_2.home_button.wait_for_visibility_of_element()
|
||||
if not home_2.offline_label.is_element_displayed():
|
||||
if home_2.connection_status.text != 'Offline':
|
||||
self.errors.append('Offline label is not shown on Home view while being offline')
|
||||
chat_2 = home_2.get_chat_with_user(username_1).click()
|
||||
if not chat_2.offline_label.is_element_displayed():
|
||||
if chat_2.connection_status.text != 'Offline':
|
||||
self.errors.append('Offline label is not shown on Chat view while being offline')
|
||||
device_2.set_network_connection(2) # turning on WiFi connection
|
||||
chat_2.wait_for_message_in_one_to_one_chat(message_text, self.errors, wait_time=120)
|
||||
|
@ -326,10 +326,10 @@ class TestOfflineMessages(MultipleDeviceTestCase):
|
|||
chat_element_2.wait_for_visibility_of_element()
|
||||
device_2.set_network_connection(1) # airplane mode
|
||||
|
||||
if not home_2.offline_label.is_element_displayed():
|
||||
if home_2.connection_status.text != 'Offline':
|
||||
self.errors.append('Offline label is not shown on Home view while being offline')
|
||||
chat_2 = chat_element_2.click()
|
||||
if not chat_2.offline_label.is_element_displayed():
|
||||
if chat_2.connection_status.text != 'Offline':
|
||||
self.errors.append('Offline label is not shown on Chat view while being offline')
|
||||
|
||||
message_text = 'test message'
|
||||
|
|
|
@ -3,6 +3,8 @@ from io import BytesIO
|
|||
import os
|
||||
|
||||
import time
|
||||
from timeit import timeit
|
||||
|
||||
from PIL import Image, ImageChops
|
||||
from appium.webdriver.common.mobileby import MobileBy
|
||||
from appium.webdriver.common.touch_action import TouchAction
|
||||
|
@ -153,6 +155,16 @@ class BaseElement(object):
|
|||
action = TouchAction(self.driver)
|
||||
action.long_press(element).release().perform()
|
||||
|
||||
def measure_time_before_element_appears(self, max_wait_time=30):
|
||||
def wrapper():
|
||||
return self.wait_for_visibility_of_element(max_wait_time)
|
||||
return timeit(wrapper, number=1)
|
||||
|
||||
def measure_time_while_element_is_shown(self, max_wait_time=30):
|
||||
def wrapper():
|
||||
return self.wait_for_invisibility_of_element(max_wait_time)
|
||||
return timeit(wrapper, number=1)
|
||||
|
||||
|
||||
class BaseEditBox(BaseElement):
|
||||
|
||||
|
|
|
@ -146,10 +146,11 @@ class SendMessageButton(BaseButton):
|
|||
info('Tap on %s' % self.name)
|
||||
|
||||
|
||||
class OfflineLabelText(BaseText):
|
||||
class ConnectionStatusText(BaseText):
|
||||
def __init__(self, driver):
|
||||
super(OfflineLabelText, self).__init__(driver)
|
||||
self.locator = self.Locator.text_selector('Offline')
|
||||
super(ConnectionStatusText, self).__init__(driver)
|
||||
self.locator = self.Locator.xpath_selector(
|
||||
"//*[@content-desc='connection-status-text']/android.widget.TextView")
|
||||
|
||||
|
||||
class BaseView(object):
|
||||
|
@ -172,7 +173,7 @@ class BaseView(object):
|
|||
self.save_button = SaveButton(self.driver)
|
||||
self.done_button = DoneButton(self.driver)
|
||||
self.delete_button = DeleteButton(self.driver)
|
||||
self.offline_label = OfflineLabelText(self.driver)
|
||||
self.connection_status = ConnectionStatusText(self.driver)
|
||||
|
||||
self.apps_button = AppsButton(self.driver)
|
||||
self.status_app_icon = StatusAppIcon(self.driver)
|
||||
|
@ -186,8 +187,9 @@ class BaseView(object):
|
|||
|
||||
def accept_agreements(self):
|
||||
iterations = int()
|
||||
from views.sign_in_view import CreateAccountButton
|
||||
while iterations <= 3 and not CreateAccountButton(self.driver).is_element_displayed():
|
||||
from views.sign_in_view import CreateAccountButton, PasswordInput
|
||||
while iterations <= 3 and not (CreateAccountButton(self.driver).is_element_displayed() or PasswordInput(
|
||||
self.driver).is_element_displayed()):
|
||||
for button in self.ok_button, self.continue_button:
|
||||
try:
|
||||
button.wait_for_element(15)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import time
|
||||
from selenium.common.exceptions import TimeoutException
|
||||
from tests import info
|
||||
from views.base_element import BaseButton, BaseEditBox, BaseText
|
||||
from views.base_element import BaseButton, BaseEditBox, BaseText, BaseElement
|
||||
from views.base_view import BaseView
|
||||
from views.profile_view import ProfilePictureElement
|
||||
|
||||
|
@ -194,6 +194,37 @@ class SendRequestButton(BaseButton):
|
|||
self.locator = self.Locator.xpath_selector('//*[contains(@text, "%s.ETH")]/../*[@text="Send"]' % amount)
|
||||
|
||||
|
||||
class ChatElementByText(BaseText):
|
||||
def __init__(self, driver, text):
|
||||
super(ChatElementByText, self).__init__(driver)
|
||||
self.locator = self.Locator.xpath_selector(
|
||||
"//*[starts-with(@text,'%s')]/ancestor::android.view.ViewGroup[@content-desc='chat-item']" % text)
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
class StatusText(BaseText):
|
||||
def __init__(self, driver, parent_locator: str):
|
||||
super(StatusText, self).__init__(driver)
|
||||
self.locator = self.Locator.xpath_selector(parent_locator + '/android.widget.TextView')
|
||||
|
||||
return StatusText(self.driver, self.locator.value)
|
||||
|
||||
@property
|
||||
def progress_bar(self):
|
||||
class ProgressBar(BaseElement):
|
||||
def __init__(self, driver, parent_locator: str):
|
||||
super(ProgressBar, self).__init__(driver)
|
||||
self.locator = self.Locator.xpath_selector(parent_locator + '//android.widget.ProgressBar')
|
||||
|
||||
return ProgressBar(self.driver, self.locator.value)
|
||||
|
||||
def contains_text(self, text) -> bool:
|
||||
element = BaseText(self.driver)
|
||||
element.locator = element.Locator.xpath_selector("//android.view.ViewGroup//android.widget.TextView[@text='%s']"
|
||||
% text)
|
||||
return element.is_element_displayed()
|
||||
|
||||
|
||||
class ChatView(BaseView):
|
||||
def __init__(self, driver):
|
||||
super(ChatView, self).__init__(driver)
|
||||
|
@ -244,7 +275,8 @@ class ChatView(BaseView):
|
|||
|
||||
def wait_for_message_in_one_to_one_chat(self, expected_message: str, errors: list, wait_time: int = 20):
|
||||
try:
|
||||
self.wait_for_element_starts_with_text(expected_message, wait_time=wait_time)
|
||||
element = ChatElementByText(self.driver, expected_message)
|
||||
element.wait_for_element(wait_time)
|
||||
except TimeoutException:
|
||||
errors.append('Message with text "%s" was not received' % expected_message)
|
||||
|
||||
|
@ -341,7 +373,14 @@ class ChatView(BaseView):
|
|||
|
||||
def chat_element_by_text(self, text):
|
||||
info("Looking for full text: '%s'" % text)
|
||||
element = self.element_types['text'](self.driver)
|
||||
element.locator = element.Locator.xpath_selector(
|
||||
"//*[@content-desc='chat-item']//*[starts-with(@text,'%s')]" % text)
|
||||
return element
|
||||
return ChatElementByText(self.driver, text)
|
||||
|
||||
def verify_message_is_under_today_text(self, text, errors):
|
||||
message_element = self.chat_element_by_text(text)
|
||||
message_element.wait_for_visibility_of_element()
|
||||
message_location = message_element.find_element().location['y']
|
||||
today_text_element = self.element_by_text('Today').find_element()
|
||||
today_location = today_text_element.location['y']
|
||||
today_height = today_text_element.size['height']
|
||||
if message_location < today_location + today_height:
|
||||
errors.append("Message '%s' is not uder 'Today' text" % text)
|
||||
|
|
|
@ -94,6 +94,7 @@ class HomeView(BaseView):
|
|||
start_new_chat.confirm()
|
||||
one_to_one_chat = self.get_chat_view()
|
||||
one_to_one_chat.chat_message_input.wait_for_element(60)
|
||||
return one_to_one_chat
|
||||
|
||||
def start_1_1_chat(self, username):
|
||||
start_new_chat = self.plus_button.click()
|
||||
|
@ -119,6 +120,8 @@ class HomeView(BaseView):
|
|||
start_new_chat.chat_name_editbox.send_keys(chat_name)
|
||||
time.sleep(2)
|
||||
start_new_chat.confirm()
|
||||
from views.chat_view import ChatView
|
||||
return ChatView(self.driver)
|
||||
|
||||
def get_public_key(self):
|
||||
profile_view = self.profile_button.click()
|
||||
|
|
|
@ -2,6 +2,7 @@ from tests import get_current_time, common_password
|
|||
from views.base_element import BaseButton, BaseEditBox
|
||||
from views.base_view import BaseView
|
||||
|
||||
|
||||
class AccountButton(BaseButton):
|
||||
|
||||
def __init__(self, driver):
|
||||
|
@ -137,7 +138,7 @@ class SignInView(BaseView):
|
|||
|
||||
def sign_in(self, password=common_password):
|
||||
self.password_input.set_value(password)
|
||||
self.sign_in_button.click()
|
||||
return self.sign_in_button.click()
|
||||
|
||||
def click_account_by_position(self, position: int):
|
||||
self.account_button.find_elements()[position].click()
|
||||
|
|
Loading…
Reference in New Issue