From 4eac209b9b7b1be75be487b3854d30a7a4cb7b08 Mon Sep 17 00:00:00 2001 From: Churikova Tetiana Date: Fri, 4 Oct 2019 15:50:44 +0200 Subject: [PATCH] 4 e2e fix Signed-off-by: Churikova Tetiana --- test/appium/support/api/network_api.py | 8 ++++ .../atomic/chats/test_chats_management.py | 41 ++++++++----------- .../atomic/dapps_and_browsing/test_dapps.py | 6 +-- .../tests/atomic/transactions/test_wallet.py | 12 ++++-- test/appium/views/base_view.py | 1 + 5 files changed, 38 insertions(+), 30 deletions(-) diff --git a/test/appium/support/api/network_api.py b/test/appium/support/api/network_api.py index f8c0fa73d8..5bc666890a 100644 --- a/test/appium/support/api/network_api.py +++ b/test/appium/support/api/network_api.py @@ -5,6 +5,7 @@ import pytest import requests import time from json import JSONDecodeError +from decimal import Decimal class NetworkApi(object): @@ -130,3 +131,10 @@ class NetworkApi(object): url = '%s/ping/%s?count=%s&interval=%s' % (self.chat_bot_url, chat_name, messages_number, interval) text = requests.request('GET', url).text return [i.split(maxsplit=5)[-1].strip('*') for i in text.splitlines()] + + def get_rounded_balance(self, fetched_balance, actual_balance): + fetched_balance, actual_balance = str(fetched_balance), str(actual_balance) + # get actual number of decimals on account balance + decimals = abs(Decimal(fetched_balance).as_tuple().exponent) + rounded_balance = round(float(actual_balance), decimals) + return rounded_balance \ No newline at end of file diff --git a/test/appium/tests/atomic/chats/test_chats_management.py b/test/appium/tests/atomic/chats/test_chats_management.py index 0002910bde..dd7fc87bbb 100644 --- a/test/appium/tests/atomic/chats/test_chats_management.py +++ b/test/appium/tests/atomic/chats/test_chats_management.py @@ -242,9 +242,9 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): message_before_block_1 = "Before block from %s" % device_1.driver.number message_before_block_2 = "Before block from %s" % device_2.driver.number message_after_block_2 = "After block from %s" % device_2.driver.number - home_1, home_2 = device_1.create_user(), device_2.recover_access(basic_user['passphrase']) + home_1, home_2 = device_1.create_user(), device_2.create_user() - # device 1, device 2: join to public chat and send several messages + device_1.just_fyi('both devices joining the same public chat and send messages') chat_name = device_1.get_public_chat_name() for home in home_1, home_2: home.join_public_chat(chat_name) @@ -253,27 +253,25 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): chat.chat_message_input.send_keys("Before block from %s" % chat.driver.number) chat.send_message_button.click() - # device 1: block user from public chat + device_1.just_fyi('block user') chat_element = chat_public_1.chat_element_by_text(message_before_block_2) chat_element.find_element() chat_element.member_photo.click() chat_public_1.profile_block_contact.click() chat_public_1.block_button.click() - # device 1: check that messages from blocked user are hidden in public chat + device_1.just_fyi('messages from blocked user are hidden in public chat and close app') if chat_public_1.chat_element_by_text(message_before_block_2).is_element_displayed(): self.errors.append( "Messages from blocked user %s are not cleared in public chat '%s'" % ( device_2.driver.number, chat_name)) - - # device 1: close app self.drivers[0].close_app() - # device 2: send message to public chat while device 1 is offline + device_2.just_fyi('send message to public chat while device 1 is offline') chat_public_2.chat_message_input.send_keys(message_after_block_2) chat_public_2.send_message_button.click() - # device 1: check that new messages from blocked user are not delivered + device_1.just_fyi('check that new messages from blocked user are not delivered') self.drivers[0].launch_app() device_1.accept_agreements() device_1.sign_in() @@ -292,12 +290,14 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): message_before_block_1 = "Before block from %s" % device_1.driver.number message_before_block_2 = "Before block from %s" % device_2.driver.number message_after_block_2 = "After block from %s" % device_2.driver.number - home_1, home_2 = device_1.create_user(), device_2.recover_access(basic_user['passphrase']) + home_1, home_2 = device_1.create_user(), device_2.create_user() profile_1 = home_1.profile_button.click() + device_2_public_key = home_2.get_public_key() + home_2.get_back_to_home_view() default_username_1 = profile_1.default_username_text.text profile_1.get_back_to_home_view() - # device 1, device 2: join to public chat and send several messages + device_1.just_fyi('both devices joining the same public chat and send messages') chat_name = device_1.get_public_chat_name() for home in home_1, home_2: home.join_public_chat(chat_name) @@ -309,8 +309,8 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): chat_public_1.get_back_to_home_view() chat_public_2.get_back_to_home_view() - # device 1, device 2: create 1-1 chat and send there several messages - chat_1 = home_1.add_contact(basic_user['public_key']) + device_1.just_fyi('both devices joining 1-1 chat and exchanging several messages') + chat_1 = home_1.add_contact(device_2_public_key) for _ in range(2): chat_1.chat_message_input.send_keys(message_before_block_1) chat_1.send_message_button.click() @@ -320,24 +320,22 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): chat_2.chat_message_input.send_keys(message_before_block_2) chat_2.send_message_button.click() - # device 1: block user from chat header + device_1.just_fyi('block user') chat_1.chat_options.click() chat_1.view_profile_button.click() chat_1.profile_block_contact.click() chat_1.block_button.click() - # device 1: check that chat with blocked user was deleted - # and messages from blocked user are hidden in public chat + device_1.just_fyi('no 1-1, messages from blocked user are hidden in public chat') if home_1.get_chat_with_user(basic_user['username']).is_element_displayed(): home_1.driver.fail("Chat with blocked user '%s' is not deleted" % device_2.driver.number) - public_chat_after_block = home_1.join_public_chat(chat_name) if public_chat_after_block.chat_element_by_text(message_before_block_2).is_element_displayed(): self.errors.append( "Messages from blocked user '%s' are not cleared in public chat '%s'" % (device_2.driver.number, chat_name)) - # device 2: send messages to 1-1 and public chat + device_2.just_fyi('send messages to 1-1 and public chat') for _ in range(2): chat_2.chat_message_input.send_keys(message_after_block_2) chat_2.send_message_button.click() @@ -349,18 +347,15 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): chat_public_2.chat_message_input.send_keys(message_after_block_2) chat_public_2.send_message_button.click() - # device 1: check that new messages sent from device 2 are not shown + device_1.just_fyi("check that new messages didn't arrived from blocked user") if public_chat_after_block.chat_element_by_text(message_after_block_2).is_element_displayed(): self.errors.append("Message from blocked user '%s' is received" % device_2.driver.number) public_chat_after_block.get_back_to_home_view() - if home_1.get_chat_with_user(basic_user['username']).is_element_displayed(): device_2.driver.fail("Chat with blocked user is reappeared after receiving new messages") - - # device 1: close app self.drivers[0].close_app() - # device 2: send message to 1-1 and public chat while device 1 is offline + device_2.just_fyi("send messages when device 1 is offline") for _ in range(2): chat_public_2.chat_message_input.send_keys(message_after_block_2) chat_public_2.send_message_button.click() @@ -370,7 +365,7 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): chat_2.chat_message_input.send_keys(message_after_block_2) chat_2.send_message_button.click() - # device 1: check that messages from blocked user are not fetched from offline + device_1.just_fyi("reopen app and check that messages from blocked user are not fetched") self.drivers[0].launch_app() device_1.accept_agreements() device_1.sign_in() diff --git a/test/appium/tests/atomic/dapps_and_browsing/test_dapps.py b/test/appium/tests/atomic/dapps_and_browsing/test_dapps.py index 4e5de434ab..12afe0f937 100644 --- a/test/appium/tests/atomic/dapps_and_browsing/test_dapps.py +++ b/test/appium/tests/atomic/dapps_and_browsing/test_dapps.py @@ -28,12 +28,12 @@ class TestDApps(SingleDeviceTestCase): sign_in_view = SignInView(self.driver) home_view = sign_in_view.recover_access(passphrase=user['passphrase']) status_test_dapp = home_view.open_status_test_dapp(allow_all=False) - status_test_dapp.status_api_button.click() - status_test_dapp.request_contact_code_button.click() + status_test_dapp.status_api_button.click_until_presence_of_element(status_test_dapp.request_contact_code_button) + status_test_dapp.request_contact_code_button.click_until_presence_of_element(status_test_dapp.deny_button) status_test_dapp.deny_button.click() if status_test_dapp.element_by_text(user['public_key']).is_element_displayed(): pytest.fail('Public key is returned but access was not allowed') - status_test_dapp.request_contact_code_button.click() + status_test_dapp.request_contact_code_button.click_until_presence_of_element(status_test_dapp.deny_button) status_test_dapp.allow_button.click() if not status_test_dapp.element_by_text(user['public_key']).is_element_displayed(): pytest.fail('Public key is not returned') diff --git a/test/appium/tests/atomic/transactions/test_wallet.py b/test/appium/tests/atomic/transactions/test_wallet.py index 21a3842956..a622de2036 100644 --- a/test/appium/tests/atomic/transactions/test_wallet.py +++ b/test/appium/tests/atomic/transactions/test_wallet.py @@ -1,5 +1,4 @@ import random - import pytest from support.utilities import get_merged_txs_list @@ -461,7 +460,8 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase): wallet_view.send_transaction_button.click() wallet_view.back_button.click() balance_after_receiving_tx = float(wallet_view.eth_asset_value.text) - if balance_after_receiving_tx != float(transaction_amount): + expected_balance = self.network_api.get_rounded_balance(balance_after_receiving_tx, transaction_amount) + if balance_after_receiving_tx != expected_balance: self.driver.fail('New account balance %s does not match expected %s after receiving a transaction' % ( balance_after_receiving_tx, transaction_amount)) @@ -484,12 +484,16 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase): self.network_api.verify_balance_is_updated(updated_balance, status_account_address) wallet_view.just_fyi("Verify total ETH on main wallet view") + self.network_api.wait_for_confirmation_of_transaction(status_account_address, transaction_amount_1) + self.network_api.verify_balance_is_updated((updated_balance + transaction_amount_1), status_account_address) send_transaction.back_button.click() balance_of_sub_account = float(self.network_api.get_balance(sub_account_address)) / 1000000000000000000 balance_of_status_account = float(self.network_api.get_balance(status_account_address)) / 1000000000000000000 - expected_balance = str(float(balance_after_receiving_tx) - transaction_amount_1 - float(total_fee)) total_eth_from_two_accounts = float(wallet_view.eth_asset_value.text) - if total_eth_from_two_accounts != (balance_of_status_account + balance_of_sub_account): + expected_balance = self.network_api.get_rounded_balance(total_eth_from_two_accounts, + (balance_of_status_account + balance_of_sub_account)) + + if total_eth_from_two_accounts != expected_balance: self.driver.fail('Total wallet balance %s != of Status account (%s) + SubAccount (%s)' % ( total_eth_from_two_accounts, balance_of_status_account, balance_of_sub_account)) diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index e9239897e4..ae9b00ff7b 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -386,6 +386,7 @@ class BaseView(object): counter += 1 def just_fyi(self, string): + self.driver.info('=========================================================================') self.driver.info(string) def click_system_back_button(self):