added 'recover access' and 'send transaction in group chat' tests
This commit is contained in:
parent
141ef4e631
commit
698e90a62c
|
@ -17,4 +17,28 @@ class TestData(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.name = None
|
self.name = None
|
||||||
|
|
||||||
|
|
||||||
|
basic_user = {'password': "qwerty",
|
||||||
|
'passphrase': "level acquire claim tide company believe duck embody consider dune century mountain",
|
||||||
|
'username': "Silky Heavenly Zethusspinipes"}
|
||||||
|
|
||||||
|
transaction_users = {
|
||||||
|
'A_USER': {'password': "qwerty",
|
||||||
|
'passphrase': "pet letter very ozone shop humor "
|
||||||
|
"shuffle bounce convince soda hint brave",
|
||||||
|
'public_key': '0x040e016b940e067997be8d91298d893ff2bc3580504b4ccb155ea03d183b85f1'
|
||||||
|
'8e771a763d99f60fec70edf637eb6bad9f96d3e8a544168d3ad144f83b4cf7625c',
|
||||||
|
'address': '67a50ef1d26de6d65dbfbb88172ac1e7017e766d',
|
||||||
|
'username': 'Evergreen Handsome Cottontail'},
|
||||||
|
|
||||||
|
'B_USER': {'password': "qwerty",
|
||||||
|
'passphrase': "resemble soap taxi meat reason "
|
||||||
|
"inflict dilemma calm warrior key gloom again",
|
||||||
|
'public_key': '0x0406b17e5cdfadb2a05e84508b1a2916def6395e6295f57e92b85f915d40bca3'
|
||||||
|
'f4a7e4c6d6b25afa840dd042fac83d3f856181d553f34f1c2b12878e774adde099',
|
||||||
|
'address': '3d672407a7e1250bbff85b7cfdb456f5015164db',
|
||||||
|
'username': 'Brief Organic Xenops'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
tests_data = TestData()
|
tests_data = TestData()
|
||||||
|
|
|
@ -39,6 +39,7 @@ class AbstractTestCase:
|
||||||
desired_caps['name'] = tests_data.name
|
desired_caps['name'] = tests_data.name
|
||||||
desired_caps['build'] = pytest.config.getoption('build')
|
desired_caps['build'] = pytest.config.getoption('build')
|
||||||
desired_caps['idleTimeout'] = 1000
|
desired_caps['idleTimeout'] = 1000
|
||||||
|
desired_caps['commandTimeout'] = 600
|
||||||
return desired_caps
|
return desired_caps
|
||||||
|
|
||||||
def get_public_url(self, driver):
|
def get_public_url(self, driver):
|
||||||
|
|
|
@ -2,10 +2,9 @@ from tests import tests_data
|
||||||
import time
|
import time
|
||||||
import requests
|
import requests
|
||||||
import re
|
import re
|
||||||
import shutil
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from os import environ
|
from os import environ
|
||||||
from io import BytesIO, StringIO
|
from io import BytesIO
|
||||||
from sauceclient import SauceClient
|
from sauceclient import SauceClient
|
||||||
|
|
||||||
storage = 'http://artifacts.status.im:8081/artifactory/nightlies-local/'
|
storage = 'http://artifacts.status.im:8081/artifactory/nightlies-local/'
|
||||||
|
|
|
@ -3,8 +3,22 @@
|
||||||
def set_password_as_new_user(*args):
|
def set_password_as_new_user(*args):
|
||||||
for view in args:
|
for view in args:
|
||||||
view.request_password_icon.click()
|
view.request_password_icon.click()
|
||||||
view.type_message_edit_box.send_keys("qwerty1234")
|
view.chat_request_input.send_keys("qwerty1234")
|
||||||
view.confirm()
|
view.confirm()
|
||||||
view.type_message_edit_box.send_keys("qwerty1234")
|
view.chat_request_input.send_keys("qwerty1234")
|
||||||
view.confirm()
|
view.confirm()
|
||||||
view.find_full_text("Tap here to enter your phone number & I\'ll find your friends")
|
view.find_full_text("Tap here to enter your phone number & I\'ll find your friends")
|
||||||
|
|
||||||
|
|
||||||
|
def recover_access(chats, passphrase, password, username):
|
||||||
|
chats.back_button.click()
|
||||||
|
chats.profile_button.click()
|
||||||
|
login = chats.switch_users_button.click()
|
||||||
|
login.recover_access_button.click()
|
||||||
|
login.passphrase_input.send_keys(passphrase)
|
||||||
|
login.password_input.send_keys(password)
|
||||||
|
login.confirm_recover_access.click()
|
||||||
|
recovered_user = login.element_by_text(username, 'button')
|
||||||
|
recovered_user.click()
|
||||||
|
login.password_input.send_keys(password)
|
||||||
|
login.sign_in_button.click()
|
||||||
|
|
|
@ -1,49 +1,29 @@
|
||||||
import pytest
|
import pytest
|
||||||
from tests.basetestcase import SingleDeviceTestCase
|
from tests.basetestcase import SingleDeviceTestCase
|
||||||
from views.home import HomeView
|
from views.home import HomeView
|
||||||
from tests.preconditions import set_password_as_new_user
|
from tests.preconditions import set_password_as_new_user, recover_access
|
||||||
|
from tests import basic_user, transaction_users
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sanity
|
@pytest.mark.sanity
|
||||||
class TestSanity(SingleDeviceTestCase):
|
class TestSanity(SingleDeviceTestCase):
|
||||||
|
|
||||||
def test_transaction(self):
|
def test_recover_access(self):
|
||||||
home = HomeView(self.driver)
|
home = HomeView(self.driver)
|
||||||
set_password_as_new_user(home)
|
set_password_as_new_user(home)
|
||||||
chats = home.get_chats()
|
chats = home.get_chats()
|
||||||
chats.wait_for_syncing_complete()
|
|
||||||
chats.back_button.click()
|
chats.back_button.click()
|
||||||
chats.profile_button.click()
|
chats.profile_button.click()
|
||||||
profile = chats.profile_icon.click()
|
login = chats.switch_users_button.click()
|
||||||
|
login.recover_access_button.click()
|
||||||
sender_address = profile.profile_address_text.text
|
login.passphrase_input.send_keys(basic_user['passphrase'])
|
||||||
recipient_key = '0x040e016b940e067997be8d91298d893ff2bc3580504b4ccb155ea03d183b85f1' \
|
login.password_input.send_keys(basic_user['password'])
|
||||||
'8e771a763d99f60fec70edf637eb6bad9f96d3e8a544168d3ad144f83b4cf7625c'
|
login.confirm_recover_access.click()
|
||||||
recipient_address = '67a50ef1d26de6d65dbfbb88172ac1e7017e766d'
|
recovered_user = login.element_by_text(basic_user['username'], 'button')
|
||||||
|
recovered_user.click()
|
||||||
profile.get_donate(sender_address)
|
login.password_input.send_keys(basic_user['password'])
|
||||||
initial_balance = profile.get_balance(recipient_address)
|
login.sign_in_button.click()
|
||||||
|
home.find_full_text('Chats', 10)
|
||||||
profile.back_button.click()
|
|
||||||
chats.plus_button.click()
|
|
||||||
chats.add_new_contact.click()
|
|
||||||
chats.public_key_edit_box.send_keys(recipient_key)
|
|
||||||
chats.confirm()
|
|
||||||
chats.confirm_public_key_button.click()
|
|
||||||
|
|
||||||
chats.send_funds_button.click()
|
|
||||||
chats.first_recipient_button.click()
|
|
||||||
chats.send_int_as_keyevent(0)
|
|
||||||
chats.send_dot_as_keyevent()
|
|
||||||
chats.send_int_as_keyevent(1)
|
|
||||||
chats.send_message_button.click()
|
|
||||||
chats.confirm_transaction_button.click()
|
|
||||||
chats.password_input.send_keys('qwerty1234')
|
|
||||||
chats.confirm_button.click()
|
|
||||||
chats.got_it_button.click()
|
|
||||||
chats.find_full_text('0.1')
|
|
||||||
chats.find_full_text('Sent', 60)
|
|
||||||
chats.verify_balance_is_updated(initial_balance, recipient_address)
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("verification", ["invalid", "valid"])
|
@pytest.mark.parametrize("verification", ["invalid", "valid"])
|
||||||
def test_sign_in(self, verification):
|
def test_sign_in(self, verification):
|
||||||
|
@ -65,23 +45,75 @@ class TestSanity(SingleDeviceTestCase):
|
||||||
login.sign_in_button.click()
|
login.sign_in_button.click()
|
||||||
home.find_full_text(verifications[verification]["outcome"], 10)
|
home.find_full_text(verifications[verification]["outcome"], 10)
|
||||||
|
|
||||||
@pytest.mark.parametrize("verification", ["short", "mismatch", "valid"])
|
@pytest.mark.parametrize("verification", ["short", "mismatch"])
|
||||||
def test_password(self, verification):
|
def test_password(self, verification):
|
||||||
|
|
||||||
verifications = {"short":
|
verifications = {"short":
|
||||||
{"input": "qwe1",
|
{"input": "qwe1",
|
||||||
"outcome": "Password should be not less then 6 symbols."},
|
"outcome": "Password should be not less then 6 symbols."},
|
||||||
"valid":
|
|
||||||
{"input": "qwerty1234",
|
|
||||||
"outcome": "Tap here to enter your phone number & I\'ll find your friends"},
|
|
||||||
"mismatch":
|
"mismatch":
|
||||||
{"input": "mismatch1234",
|
{"input": "mismatch1234",
|
||||||
"outcome": "Password confirmation doesn\'t match password."}}
|
"outcome": "Password confirmation doesn\'t match password."}}
|
||||||
home = HomeView(self.driver)
|
home = HomeView(self.driver)
|
||||||
home.request_password_icon.click()
|
home.request_password_icon.click()
|
||||||
home.type_message_edit_box.send_keys(verifications[verification]["input"])
|
home.chat_request_input.send_keys(verifications[verification]["input"])
|
||||||
home.confirm()
|
home.confirm()
|
||||||
if 'short' not in verification:
|
if 'short' not in verification:
|
||||||
home.type_message_edit_box.send_keys(verifications["valid"]["input"])
|
home.chat_request_input.send_keys("qwerty1234")
|
||||||
home.confirm()
|
home.confirm()
|
||||||
home.find_full_text(verifications[verification]["outcome"])
|
home.find_full_text(verifications[verification]["outcome"])
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("test, recipient, sender", [('group_chat', 'A_USER', 'B_USER'),
|
||||||
|
('one_to_one_chat', 'B_USER', 'A_USER')],
|
||||||
|
ids=['group_chat', 'one_to_one_chat'])
|
||||||
|
def test_send_transaction(self, test, recipient, sender):
|
||||||
|
home = HomeView(self.driver)
|
||||||
|
set_password_as_new_user(home)
|
||||||
|
chats = home.get_chats()
|
||||||
|
recover_access(chats,
|
||||||
|
transaction_users[sender]['passphrase'],
|
||||||
|
transaction_users[sender]['password'],
|
||||||
|
transaction_users[sender]['username'])
|
||||||
|
chats.wait_for_syncing_complete()
|
||||||
|
|
||||||
|
sender_address = transaction_users[sender]['address']
|
||||||
|
recipient_address = transaction_users[recipient]['address']
|
||||||
|
recipient_key = transaction_users[recipient]['public_key']
|
||||||
|
initial_balance_recipient = chats.get_balance(recipient_address)
|
||||||
|
|
||||||
|
if chats.get_balance(sender_address) < 1000000000000000000:
|
||||||
|
chats.get_donate(sender_address)
|
||||||
|
|
||||||
|
chats.plus_button.click()
|
||||||
|
chats.add_new_contact.click()
|
||||||
|
chats.public_key_edit_box.send_keys(recipient_key)
|
||||||
|
chats.confirm()
|
||||||
|
chats.confirm_public_key_button.click()
|
||||||
|
|
||||||
|
if test == 'group_chat':
|
||||||
|
user_name = chats.user_name_text.text
|
||||||
|
chats.back_button.click()
|
||||||
|
chats.new_group_chat_button.click()
|
||||||
|
user_contact = chats.element_by_text(user_name, 'button')
|
||||||
|
user_contact.scroll_to_element()
|
||||||
|
user_contact.click()
|
||||||
|
chats.next_button.click()
|
||||||
|
chats.name_edit_box.send_keys('chat_send_transaction')
|
||||||
|
chats.save_button.click()
|
||||||
|
|
||||||
|
chats.send_funds_button.click()
|
||||||
|
chats.first_recipient_button.click()
|
||||||
|
chats.send_int_as_keyevent(0)
|
||||||
|
chats.send_dot_as_keyevent()
|
||||||
|
chats.send_int_as_keyevent(1)
|
||||||
|
chats.send_message_button.click()
|
||||||
|
chats.confirm_transaction_button.wait_for_element(60)
|
||||||
|
chats.confirm_transaction_button.click()
|
||||||
|
chats.password_input.send_keys(transaction_users[sender]['password'])
|
||||||
|
chats.confirm_button.click()
|
||||||
|
chats.got_it_button.click()
|
||||||
|
|
||||||
|
chats.find_full_text('0.1')
|
||||||
|
chats.find_full_text('Sent', 60)
|
||||||
|
if test == 'group_chat':
|
||||||
|
chats.find_full_text('to ' + transaction_users[recipient]['username'], 60)
|
||||||
|
chats.verify_balance_is_updated(initial_balance_recipient, recipient_address)
|
||||||
|
|
|
@ -32,6 +32,7 @@ class BaseViewObject(object):
|
||||||
def send_int_as_keyevent(self, integer):
|
def send_int_as_keyevent(self, integer):
|
||||||
keys = {0: 7, 1: 8, 2: 9, 3: 10, 4: 11,
|
keys = {0: 7, 1: 8, 2: 9, 3: 10, 4: 11,
|
||||||
5: 12, 6: 13, 7: 14, 8: 15, 9: 16}
|
5: 12, 6: 13, 7: 14, 8: 15, 9: 16}
|
||||||
|
time.sleep(2)
|
||||||
self.driver.keyevent(keys[integer])
|
self.driver.keyevent(keys[integer])
|
||||||
|
|
||||||
def send_dot_as_keyevent(self):
|
def send_dot_as_keyevent(self):
|
||||||
|
@ -66,16 +67,16 @@ class BaseViewObject(object):
|
||||||
|
|
||||||
def get_balance(self, address):
|
def get_balance(self, address):
|
||||||
url = 'http://ropsten.etherscan.io/api?module=account&action=balance&address=0x%s&tag=latest' % address
|
url = 'http://ropsten.etherscan.io/api?module=account&action=balance&address=0x%s&tag=latest' % address
|
||||||
return requests.request('GET', url).json()["result"]
|
return int(requests.request('GET', url).json()["result"])
|
||||||
|
|
||||||
def get_donate(self, address, wait_time=300):
|
def get_donate(self, address, wait_time=300):
|
||||||
|
initial_balance = self.get_balance(address)
|
||||||
response = requests.request('GET', 'http://46.101.129.137:3001/donate/0x%s' % address).json()
|
response = requests.request('GET', 'http://46.101.129.137:3001/donate/0x%s' % address).json()
|
||||||
counter = 0
|
counter = 0
|
||||||
while True:
|
while True:
|
||||||
if counter == wait_time:
|
if counter == wait_time:
|
||||||
logging.info("Donation was not received during %s seconds!" % wait_time)
|
pytest.fail("Donation was not received during %s seconds!" % wait_time)
|
||||||
break
|
elif self.get_balance(address) == initial_balance:
|
||||||
elif self.get_balance(address) != '1000000000000000000':
|
|
||||||
counter += 10
|
counter += 10
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
logging.info('Waiting %s seconds for donation' % counter)
|
logging.info('Waiting %s seconds for donation' % counter)
|
||||||
|
@ -87,8 +88,7 @@ class BaseViewObject(object):
|
||||||
counter = 0
|
counter = 0
|
||||||
while True:
|
while True:
|
||||||
if counter == wait_time:
|
if counter == wait_time:
|
||||||
logging.info('Balance is not changed during %s seconds, funds were not received!')
|
pytest.fail('Balance is not changed during %s seconds, funds were not received!' % wait_time)
|
||||||
break
|
|
||||||
elif initial_balance == self.get_balance(recipient_address):
|
elif initial_balance == self.get_balance(recipient_address):
|
||||||
counter += 10
|
counter += 10
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
|
@ -28,9 +28,14 @@ class SwitchUsersButton(BaseButton):
|
||||||
super(SwitchUsersButton, self).__init__(driver)
|
super(SwitchUsersButton, self).__init__(driver)
|
||||||
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='SWITCH USERS']")
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='SWITCH USERS']")
|
||||||
|
|
||||||
|
def click(self):
|
||||||
|
time.sleep(2)
|
||||||
|
self.find_element().click()
|
||||||
|
logging.info('Tap on %s' % self.name)
|
||||||
|
return self.navigate()
|
||||||
|
|
||||||
def navigate(self):
|
def navigate(self):
|
||||||
from views.login import LoginView
|
from views.login import LoginView
|
||||||
time.sleep(2)
|
|
||||||
return LoginView(self.driver)
|
return LoginView(self.driver)
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,7 +148,7 @@ class SendMessageButton(BaseButton):
|
||||||
self.locator = self.Locator.accessibility_id("send-message-button")
|
self.locator = self.Locator.accessibility_id("send-message-button")
|
||||||
|
|
||||||
def click(self):
|
def click(self):
|
||||||
time.sleep(30)
|
time.sleep(10)
|
||||||
self.find_element().click()
|
self.find_element().click()
|
||||||
logging.info('Tap on %s' % self.name)
|
logging.info('Tap on %s' % self.name)
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,12 @@ class ContinueButtonAPK(BaseButton):
|
||||||
self.locator = self.Locator.xpath_selector("//*[@text='Continue']")
|
self.locator = self.Locator.xpath_selector("//*[@text='Continue']")
|
||||||
|
|
||||||
|
|
||||||
class TypeMessageEditBox(BaseEditBox):
|
class ChatRequestInput(BaseEditBox):
|
||||||
|
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
super(TypeMessageEditBox, self).__init__(driver)
|
super(ChatRequestInput, self).__init__(driver)
|
||||||
self.locator = \
|
self.locator = \
|
||||||
self.Locator.xpath_selector("//*[@content-desc!='chat-message-input']")
|
self.Locator.xpath_selector("//android.widget.EditText[@content-desc!='chat-message-input']")
|
||||||
|
|
||||||
|
|
||||||
class RequestPasswordIcon(BaseButton):
|
class RequestPasswordIcon(BaseButton):
|
||||||
|
@ -31,6 +31,12 @@ class RequestPasswordIcon(BaseButton):
|
||||||
super(RequestPasswordIcon, self).__init__(driver)
|
super(RequestPasswordIcon, self).__init__(driver)
|
||||||
self.locator = self.Locator.xpath_selector("//*[@content-desc='request-password']")
|
self.locator = self.Locator.xpath_selector("//*[@content-desc='request-password']")
|
||||||
|
|
||||||
|
def click(self):
|
||||||
|
self.wait_for_element(60)
|
||||||
|
self.find_element().click()
|
||||||
|
logging.info('Tap on %s' % self.name)
|
||||||
|
return self.navigate()
|
||||||
|
|
||||||
|
|
||||||
class HomeView(BaseViewObject):
|
class HomeView(BaseViewObject):
|
||||||
|
|
||||||
|
@ -45,5 +51,5 @@ class HomeView(BaseViewObject):
|
||||||
except (NoSuchElementException, TimeoutException):
|
except (NoSuchElementException, TimeoutException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.type_message_edit_box = TypeMessageEditBox(driver)
|
self.chat_request_input = ChatRequestInput(driver)
|
||||||
self.request_password_icon = RequestPasswordIcon(driver)
|
self.request_password_icon = RequestPasswordIcon(driver)
|
||||||
|
|
|
@ -14,7 +14,7 @@ class PasswordInput(BaseEditBox):
|
||||||
|
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
super(PasswordInput, self).__init__(driver)
|
super(PasswordInput, self).__init__(driver)
|
||||||
self.locator = self.Locator.xpath_selector("//android.widget.EditText")
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Password']")
|
||||||
|
|
||||||
|
|
||||||
class SignInButton(BaseButton):
|
class SignInButton(BaseButton):
|
||||||
|
@ -24,6 +24,28 @@ class SignInButton(BaseButton):
|
||||||
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Sign in']")
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Sign in']")
|
||||||
|
|
||||||
|
|
||||||
|
class RecoverAccessButton(BaseButton):
|
||||||
|
|
||||||
|
def __init__(self, driver):
|
||||||
|
super(RecoverAccessButton, self).__init__(driver)
|
||||||
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Recover access']")
|
||||||
|
|
||||||
|
|
||||||
|
class PassphraseInput(BaseEditBox):
|
||||||
|
|
||||||
|
def __init__(self, driver):
|
||||||
|
super(PassphraseInput, self).__init__(driver)
|
||||||
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Passphrase']")
|
||||||
|
|
||||||
|
|
||||||
|
class ConfirmRecoverAccess(BaseButton):
|
||||||
|
|
||||||
|
def __init__(self, driver):
|
||||||
|
super(ConfirmRecoverAccess, self).__init__(driver)
|
||||||
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='RECOVER ACCESS']")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LoginView(BaseViewObject):
|
class LoginView(BaseViewObject):
|
||||||
|
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
|
@ -33,3 +55,7 @@ class LoginView(BaseViewObject):
|
||||||
self.first_account_button = FirstAccountButton(self.driver)
|
self.first_account_button = FirstAccountButton(self.driver)
|
||||||
self.password_input = PasswordInput(self.driver)
|
self.password_input = PasswordInput(self.driver)
|
||||||
self.sign_in_button = SignInButton(self.driver)
|
self.sign_in_button = SignInButton(self.driver)
|
||||||
|
|
||||||
|
self.recover_access_button = RecoverAccessButton(self.driver)
|
||||||
|
self.passphrase_input = PassphraseInput(self.driver)
|
||||||
|
self.confirm_recover_access = ConfirmRecoverAccess(self.driver)
|
||||||
|
|
Loading…
Reference in New Issue