From b8c7e443265b52acb5b0f422259a0204efb54fe0 Mon Sep 17 00:00:00 2001 From: Churikova Tetiana Date: Mon, 24 Feb 2020 12:30:45 +0100 Subject: [PATCH] fix e2e Signed-off-by: Churikova Tetiana --- ci/tests/Jenkinsfile.e2e-nightly | 4 ++ ci/tests/Jenkinsfile.e2e-prs | 4 ++ test/appium/Jenkinsfile | 12 ---- test/appium/pytest.ini | 28 +++++++- test/appium/support/api/network_api.py | 15 +++-- test/appium/tests/__init__.py | 9 ++- .../atomic/account_management/test_profile.py | 66 +++++++++---------- .../test_wallet_management.py | 1 + .../tests/atomic/chats/test_group_chat.py | 2 + .../dapps_and_browsing/test_browsing.py | 29 ++++---- .../dapps_and_browsing/test_deep_links.py | 4 ++ .../tests/atomic/transactions/test_wallet.py | 1 - test/appium/tests/base_test_case.py | 1 - test/appium/tests/marks.py | 1 - test/appium/views/base_element.py | 4 +- 15 files changed, 111 insertions(+), 70 deletions(-) delete mode 100644 test/appium/Jenkinsfile diff --git a/ci/tests/Jenkinsfile.e2e-nightly b/ci/tests/Jenkinsfile.e2e-nightly index 927ec0f1d9..0758471d6b 100644 --- a/ci/tests/Jenkinsfile.e2e-nightly +++ b/ci/tests/Jenkinsfile.e2e-nightly @@ -40,6 +40,10 @@ pipeline { usernameVariable: 'SAUCE_USERNAME', passwordVariable: 'SAUCE_ACCESS_KEY' ), + string( + credentialsId: 'etherscan-api-key', + variable: 'ETHERSCAN_API_KEY' + ), ]) { dir('test/appium/tests') { sh """ diff --git a/ci/tests/Jenkinsfile.e2e-prs b/ci/tests/Jenkinsfile.e2e-prs index f911d039fc..aa85e4235d 100644 --- a/ci/tests/Jenkinsfile.e2e-prs +++ b/ci/tests/Jenkinsfile.e2e-prs @@ -75,6 +75,10 @@ pipeline { usernameVariable: 'SAUCE_USERNAME', passwordVariable: 'SAUCE_ACCESS_KEY' ), + string( + credentialsId: 'etherscan-api-key', + variable: 'ETHERSCAN_API_KEY' + ), ]) { dir('test/appium/tests') { sh """ diff --git a/test/appium/Jenkinsfile b/test/appium/Jenkinsfile deleted file mode 100644 index 185cd6c7ab..0000000000 --- a/test/appium/Jenkinsfile +++ /dev/null @@ -1,12 +0,0 @@ -node ('linux1'){sauce('12e007ad-48cf-4c20-92f3-b923bb5641bd'){ - checkout([$class: 'GitSCM', branches: [[name: 'tests/align-with-start-chat-redesign-#3195']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/status-im/status-react.git']]]) - currentBuild.displayName = "PR-$pr_id" - try {withCredentials([string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GIT_HUB_TOKEN'), string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'SAUCE_ACCESS_KEY'), string(credentialsId: 'SAUCE_USERNAME', variable: 'SAUCE_USERNAME')]){ - sh 'cd test/appium/tests && python3 -m pytest -m all --pr_number=$pr_id --build=PR-$pr_id -n12 $apk' - } - } - finally { - saucePublisher() - junit testDataPublishers: [[$class: 'SauceOnDemandReportPublisher', jobVisibility: 'public']], testResults: 'test/appium/tests/*.xml' } - } -} diff --git a/test/appium/pytest.ini b/test/appium/pytest.ini index 2d92e2f00b..f39564d322 100644 --- a/test/appium/pytest.ini +++ b/test/appium/pytest.ini @@ -1,3 +1,29 @@ [pytest] norecursedirs = .git views -addopts = -s -v --tb=line --junitxml=result.xml \ No newline at end of file +addopts = -s -v --tb=line --junitxml=result.xml +junit_family=legacy +markers = + critical: TCs by priority + high: TCs by priority + medium: TCs by priority + low: TCs by priority + + upgrade: TCs by area + chat: TCs by area + chat_management: TCs by area + wallet: TCs by area + logcat: TCs by area + dapps: TCs by area + sign_in: TCs by area + transaction: TCs by area + + pr + account + testrail_case_id + api + all + message_reliability + performance + battery_consumption + translations + chatbot \ No newline at end of file diff --git a/test/appium/support/api/network_api.py b/test/appium/support/api/network_api.py index 610b6963a6..d85c61a908 100644 --- a/test/appium/support/api/network_api.py +++ b/test/appium/support/api/network_api.py @@ -6,6 +6,7 @@ import requests import time from json import JSONDecodeError from decimal import Decimal +from os import environ import tests @@ -21,12 +22,18 @@ class NetworkApi(object): self.chat_bot_url = 'http://offsite.chat:8099' def get_transactions(self, address: str) -> List[dict]: - method = self.network_url + 'module=account&action=txlist&address=0x%s&sort=desc' % address - return requests.request('GET', url=method, headers=self.headers).json()['result'] + method = self.network_url + 'module=account&action=txlist&address=0x%s&sort=desc&apikey=%s' % (address, environ.get('ETHERSCAN_API_KEY')) + try: + return requests.request('GET', url=method, headers=self.headers).json()['result'] + except TypeError: + print('Check response from etherscan API. Returned values don\'t match expected') def get_token_transactions(self, address: str) -> List[dict]: - method = self.network_url + 'module=account&action=tokentx&address=0x%s&sort=desc' % address - return requests.request('GET', url=method, headers=self.headers).json()['result'] + method = self.network_url + 'module=account&action=tokentx&address=0x%s&sort=desc&apikey=%s' % (address, environ.get('ETHERSCAN_API_KEY')) + try: + return requests.request('GET', url=method, headers=self.headers).json()['result'] + except TypeError: + print('Check response from etherscan API. Returned values don\'t match expected') def is_transaction_successful(self, transaction_hash: str) -> int: method = self.network_url + 'module=transaction&action=getstatus&txhash=%s' % transaction_hash diff --git a/test/appium/tests/__init__.py b/test/appium/tests/__init__.py index 60cb568457..be63f5709e 100644 --- a/test/appium/tests/__init__.py +++ b/test/appium/tests/__init__.py @@ -30,12 +30,15 @@ appium_container = AppiumContainer() common_password = 'qwerty' unique_password = 'unique' + get_current_time() -bootnode_address = "enode://436cc6f674928fdc9a9f7990f2944002b685d1c37f025c1be425185b5b1f0900feaf1ccc2a6130268f9901be4a7d252f37302c8335a2c1a62736e9232691cc3a@178.128.138.128:443" -mailserver_address = "enode://ee2b53b0ace9692167a410514bca3024695dbf0e1a68e1dff9716da620efb195f04a4b9e873fb9b74ac84de801106c465b8e2b6c4f0d93b8749d1578bfcaf03e@104.197.238.144:443" +bootnode_address = "enode://a8a97f126f5e3a340cb4db28a1187c325290ec08b2c9a6b1f19845ac86c46f9fac2ba13328822590" \ + "fd3de3acb09cc38b5a05272e583a2365ad1fa67f66c55b34@167.99.210.203:30404" +# referred to https://github.com/status-im/status-react/blob/1ea49a80fc915aa3174ecfd9649c3bab6480d30d/src/status_im/constants.cljs#L40 +mailserver_address = "enode://ee2b53b0ace9692167a410514bca3024695dbf0e1a68e1dff9716da620efb195f04a4b9e873fb9b74ac84de80" \ + "1106c465b8e2b6c4f0d93b8749d1578bfcaf03e:status-offline-inbox@104.197.238.144:443" staging_fleet = 'eth.staging' prod_fleet = 'eth.prod' mailserver_ams = 'mail-01.do-ams3' -mailserver_hk = 'mail-01.ac-cn-hongkong-c' +mailserver_hk = 'mail-02.ac-cn-hongkong-c' mailserver_gc = 'mail-01.gc-us-central1-a' mailserver_ams_01 = 'mail-01.do-ams3.eth.prod' camera_access_error_text = "To grant the required camera permission, please go to your system settings " \ diff --git a/test/appium/tests/atomic/account_management/test_profile.py b/test/appium/tests/atomic/account_management/test_profile.py index 4dae1c162e..046510cdfc 100644 --- a/test/appium/tests/atomic/account_management/test_profile.py +++ b/test/appium/tests/atomic/account_management/test_profile.py @@ -746,43 +746,43 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase): profile_1.mail_server_by_name(server_name).click() profile_1.mail_server_connect_button.click() profile_1.confirm_button.click() - profile_1.home_button.click() - if not profile_1.element_by_text_part('Error connecting').is_element_displayed(30): sign_in_1.driver.fail("No popup with 'Error connecting' is shown") profile_1.element_by_text('CANCEL').click() - home_2.just_fyi('send several messages to public channel') - public_chat_name = home_2.get_public_chat_name() - message = 'test_message' - public_chat_2 = home_2.join_public_chat(public_chat_name) - public_chat_2.chat_message_input.send_keys(message) - public_chat_2.send_message_button.click() - public_chat_2.back_button.click() + # TODO: blocked by 10065 + # profile_1.home_button.click() + # home_2.just_fyi('send several messages to public channel') + # public_chat_name = home_2.get_public_chat_name() + # message = 'test_message' + # public_chat_2 = home_2.join_public_chat(public_chat_name) + # public_chat_2.chat_message_input.send_keys(message) + # public_chat_2.send_message_button.click() + # public_chat_2.back_button.click() + # + # profile_1.just_fyi('join same public chat and try to reconnect via "Tap to reconnect" and check "Connecting"') + # profile_1.home_button.click() + # home_1.join_public_chat(public_chat_name) + # public_chat_1 = home_1.get_chat_view() + # chat_state = 'Could not connect to mailserver. Tap to reconnect' + # public_chat_1.element_by_text(chat_state).click() + # if not public_chat_1.element_by_text_part('Connecting').is_element_displayed(): + # self.errors.append("Indicator doesn't show 'Connecting'") - profile_1.just_fyi('join same public chat and try to reconnect via "Tap to reconnect" and check "Connecting"') - profile_1.home_button.click() - home_1.join_public_chat(public_chat_name) - public_chat_1 = home_1.get_chat_view() - chat_state = 'Could not connect to mailserver. Tap to reconnect' - public_chat_1.element_by_text(chat_state).click() - if not public_chat_1.element_by_text_part('Connecting').is_element_displayed(): - self.errors.append("Indicator doesn't show 'Connecting'") - - profile_1.just_fyi('check that can RETRY to connect') - for _ in range(2): - public_chat_1.element_by_text('RETRY').wait_for_element(30) - public_chat_1.element_by_text('RETRY').click() - - profile_1.just_fyi('check that can pick another mailserver and receive messages') - public_chat_1.element_by_text('PICK ANOTHER').is_element_displayed(30) - public_chat_1.element_by_text_part('PICK ANOTHER').click() - mailserver = profile_1.return_mailserver_name(mailserver_ams, prod_fleet) - profile_1.element_by_text(mailserver).click() - profile_1.confirm_button.click() - profile_1.home_button.click() - if not public_chat_1.chat_element_by_text(message).is_element_displayed(30): - self.errors.append("Chat history wasn't fetched") + # profile_1.just_fyi('check that can RETRY to connect') + # for _ in range(2): + # public_chat_1.element_by_text('RETRY').wait_for_element(30) + # public_chat_1.element_by_text('RETRY').click() + # + # profile_1.just_fyi('check that can pick another mailserver and receive messages') + # public_chat_1.element_by_text('PICK ANOTHER').is_element_displayed(30) + # public_chat_1.element_by_text_part('PICK ANOTHER').click() + # mailserver = profile_1.return_mailserver_name(mailserver_ams, prod_fleet) + # profile_1.element_by_text(mailserver).click() + # profile_1.confirm_button.click() + # profile_1.home_button.click() + # if not public_chat_1.chat_element_by_text(message).is_element_displayed(30): + # self.errors.append("Chat history wasn't fetched") self.errors.verify_no_errors() @@ -851,7 +851,7 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase): @marks.testrail_id(5680) @marks.high @marks.skip - # skip until edit userpic is enabled back + # TODO: skip until edit userpic is enabled back def test_pair_devices_sync_name_photo_public_group_chats(self): self.create_drivers(2) device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) diff --git a/test/appium/tests/atomic/account_management/test_wallet_management.py b/test/appium/tests/atomic/account_management/test_wallet_management.py index aba0257baa..022e3a9feb 100644 --- a/test/appium/tests/atomic/account_management/test_wallet_management.py +++ b/test/appium/tests/atomic/account_management/test_wallet_management.py @@ -119,6 +119,7 @@ class TestWalletManagement(SingleDeviceTestCase): address = wallet.get_wallet_address() self.network_api.get_donate(address[2:]) wallet.back_button.click() + wallet.wait_balance_is_changed() if not wallet.backup_recovery_phrase_warning_text.is_element_present(30): self.driver.fail("'Back up your seed phrase' warning is not shown on Wallet with funds") wallet.backup_recovery_phrase_warning_text.click() diff --git a/test/appium/tests/atomic/chats/test_group_chat.py b/test/appium/tests/atomic/chats/test_group_chat.py index c13aef529e..f02557dd08 100644 --- a/test/appium/tests/atomic/chats/test_group_chat.py +++ b/test/appium/tests/atomic/chats/test_group_chat.py @@ -224,6 +224,8 @@ class TestGroupChatMultipleDevice(MultipleDeviceTestCase): @marks.testrail_id(4001) @marks.high + @marks.skip + # TODO:should be retested after fix 10054 def test_remove_member_from_group_chat(self): self.create_drivers(2) message_for_device_2 = 'This message should not be visible for device 2' diff --git a/test/appium/tests/atomic/dapps_and_browsing/test_browsing.py b/test/appium/tests/atomic/dapps_and_browsing/test_browsing.py index 1cdb5a579d..9239773a8c 100644 --- a/test/appium/tests/atomic/dapps_and_browsing/test_browsing.py +++ b/test/appium/tests/atomic/dapps_and_browsing/test_browsing.py @@ -25,20 +25,22 @@ class TestBrowsing(SingleDeviceTestCase): sign_in = SignInView(self.driver) home_view = sign_in.create_user() dapp_view = home_view.dapp_tab_button.click() - ru_url = 'https://status.im/ru/' + ru_url = 'https://ru.m.wikipedia.org' browsing_view = dapp_view.open_url(ru_url) - browsing_view.find_text_part('Частная, безопасная связь') + browsing_view.find_text_part('Добро пожаловать') - browsing_view.just_fyi('Navigate to get-involved and back') - browsing_view.element_by_text_part('Участвовать').click() + browsing_view.just_fyi('Navigate to next page and back') + browsing_view.element_by_text_part('свободную энциклопедию').click() + browsing_view.element_by_text_part('Свободный контент') browsing_view.browser_previous_page_button.click() - browsing_view.just_fyi('Relogin and check that tap on "Next" navigates to get-involved') + browsing_view.just_fyi('Relogin and check that tap on "Next" navigates to next page') browsing_view.relogin() home_view.dapp_tab_button.click() dapp_view.element_by_text_part(ru_url).click() browsing_view.browser_next_page_button.click() - browsing_view.find_text_part('Сообщество с открытым исходным кодом') + if not browsing_view.element_by_text_part('Свободный контент').is_element_displayed(20): + self.driver.fail("Browser history is not kept after relogin") @marks.testrail_id(5438) @marks.medium @@ -137,14 +139,14 @@ class TestBrowsing(SingleDeviceTestCase): sign_in = SignInView(self.driver) home = sign_in.create_user() daap_view = home.dapp_tab_button.click() - browsing_view = daap_view.open_url('status.im') - browsing_view.element_by_text_part('Get Involved', 'button').click() - browsing_view.find_text_part('An Open Source Community') + browsing_view = daap_view.open_url('dap.ps') + browsing_view.element_by_text_part('View all', 'button').click() + if browsing_view.element_by_text_part('View all').is_element_displayed(20): + self.driver.fail("Failed to access Categories using ''View all'") browsing_view.browser_previous_page_button.click() - browsing_view.find_text_part('Get Status', 15) - + browsing_view.find_text_part('Categories', 15) browsing_view.browser_next_page_button.click() - browsing_view.find_text_part('An Open Source Community') + browsing_view.find_text_part('Exchanges', 15) browsing_view.back_to_home_button.click() @marks.testrail_id(5354) @@ -160,6 +162,9 @@ class TestBrowsing(SingleDeviceTestCase): @marks.testrail_id(5785) @marks.critical + @marks.skip + #TODO: needs to be updated; skipped due to changing DApps in Discover, also not possible to use search + # (no suggestions on emulators) def test_can_open_dapp_from_dapp_store(self): sign_in = SignInView(self.driver) home = sign_in.create_user() diff --git a/test/appium/tests/atomic/dapps_and_browsing/test_deep_links.py b/test/appium/tests/atomic/dapps_and_browsing/test_deep_links.py index 9f5a432899..49500cc31b 100644 --- a/test/appium/tests/atomic/dapps_and_browsing/test_deep_links.py +++ b/test/appium/tests/atomic/dapps_and_browsing/test_deep_links.py @@ -25,6 +25,8 @@ class TestDeepLinks(SingleDeviceTestCase): @marks.testrail_id(5441) @marks.medium + @marks.skip + # TODO: uncomment after https://github.com/status-im/universal-links-handler/pull/29 will be implemented in app def test_open_user_profile_using_deep_link(self): sign_in_view = SignInView(self.driver) sign_in_view.create_user() @@ -39,6 +41,8 @@ class TestDeepLinks(SingleDeviceTestCase): @marks.testrail_id(5442) @marks.medium + @marks.skip + # TODO: uncomment after https://github.com/status-im/universal-links-handler/pull/29 will be implemented in app def test_open_dapp_using_deep_link(self): sign_in_view = SignInView(self.driver) sign_in_view.create_user() diff --git a/test/appium/tests/atomic/transactions/test_wallet.py b/test/appium/tests/atomic/transactions/test_wallet.py index 438e8b664c..9e2da2b59a 100644 --- a/test/appium/tests/atomic/transactions/test_wallet.py +++ b/test/appium/tests/atomic/transactions/test_wallet.py @@ -128,7 +128,6 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase): sign_in_view.just_fyi('Restore account with funds offline') sign_in_view.toggle_airplane_mode() - sign_in_view.access_key_button.click() sign_in_view.recover_access(sender['passphrase']) home_view = sign_in_view.get_home_view() wallet_view = home_view.wallet_button.click() diff --git a/test/appium/tests/base_test_case.py b/test/appium/tests/base_test_case.py index 22a2c8ccd8..f8a2d2277d 100644 --- a/test/appium/tests/base_test_case.py +++ b/test/appium/tests/base_test_case.py @@ -14,7 +14,6 @@ from selenium.common.exceptions import WebDriverException from support.api.network_api import NetworkApi from support.github_report import GithubHtmlReport -from support.message_reliability_report import create_one_to_one_chat_report, create_public_chat_report from tests import test_suite_data, start_threads, appium_container, pytest_config_global class AbstractTestCase: diff --git a/test/appium/tests/marks.py b/test/appium/tests/marks.py index f78f073ba8..74eb70428c 100644 --- a/test/appium/tests/marks.py +++ b/test/appium/tests/marks.py @@ -1,6 +1,5 @@ import pytest -pr = pytest.mark.pr testrail_case_id = pytest.mark.testrail_case_id testrail_id = pytest.mark.testrail_id # atomic tests critical = pytest.mark.critical diff --git a/test/appium/views/base_element.py b/test/appium/views/base_element.py index e9fc6f31e4..db17783b0d 100644 --- a/test/appium/views/base_element.py +++ b/test/appium/views/base_element.py @@ -179,11 +179,11 @@ class BaseElement(object): width, height = size['width'], size['height'] self.driver.swipe(start_x=x + width * 0.75, start_y=y + height / 2, end_x=x, end_y=y + height / 2) - def swipe_to_web_element(self): + def swipe_to_web_element(self, depth=400): element = self.find_element() location = element.location x, y = location['x'], location['y'] - self.driver.swipe(start_x=x, start_y=y, end_x=x, end_y=400) + self.driver.swipe(start_x=x, start_y=y, end_x=x, end_y=depth) def long_press_element(self): element = self.find_element()