diff --git a/test/appium/Jenkinsfile b/test/appium/Jenkinsfile index c76551aa0e..aac0d1b8d9 100644 --- a/test/appium/Jenkinsfile +++ b/test/appium/Jenkinsfile @@ -1,6 +1,6 @@ node {sauce('b9aded57-5cc1-4f6b-b5ea-42d989987852') { checkout([$class: 'GitSCM', branches: [[name: '*/develop']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/status-im/status-react.git']]]) - try {sh 'cd test/appium/tests && /usr/local/bin/python3 -m pytest -m all --build ${JOB_NAME}__${BUILD_NUMBER} -v --dist=loadscope -n3' + try {sh 'cd test/appium/tests && /usr/local/bin/python3 -m pytest -m all --build ${JOB_NAME}__${BUILD_NUMBER} -v --dist=loadscope -n4' } finally { saucePublisher() diff --git a/test/appium/tests/test_sanity.py b/test/appium/tests/test_sanity.py index 112b235a74..503f1dc8a3 100644 --- a/test/appium/tests/test_sanity.py +++ b/test/appium/tests/test_sanity.py @@ -44,7 +44,7 @@ class TestAccess(SingleDeviceTestCase): login.first_account_button.click() login.password_input.send_keys(verifications[verification]['input']) login.sign_in_button.click() - home.find_full_text(verifications[verification]["outcome"], 10) + home.find_full_text(verifications[verification]["outcome"], 60) @pytest.mark.parametrize("verification", ["short", "mismatch"]) def test_password(self, verification): diff --git a/test/appium/tests/test_transaction.py b/test/appium/tests/test_transaction.py index ab038d00b6..3a24a9012e 100644 --- a/test/appium/tests/test_transaction.py +++ b/test/appium/tests/test_transaction.py @@ -29,9 +29,6 @@ class TestTransactions(SingleDeviceTestCase): 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) @@ -65,8 +62,9 @@ class TestTransactions(SingleDeviceTestCase): chats.find_full_text('Wrong password', 20) else: - chats.enter_password_input.send_keys(transaction_users[recipient]['password']) + chats.enter_password_input.send_keys(transaction_users[sender]['password']) chats.sign_transaction_button.click() + chats.got_it_button.click() chats.find_full_text('0.1') chats.find_full_text('Sent', 60) if test == 'group_chat': @@ -85,8 +83,6 @@ class TestTransactions(SingleDeviceTestCase): transaction_users['B_USER']['passphrase'], transaction_users['B_USER']['password'], transaction_users['B_USER']['username']) - if chats.get_balance(address) < 1000000000000000000: - chats.get_donate(address) contacts = chats.contacts_button.click() auction_house = contacts.auction_house_button.click() @@ -102,5 +98,6 @@ class TestTransactions(SingleDeviceTestCase): chats.sign_transaction_button.click() chats.enter_password_input.send_keys(transaction_users['B_USER']['password']) chats.sign_transaction_button.click() + chats.got_it_button.click() auction_house.find_full_text('You are the proud owner of the name: ' + auction_name, 120) chats.verify_balance_is_updated(initial_balance, address) diff --git a/test/appium/tests/test_wallet.py b/test/appium/tests/test_wallet.py new file mode 100644 index 0000000000..45df243144 --- /dev/null +++ b/test/appium/tests/test_wallet.py @@ -0,0 +1,68 @@ +import pytest +import time +from tests.basetestcase import SingleDeviceTestCase +from views.home import HomeView +from tests.preconditions import set_password_as_new_user, recover_access +from tests import transaction_users + + +@pytest.mark.all +class TestWallet(SingleDeviceTestCase): + + @pytest.mark.wallet + def test_insufficient_funds(self): + home = HomeView(self.driver) + set_password_as_new_user(home) + chats = home.get_chats() + chats.back_button.click() + wallet_view = chats.wallet_button.click() + wallet_view.send_button.click() + wallet_view.amount_edit_box.send_keys('0,1') + wallet_view.find_full_text('Insufficient funds') + + @pytest.mark.wallet + @pytest.mark.parametrize("test, recipient, sender", [('sign_now', 'A_USER', 'B_USER'), + ('sign_later', 'B_USER', 'A_USER')], + ids=['sign_now', 'sign_later']) + def test_send_transaction_from_wallet(self, test, recipient, sender): + home = HomeView(self.driver) + set_password_as_new_user(home) + chats = home.get_chats() + recipient_key = transaction_users[recipient]['public_key'] + recipient_address = transaction_users[recipient]['address'] + initial_balance_recipient = chats.get_balance(recipient_address) + recover_access(chats, + transaction_users[sender]['passphrase'], + transaction_users[sender]['password'], + transaction_users[sender]['username']) + chats.wait_for_syncing_complete() + 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() + for _ in range(2): + chats.back_button.click() + wallet = chats.wallet_button.click() + wallet.send_button.click() + wallet.amount_edit_box.click() + wallet.send_as_keyevent('0,1') + wallet.confirm() + wallet.chose_recipient_button.click() + wallet.deny_button.click() + wallet.chose_from_contacts_button.click() + user_contact = chats.element_by_text(transaction_users[recipient]['username'], 'button') + user_contact.click() + if test == 'sign_later': + chats.sign_later_button.click() + wallet.yes_button.click() + wallet.ok_button_apk.click() + wallet.transactions_icon.click() + wallet.unsigned_tab.click() + wallet.sign_button.click() + chats.sign_transaction_button.click() + chats.enter_password_input.send_keys(transaction_users[sender]['password']) + chats.sign_transaction_button.click() + chats.got_it_button.click() + chats.verify_balance_is_updated(initial_balance_recipient, recipient_address) + diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index 842434b03e..a1ff5ad400 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -18,6 +18,13 @@ class BackButton(BaseButton): return self.navigate() +class DenyButton(BaseButton): + + def __init__(self, driver): + super(DenyButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Deny']") + + class ContactsButton(BaseButton): def __init__(self, driver): @@ -29,12 +36,59 @@ class ContactsButton(BaseButton): return ContactsViewObject(self.driver) +class WalletButton(BaseButton): + + def __init__(self, driver): + super(WalletButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Wallet']") + + def navigate(self): + from views.wallet import WalletViewObject + return WalletViewObject(self.driver) + + +class YesButton(BaseButton): + + def __init__(self, driver): + super(YesButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Yes']") + + +class NoButton(BaseButton): + + def __init__(self, driver): + super(NoButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='No']") + + +class OkButtonAPK(BaseButton): + + def __init__(self, driver): + super(OkButtonAPK, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='OK']") + + +class ContinueButtonAPK(BaseButton): + + def __init__(self, driver): + super(ContinueButtonAPK, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Continue']") + + class BaseViewObject(object): def __init__(self, driver): self.driver = driver + + self.yes_button = YesButton(self.driver) + self.no_button = NoButton(self.driver) self.back_button = BackButton(self.driver) + self.deny_button = DenyButton(self.driver) + self.continue_button_apk = ContinueButtonAPK(driver) + self.ok_button_apk = OkButtonAPK(driver) + self.contacts_button = ContactsButton(self.driver) + self.wallet_button = WalletButton(self.driver) def confirm(self): logging.info("Tap 'Confirm' on native keyboard") @@ -87,18 +141,19 @@ class BaseViewObject(object): 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() counter = 0 - while True: - if counter == wait_time: - pytest.fail("Donation was not received during %s seconds!" % wait_time) - elif self.get_balance(address) == initial_balance: - counter += 10 - time.sleep(10) - logging.info('Waiting %s seconds for donation' % counter) - else: - logging.info('Got %s for %s' % (response["amount"], address)) - break + if initial_balance < 1000000000000000000: + response = requests.request('GET', 'http://46.101.129.137:3001/donate/0x%s' % address).json() + while True: + if counter == wait_time: + pytest.fail("Donation was not received during %s seconds!" % wait_time) + elif self.get_balance(address) == initial_balance: + counter += 10 + time.sleep(10) + logging.info('Waiting %s seconds for donation' % counter) + else: + logging.info('Got %s for %s' % (response["amount"], address)) + break def verify_balance_is_updated(self, initial_balance, recipient_address, wait_time=120): counter = 0 diff --git a/test/appium/views/chats.py b/test/appium/views/chats.py index 7dfcda6cfa..0da1d9a9e3 100644 --- a/test/appium/views/chats.py +++ b/test/appium/views/chats.py @@ -179,6 +179,12 @@ class SendFundsButton(BaseButton): super(SendFundsButton.SignTransactionButton, self).__init__(driver) self.locator = self.Locator.xpath_selector("//*[@text='SIGN TRANSACTION']") + class SignLaterButton(BaseButton): + + def __init__(self, driver): + super(SendFundsButton.SignLaterButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='SIGN LATER']") + class PasswordInput(BaseEditBox): def __init__(self, driver): @@ -204,8 +210,6 @@ class SendFundsButton(BaseButton): self.locator = self.Locator.xpath_selector("//*[@text='GOT IT']") - - class ChatsViewObject(BaseViewObject): def __init__(self, driver): @@ -237,8 +241,10 @@ class ChatsViewObject(BaseViewObject): self.user_name_text = UserNameText(self.driver) self.send_funds_button = SendFundsButton(self.driver) + self.first_recipient_button = SendFundsButton.FirstRecipient(self.driver) self.sign_transaction_button = SendFundsButton.SignTransactionButton(self.driver) + self.sign_later_button = SendFundsButton.SignLaterButton(self.driver) self.confirm_button = SendFundsButton.ConfirmButton(self.driver) self.password_input = SendFundsButton.PasswordInput(self.driver) self.enter_password_input = SendFundsButton.EnterPasswordInput(self.driver) diff --git a/test/appium/views/home.py b/test/appium/views/home.py index 51d8d8b56b..8ecd1b0b12 100644 --- a/test/appium/views/home.py +++ b/test/appium/views/home.py @@ -3,20 +3,6 @@ from views.base_element import * from tests import tests_data -class OkButtonAPK(BaseButton): - - def __init__(self, driver): - super(OkButtonAPK, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='OK']") - - -class ContinueButtonAPK(BaseButton): - - def __init__(self, driver): - super(ContinueButtonAPK, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='Continue']") - - class ChatRequestInput(BaseEditBox): def __init__(self, driver): @@ -42,8 +28,6 @@ class HomeView(BaseViewObject): def __init__(self, driver): super(HomeView, self).__init__(driver) - self.continue_button_apk = ContinueButtonAPK(driver) - self.ok_button_apk = OkButtonAPK(driver) for i in self.ok_button_apk, self.continue_button_apk: try: i.click() diff --git a/test/appium/views/login.py b/test/appium/views/login.py index 3efc842827..42f741abc4 100644 --- a/test/appium/views/login.py +++ b/test/appium/views/login.py @@ -45,7 +45,6 @@ class ConfirmRecoverAccess(BaseButton): self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='RECOVER ACCESS']") - class LoginView(BaseViewObject): def __init__(self, driver): diff --git a/test/appium/views/wallet.py b/test/appium/views/wallet.py new file mode 100644 index 0000000000..7a09dac311 --- /dev/null +++ b/test/appium/views/wallet.py @@ -0,0 +1,66 @@ +from views.base_view import BaseViewObject +import pytest +from views.base_element import * + + +class SendButton(BaseButton): + + def __init__(self, driver): + super(SendButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='SEND']") + + +class AmountEditBox(BaseEditBox, BaseButton): + + def __init__(self, driver): + super(AmountEditBox, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='0.000']") + + +class ChooseRecipientButton(BaseButton): + + def __init__(self, driver): + super(ChooseRecipientButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Choose recipient...']") + + +class TransactionsIcon(BaseButton): + + def __init__(self, driver): + super(TransactionsIcon, self).__init__(driver) + self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[4]') + + +class UnsignedTab(BaseButton): + + def __init__(self, driver): + super(UnsignedTab, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='UNSIGNED']") + + class SignButton(BaseButton): + + def __init__(self, driver): + super(UnsignedTab.SignButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='SIGN']") + + +class ChooseFromContactsButton(BaseButton): + + def __init__(self, driver): + super(ChooseFromContactsButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//*[@text='Choose From Contacts']") + + +class WalletViewObject(BaseViewObject): + + def __init__(self, driver): + super(WalletViewObject, self).__init__(driver) + self.driver = driver + + self.send_button = SendButton(self.driver) + self.amount_edit_box = AmountEditBox(self.driver) + self.chose_recipient_button = ChooseRecipientButton(self.driver) + self.chose_from_contacts_button = ChooseFromContactsButton(self.driver) + self.unsigned_tab = UnsignedTab(self.driver) + self.sign_button = UnsignedTab.SignButton(self.driver) + self.transactions_icon = TransactionsIcon(self.driver)