Add appium test about deleting 1-1 chat
This commit is contained in:
parent
2d1f8989a9
commit
d9755f546d
|
@ -96,6 +96,22 @@ transaction_users['F_USER']['address'] = "08fee8015ec71d78b1855937988d5bf45892bc
|
|||
transaction_users['F_USER']['public_key'] = "0x0445284807c9fb9080cec6f1bd24f8d546c5c2c0dd2d06bdbf91d1af70507885" \
|
||||
"1b9ee0d3bb04736abd00f5a8dce2f20a579a437ee3bea9920eefba7fa46266f8df"
|
||||
|
||||
transaction_users['G_USER'] = dict()
|
||||
transaction_users['G_USER']['password'] = 'qwerty'
|
||||
transaction_users['G_USER']['passphrase'] = 'sorry assume clutch category grace lift text drift ankle tenant price inside'
|
||||
transaction_users['G_USER']['username'] = 'Corny Jumpy Argusfish'
|
||||
transaction_users['G_USER']['address'] = '0xcd22ac97164257fa832104b94286e0d839a42cfc'
|
||||
transaction_users['G_USER']['public_key'] = '0x04e53b6e5c602208d34b436fec90d4b85d171e5583d4371be57c7994a247e4ab3333c8ea2' \
|
||||
'42978d80dda9a0279c90050f4d33ea83b1bb71b7b1297a68e769be9b7'
|
||||
|
||||
transaction_users['H_USER'] = dict()
|
||||
transaction_users['H_USER']['password'] = 'qwerty'
|
||||
transaction_users['H_USER']['passphrase'] = 'expect attract panther inhale essence illegal muffin power cabbage correct market gun'
|
||||
transaction_users['H_USER']['username'] = 'Marvelous Round Argali'
|
||||
transaction_users['H_USER']['address'] = '0xbbb5bf58c92bd48e27fa508ed544da8472bbb26c'
|
||||
transaction_users['H_USER']['public_key'] = '0x04862eb3a2f08bb0469380a0ea8deb06f1c9af57e839cc7e783edd209058b72a0049596a' \
|
||||
'16faba47f53b629958b435d19857b949fb3bb4a8cfc8f577cbac96609d'
|
||||
|
||||
transaction_users_wallet = dict()
|
||||
transaction_users_wallet['A_USER'] = dict()
|
||||
transaction_users_wallet['A_USER']['password'] = "new_unique_password"
|
||||
|
|
|
@ -8,7 +8,7 @@ from os import environ
|
|||
from appium import webdriver
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from selenium.common.exceptions import WebDriverException
|
||||
from tests import test_suite_data, start_threads
|
||||
from tests import test_suite_data, start_threads, api_requests
|
||||
from views.base_view import BaseView
|
||||
|
||||
|
||||
|
@ -195,4 +195,12 @@ environments = {'local': LocalMultipleDeviceTestCase,
|
|||
|
||||
class MultipleDeviceTestCase(environments[pytest.config.getoption('env')]):
|
||||
|
||||
pass
|
||||
def setup_method(self, method):
|
||||
super(MultipleDeviceTestCase, self).setup_method(method)
|
||||
self.senders = dict()
|
||||
|
||||
def teardown_method(self, method):
|
||||
for user in self.senders:
|
||||
api_requests.faucet(address=self.senders[user]['address'])
|
||||
super(MultipleDeviceTestCase, self).teardown_method(method)
|
||||
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from tests import transaction_users
|
||||
from tests.base_test_case import MultipleDeviceTestCase
|
||||
from views.sign_in_view import SignInView
|
||||
|
||||
|
||||
@pytest.mark.all
|
||||
@pytest.mark.chat_management
|
||||
class TestChatManagement(MultipleDeviceTestCase):
|
||||
|
||||
@pytest.mark.testrail_case_id(3412)
|
||||
def test_delete_1_1_chat(self):
|
||||
self.senders['g_user'] = transaction_users['G_USER']
|
||||
self.senders['h_user'] = transaction_users['H_USER']
|
||||
|
||||
self.create_drivers(2)
|
||||
device_1 = self.drivers[0]
|
||||
device_2 = self.drivers[1]
|
||||
|
||||
device_1_sign_in_view = SignInView(device_1)
|
||||
device_1_sign_in_view.recover_access(self.senders['g_user']['passphrase'], self.senders['g_user']['password'])
|
||||
device_2_sign_in_view = SignInView(device_2)
|
||||
device_2_sign_in_view.recover_access(self.senders['h_user']['passphrase'], self.senders['h_user']['password'])
|
||||
|
||||
device_1_home_view = device_1_sign_in_view.get_home_view()
|
||||
device_2_home_view = device_2_sign_in_view.get_home_view()
|
||||
|
||||
# Device 1: Start new 1-1 chat
|
||||
device_1_home_view.add_contact(self.senders['h_user']['public_key'])
|
||||
device_1_chat_view = device_1_home_view.get_chat_view()
|
||||
chat_with_g_user = device_2_home_view.get_chat_with_user(self.senders['g_user']['username'])
|
||||
chat_with_g_user.wait_for_element(30)
|
||||
device_2_chat_view = chat_with_g_user.click()
|
||||
|
||||
# Devices: Request and send transactions
|
||||
transaction_amount = '0.00001'
|
||||
device_1_chat_view.request_transaction_in_1_1_chat(transaction_amount)
|
||||
device_1_chat_view.send_transaction_in_1_1_chat(transaction_amount, self.senders['g_user']['password'])
|
||||
device_2_chat_view.request_transaction_in_1_1_chat(transaction_amount)
|
||||
device_2_chat_view.send_transaction_in_1_1_chat(transaction_amount, self.senders['h_user']['password'])
|
||||
|
||||
# Device 1: Send message to device 2
|
||||
device_1_message = 'message from user 1'
|
||||
device_1_chat_view.chat_message_input.send_keys(device_1_message)
|
||||
device_1_chat_view.send_message_button.click()
|
||||
|
||||
# Device 2: Send message to device 1
|
||||
device_2_message = 'message from user 2'
|
||||
device_2_chat_view = device_2_home_view.get_chat_view()
|
||||
device_2_chat_view.chat_message_input.send_keys(device_2_message)
|
||||
device_2_chat_view.send_message_button.click()
|
||||
|
||||
# Device 1: See the message from device 2
|
||||
device_1_chat_view.wait_for_message_in_one_to_one_chat(device_2_message, self.errors)
|
||||
|
||||
# Stop device 2, it's not needed anymore
|
||||
device_2.quit()
|
||||
|
||||
# Device 1: Delete chat and make sure it does not reappear after logging in again
|
||||
device_1_chat_view.delete_chat(self.senders['h_user']['username'], self.errors)
|
||||
device_1_profile_view = device_1_sign_in_view.profile_button.click()
|
||||
device_1_sign_in_view = device_1_profile_view.logout()
|
||||
time.sleep(5) # Prevent stale element exception for first_account_button
|
||||
device_1_sign_in_view.account_button.click()
|
||||
device_1_sign_in_view.sign_in(self.senders['g_user']['password'])
|
||||
assert not device_1_home_view.get_chat_with_user(self.senders['h_user']['username']).is_element_present(20)
|
||||
|
||||
# Device 1: Start 1-1 chat with device 2
|
||||
device_1_chat_view = device_1_home_view.start_1_1_chat(self.senders['h_user']['username'])
|
||||
assert device_1_chat_view.no_messages_in_chat.is_element_present()
|
||||
|
||||
self.verify_no_errors()
|
|
@ -22,15 +22,13 @@ message_with_new_line = 'message' '\n' 'with new line'
|
|||
class TestMessages(MultipleDeviceTestCase):
|
||||
|
||||
@pytest.mark.pr
|
||||
def test_one_to_one_chat_messages_and_delete_chat(self):
|
||||
def test_one_to_one_chat_messages(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_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()
|
||||
|
||||
|
@ -77,7 +75,6 @@ class TestMessages(MultipleDeviceTestCase):
|
|||
web_view.find_full_text('Status, the Ethereum discovery tool.')
|
||||
device_1_chat.back_button.click()
|
||||
|
||||
device_1_chat.delete_chat(device_2_username[:25], self.errors)
|
||||
self.verify_no_errors()
|
||||
|
||||
@pytest.mark.pr
|
||||
|
|
|
@ -28,7 +28,7 @@ class TestSanity(SingleDeviceTestCase):
|
|||
sign_in_view = SignInView(self.driver)
|
||||
sign_in_view.create_user()
|
||||
profile_view = sign_in_view.profile_button.click()
|
||||
profile_view.logout_button.click()
|
||||
profile_view.logout()
|
||||
recover_access_view = sign_in_view.add_existing_account_button.click()
|
||||
recover_access_view.passphrase_input.send_keys(basic_user['passphrase'])
|
||||
recover_access_view.password_input.send_keys(basic_user['password'])
|
||||
|
|
|
@ -21,22 +21,13 @@ class TestTransaction(SingleDeviceTestCase):
|
|||
sender_address = home_view.public_key_to_address(sender_public_key)
|
||||
home_view.home_button.click()
|
||||
api_requests.get_donate(sender_address)
|
||||
initial_balance_recipient = api_requests.get_balance(recipient['address'])
|
||||
home_view.add_contact(recipient['public_key'])
|
||||
chat_view = home_view.get_chat_with_user(recipient['username']).click()
|
||||
chat_view.commands_button.click()
|
||||
chat_view.send_command.click()
|
||||
chat_view.send_as_keyevent(transaction_amount)
|
||||
initial_balance_recipient = api_requests.get_balance(recipient['address'])
|
||||
chat_view.send_transaction_in_1_1_chat(transaction_amount, 'qwerty1234')
|
||||
send_transaction_view = chat_view.get_send_transaction_view()
|
||||
chat_view.send_message_button.click_until_presence_of_element(send_transaction_view.sign_transaction_button)
|
||||
send_transaction_view.sign_transaction('qwerty1234')
|
||||
send_transaction_view.find_full_text(transaction_amount)
|
||||
try:
|
||||
chat_view.find_full_text('Sent', 10)
|
||||
except TimeoutException:
|
||||
chat_view.find_full_text('Delivered', 10)
|
||||
api_requests.verify_balance_is_updated(initial_balance_recipient, recipient['address'])
|
||||
send_transaction_view.back_button.click()
|
||||
api_requests.verify_balance_is_updated(initial_balance_recipient, recipient['address'])
|
||||
wallet_view = home_view.wallet_button.click()
|
||||
transactions_view = wallet_view.transactions_button.click()
|
||||
transactions_view.transactions_table.find_transaction(amount=transaction_amount)
|
||||
|
@ -73,21 +64,13 @@ class TestTransaction(SingleDeviceTestCase):
|
|||
sender_address = home_view.public_key_to_address(sender_public_key)
|
||||
home_view.home_button.click()
|
||||
api_requests.get_donate(sender_address)
|
||||
initial_balance_recipient = api_requests.get_balance(recipient['address'])
|
||||
home_view.add_contact(recipient['public_key'])
|
||||
home_view.get_back_to_home_view()
|
||||
home_view.create_group_chat([recipient['username']], 'trg_%s' % get_current_time())
|
||||
chat_view = home_view.get_chat_view()
|
||||
chat_view.commands_button.click()
|
||||
chat_view.send_command.click()
|
||||
chat_view.first_recipient_button.click()
|
||||
chat_view.send_as_keyevent(transaction_amount)
|
||||
send_transaction_view = chat_view.get_send_transaction_view()
|
||||
chat_view.send_message_button.click_until_presence_of_element(send_transaction_view.sign_transaction_button)
|
||||
send_transaction_view.sign_transaction('qwerty1234')
|
||||
send_transaction_view.find_full_text(transaction_amount)
|
||||
chat_view.find_full_text('to ' + recipient['username'], 10)
|
||||
api_requests.verify_balance_is_updated(initial_balance_recipient, recipient['address'])
|
||||
initial_recipient_balance = api_requests.get_balance(recipient['address'])
|
||||
chat_view.send_transaction_in_group_chat(transaction_amount, 'qwerty1234', recipient)
|
||||
api_requests.verify_balance_is_updated(initial_recipient_balance, recipient['address'])
|
||||
|
||||
@pytest.mark.pr
|
||||
def test_send_transaction_from_daap(self):
|
||||
|
@ -203,15 +186,11 @@ class TestTransaction(SingleDeviceTestCase):
|
|||
|
||||
@pytest.mark.all
|
||||
class TestTransactions(MultipleDeviceTestCase):
|
||||
senders = dict()
|
||||
senders['c_user'] = transaction_users_wallet['C_USER']
|
||||
senders['d_user'] = transaction_users['D_USER']
|
||||
senders['f_user'] = transaction_users['F_USER']
|
||||
|
||||
@pytest.mark.pr
|
||||
def test_send_eth_to_request_in_group_chat(self):
|
||||
recipient = transaction_users['E_USER']
|
||||
sender = self.senders['f_user']
|
||||
sender = self.senders['f_user'] = transaction_users['F_USER']
|
||||
self.create_drivers(2)
|
||||
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
||||
for user_details in (recipient, device_1), (sender, device_2):
|
||||
|
@ -240,7 +219,7 @@ class TestTransactions(MultipleDeviceTestCase):
|
|||
@pytest.mark.pr
|
||||
def test_send_eth_to_request_in_one_to_one_chat(self):
|
||||
recipient = transaction_users['C_USER']
|
||||
sender = self.senders['d_user']
|
||||
sender = self.senders['d_user'] = transaction_users['D_USER']
|
||||
self.create_drivers(2)
|
||||
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
||||
for user_details in (recipient, device_1), (sender, device_2):
|
||||
|
@ -279,7 +258,7 @@ class TestTransactions(MultipleDeviceTestCase):
|
|||
@pytest.mark.pr
|
||||
def test_send_eth_to_request_from_wallet(self):
|
||||
recipient = transaction_users_wallet['D_USER']
|
||||
sender = self.senders['c_user']
|
||||
sender = self.senders['c_user'] = transaction_users['C_USER']
|
||||
self.create_drivers(2)
|
||||
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
|
||||
for user_details in (recipient, device_1), (sender, device_2):
|
||||
|
@ -311,7 +290,3 @@ class TestTransactions(MultipleDeviceTestCase):
|
|||
device_2_chat.send_eth_to_request(request_button, sender['password'])
|
||||
api_requests.verify_balance_is_updated(initial_balance_recipient, recipient['address'])
|
||||
|
||||
def teardown_method(self, method):
|
||||
for user in self.senders:
|
||||
api_requests.faucet(address=self.senders[user]['address'])
|
||||
super(TestTransactions, self).teardown_method(method)
|
||||
|
|
|
@ -25,6 +25,15 @@ class BaseElement(object):
|
|||
def accessibility_id(locator, value):
|
||||
return locator(MobileBy.ACCESSIBILITY_ID, value)
|
||||
|
||||
@classmethod
|
||||
def text_selector(locator, text):
|
||||
return BaseElement.Locator.xpath_selector('//*[@text="' + text + '"]')
|
||||
|
||||
@classmethod
|
||||
def text_part_selector(locator, text):
|
||||
return BaseElement.Locator.xpath_selector('//*[contains(@text, "' + text + '")]')
|
||||
|
||||
|
||||
def __str__(self, *args, **kwargs):
|
||||
return "%s:%s" % (self.by, self.value)
|
||||
|
||||
|
|
|
@ -231,13 +231,13 @@ class BaseView(object):
|
|||
def element_by_text(self, text, element_type='button'):
|
||||
info("Looking for an element by text: '%s'" % text)
|
||||
element = self.element_types[element_type](self.driver)
|
||||
element.locator = element.Locator.xpath_selector('//*[@text="' + text + '"]')
|
||||
element.locator = element.Locator.text_selector(text)
|
||||
return element
|
||||
|
||||
def element_by_text_part(self, text, element_type='base'):
|
||||
info("Looking for an element by text part: '%s'" % text)
|
||||
element = self.element_types[element_type](self.driver)
|
||||
element.locator = element.Locator.xpath_selector('//*[contains(@text, "' + text + '")]')
|
||||
element.locator = element.Locator.text_part_selector(text)
|
||||
return element
|
||||
|
||||
def element_starts_with_text(self, text, element_type='base'):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
@ -140,6 +140,12 @@ class ViewProfileButton(BaseButton):
|
|||
self.locator = self.Locator.xpath_selector('//*[@text="View profile"]')
|
||||
|
||||
|
||||
class NoMessagesInChatText(BaseText):
|
||||
def __init__(self, driver):
|
||||
super(NoMessagesInChatText, self).__init__(driver)
|
||||
self.locator = self.Locator.text_part_selector('There are no messages')
|
||||
|
||||
|
||||
class ProfileSendMessageButton(BaseButton):
|
||||
def __init__(self, driver):
|
||||
super(ProfileSendMessageButton, self).__init__(driver)
|
||||
|
@ -159,6 +165,7 @@ class ChatView(BaseView):
|
|||
self.chat_message_input = ChatMessageInput(self.driver)
|
||||
self.add_to_contacts = AddToContacts(self.driver)
|
||||
self.user_name_text = UserNameText(self.driver)
|
||||
self.no_messages_in_chat = NoMessagesInChatText(self.driver)
|
||||
|
||||
self.commands_button = CommandsButton(self.driver)
|
||||
self.send_command = SendCommand(self.driver)
|
||||
|
@ -244,3 +251,40 @@ class ChatView(BaseView):
|
|||
if not HomeView(self.driver).plus_button.is_element_present() or \
|
||||
self.element_by_text(chat_name).is_element_present():
|
||||
errors.append('Chat was not deleted')
|
||||
|
||||
def send_transaction_in_1_1_chat(self, amount, password):
|
||||
self.commands_button.click()
|
||||
self.send_command.click()
|
||||
self.send_as_keyevent(amount)
|
||||
self.send_message_button.click()
|
||||
|
||||
send_transaction_view = self.get_send_transaction_view()
|
||||
self.send_message_button.click_until_presence_of_element(send_transaction_view.sign_transaction_button)
|
||||
send_transaction_view.sign_transaction(password)
|
||||
send_transaction_view.find_full_text(amount)
|
||||
try:
|
||||
self.find_full_text('Sent', 10)
|
||||
except TimeoutException:
|
||||
try:
|
||||
self.find_full_text('Delivered', 10)
|
||||
except TimeoutException:
|
||||
self.find_full_text('Seen', 3)
|
||||
|
||||
def send_transaction_in_group_chat(self, amount, password, recipient):
|
||||
self.commands_button.click()
|
||||
self.send_command.click()
|
||||
self.find_full_text(recipient['username']).click()
|
||||
self.send_as_keyevent(amount)
|
||||
self.send_message_button.click()
|
||||
|
||||
send_transaction_view = self.get_send_transaction_view()
|
||||
self.send_message_button.click_until_presence_of_element(send_transaction_view.sign_transaction_button)
|
||||
send_transaction_view.sign_transaction(password)
|
||||
send_transaction_view.find_full_text(amount)
|
||||
self.find_full_text('to ' + recipient['username'], 10)
|
||||
|
||||
def request_transaction_in_1_1_chat(self, amount):
|
||||
self.commands_button.click()
|
||||
self.request_command.click()
|
||||
self.send_as_keyevent(amount)
|
||||
self.send_message_button.click()
|
||||
|
|
|
@ -90,6 +90,13 @@ class HomeView(BaseView):
|
|||
one_to_one_chat = self.get_chat_view()
|
||||
one_to_one_chat.chat_message_input.wait_for_element(60)
|
||||
|
||||
def start_1_1_chat(self, username):
|
||||
start_new_chat = self.plus_button.click()
|
||||
start_new_chat.start_new_chat_button.click()
|
||||
self.element_by_text(username).click()
|
||||
from views.chat_view import ChatView
|
||||
return ChatView(self.driver)
|
||||
|
||||
def create_group_chat(self, user_names_to_add: list, group_chat_name: str = 'new_group_chat'):
|
||||
start_new_chat = self.plus_button.click()
|
||||
start_new_chat.new_group_chat_button.click()
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import time
|
||||
|
||||
from tests import info
|
||||
from tests.base_test_case import AbstractTestCase
|
||||
from views.base_element import BaseText, BaseButton, BaseEditBox, BaseElement
|
||||
|
@ -77,6 +76,21 @@ class LogoutButton(BaseButton):
|
|||
self.locator = self.Locator.accessibility_id('log-out-button')
|
||||
|
||||
|
||||
class LogoutDialog(BaseView):
|
||||
def __init__(self, driver):
|
||||
super(LogoutDialog, self).__init__(driver)
|
||||
self.logout_button = LogoutDialog.LogoutButton(driver)
|
||||
|
||||
class LogoutButton(BaseButton):
|
||||
def __init__(self, driver):
|
||||
super(LogoutDialog.LogoutButton, self).__init__(driver)
|
||||
self.locator = self.Locator.text_selector('LOG OUT')
|
||||
|
||||
def navigate(self):
|
||||
from views.sign_in_view import SignInView
|
||||
return SignInView(self.driver)
|
||||
|
||||
|
||||
class ConfirmLogoutButton(BaseButton):
|
||||
|
||||
def __init__(self, driver):
|
||||
|
@ -227,6 +241,7 @@ class ProfileView(BaseView):
|
|||
self.network_settings_button = NetworkSettingsButton(self.driver)
|
||||
self.connect_button = NetworkSettingsButton.ConnectButton(self.driver)
|
||||
self.logout_button = LogoutButton(self.driver)
|
||||
self.logout_dialog = LogoutDialog(self.driver)
|
||||
self.confirm_logout_button = ConfirmLogoutButton(self.driver)
|
||||
|
||||
# new design
|
||||
|
@ -279,3 +294,8 @@ class ProfileView(BaseView):
|
|||
self.confirm_button.click()
|
||||
else:
|
||||
raise NotImplementedError('Test case is implemented to run on SauceLabs only')
|
||||
|
||||
def logout(self):
|
||||
self.logout_button.click()
|
||||
return self.logout_dialog.logout_button.click()
|
||||
|
||||
|
|
|
@ -120,5 +120,9 @@ class SignInView(BaseView):
|
|||
self.do_not_share.wait_for_element(10)
|
||||
self.do_not_share.click_until_presence_of_element(self.home_button)
|
||||
|
||||
def sign_in(self, password):
|
||||
self.password_input.set_value(password)
|
||||
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