e2e tests reworked according to new 'start chat' and 'browse DAap' flows

Signed-off-by: Goran Jovic <goranjovic@gmail.com>
This commit is contained in:
Anton Danchenko 2018-02-07 15:18:55 +02:00 committed by Goran Jovic
parent faa690950f
commit cbc61500f7
No known key found for this signature in database
GPG Key ID: A778DE3CD7D2D10D
14 changed files with 68 additions and 39 deletions

3
Jenkinsfile vendored
View File

@ -91,12 +91,11 @@ node ('macos1') {
'\niOS: ' + ipaUrl '\niOS: ' + ipaUrl
} }
stage('Run e2e tests') { stage('Upload apk for e2e tests') {
if (env.CHANGE_ID != null){ if (env.CHANGE_ID != null){
withCredentials([string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'key'), string(credentialsId: 'SAUCE_USERNAME', variable: 'username')]){ withCredentials([string(credentialsId: 'SAUCE_ACCESS_KEY', variable: 'key'), string(credentialsId: 'SAUCE_USERNAME', variable: 'username')]){
def apk_name = env.CHANGE_ID + '.apk' def apk_name = env.CHANGE_ID + '.apk'
sh('curl -u ' + username+ ':' + key + ' -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/' + username + '/' + apk_name + '?overwrite=true --data-binary @android/app/build/outputs/apk/release/app-release.apk') sh('curl -u ' + username+ ':' + key + ' -X POST -H "Content-Type: application/octet-stream" https://saucelabs.com/rest/v1/storage/' + username + '/' + apk_name + '?overwrite=true --data-binary @android/app/build/outputs/apk/release/app-release.apk')
build job: 'end-to-end-tests/status-app-end-to-end-tests', parameters: [string(name: 'apk', value: '--apk=' + apk_name), string(name: 'pr_id', value: env.CHANGE_ID)], wait: false
} }
} }
} }

View File

@ -1,9 +1,12 @@
node {sauce('b9aded57-5cc1-4f6b-b5ea-42d989987852') { node ('linux1'){sauce('12e007ad-48cf-4c20-92f3-b923bb5641bd'){
checkout([$class: 'GitSCM', branches: [[name: '*/develop']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/status-im/status-react.git']]]) 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']]])
try {sh 'cd test/appium/tests && /usr/local/bin/python3 -m pytest -m all --build ${JOB_NAME}__${BUILD_NUMBER} -v --dist=loadscope -n4' 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 { finally {
saucePublisher() saucePublisher()
junit testDataPublishers: [[$class: 'SauceOnDemandReportPublisher', jobVisibility: 'public']], testResults: 'test/appium/tests/*.xml' } junit testDataPublishers: [[$class: 'SauceOnDemandReportPublisher', jobVisibility: 'public']], testResults: 'test/appium/tests/*.xml' }
} }
} }

View File

@ -123,6 +123,7 @@ class SingleDeviceTestCase(AbstractTestCase):
class LocalMultipleDeviceTestCase(AbstractTestCase): class LocalMultipleDeviceTestCase(AbstractTestCase):
def setup_method(self, method): def setup_method(self, method):
self.update_test_info_dict()
self.drivers = dict() self.drivers = dict()
def create_drivers(self, quantity): def create_drivers(self, quantity):
@ -130,6 +131,7 @@ class LocalMultipleDeviceTestCase(AbstractTestCase):
for driver in range(quantity): for driver in range(quantity):
self.drivers[driver] = webdriver.Remote(self.executor_local, capabilities[driver]) self.drivers[driver] = webdriver.Remote(self.executor_local, capabilities[driver])
self.drivers[driver].implicitly_wait(self.implicitly_wait) self.drivers[driver].implicitly_wait(self.implicitly_wait)
test_data.test_info[test_data.test_name]['jobs'].append(self.drivers[driver].session_id)
def teardown_method(self, method): def teardown_method(self, method):
for driver in self.drivers: for driver in self.drivers:

View File

@ -47,7 +47,7 @@ class TestMultipleDevices(MultipleDeviceTestCase):
device_2_home.add_contact(device_1_public_key) device_2_home.add_contact(device_1_public_key)
device_2_chat = device_2_home.get_chat_view() device_2_chat = device_2_home.get_chat_view()
device_1_user_name = device_2_chat.user_name_text.text device_1_user_name = device_2_chat.user_name_text.text
device_2_home.back_button.click(times_to_click=3) device_2_home.back_button.click(times_to_click=2)
chat_name = 'new_chat' chat_name = 'new_chat'
message_1 = 'first SOMETHING' message_1 = 'first SOMETHING'
message_2 = 'second SOMETHING' message_2 = 'second SOMETHING'
@ -104,7 +104,7 @@ class TestMultipleDevices(MultipleDeviceTestCase):
device_2_home = device_2.get_home_view() device_2_home = device_2.get_home_view()
device_1_home = device_1.get_home_view() device_1_home = device_1.get_home_view()
device_1_home.add_contact(sender['public_key']) device_1_home.add_contact(sender['public_key'])
device_1_home.back_button.click(times_to_click=3) device_1_home.back_button.click(times_to_click=2)
if test == 'group_chat': if test == 'group_chat':
group_chat_name = 'gtr_%s' % get_current_time() group_chat_name = 'gtr_%s' % get_current_time()
device_1_home.create_group_chat([sender['username']], group_chat_name) device_1_home.create_group_chat([sender['username']], group_chat_name)
@ -115,15 +115,16 @@ class TestMultipleDevices(MultipleDeviceTestCase):
one_to_one_chat_device_1.click() one_to_one_chat_device_1.click()
device_1_chat = device_1_home.get_chat_view() device_1_chat = device_1_home.get_chat_view()
device_2_chat = device_2_home.get_chat_view() device_2_chat = device_2_home.get_chat_view()
device_1_chat.request_command.click()
amount = device_1_chat.get_unique_amount() amount = device_1_chat.get_unique_amount()
if test == 'group_chat': if test == 'group_chat':
device_1_chat.request_command.click()
device_1_chat.first_recipient_button.click() device_1_chat.first_recipient_button.click()
device_1_chat.send_as_keyevent(amount) device_1_chat.send_as_keyevent(amount)
else: else:
device_1_chat.chat_message_input.set_value(amount)
one_to_one_chat_device_2 = device_2_chat.element_by_text_part(recipient['username'][:25], 'button') one_to_one_chat_device_2 = device_2_chat.element_by_text_part(recipient['username'][:25], 'button')
one_to_one_chat_device_2.click() one_to_one_chat_device_2.click()
device_1_chat.request_command.click()
device_1_chat.send_as_keyevent(amount)
device_1_chat.send_message_button.click() device_1_chat.send_message_button.click()
initial_balance_recipient = api_requests.get_balance(recipient['address']) initial_balance_recipient = api_requests.get_balance(recipient['address'])
if test == 'group_chat': if test == 'group_chat':

View File

@ -60,7 +60,7 @@ class TestSanity(SingleDeviceTestCase):
for user in users: for user in users:
home_view.add_contact(user['public_key']) home_view.add_contact(user['public_key'])
console_view.back_button.click(3) console_view.back_button.click(2)
home_view.create_group_chat(sorted([user['username'] for user in users])) home_view.create_group_chat(sorted([user['username'] for user in users]))
group_chat = home_view.get_chat_view() group_chat = home_view.get_chat_view()
group_chat.chat_options.click() group_chat.chat_options.click()
@ -75,7 +75,8 @@ class TestSanity(SingleDeviceTestCase):
console_view.create_user() console_view.create_user()
console_view.back_button.click() console_view.back_button.click()
home_view = console_view.get_home_view() home_view = console_view.get_home_view()
home_view.plus_button.click() start_new_chat_view = home_view.plus_button.click()
start_new_chat_view.add_new_contact.click()
contact_jarrad = home_view.element_by_text('Jarrad', 'button') contact_jarrad = home_view.element_by_text('Jarrad', 'button')
contact_jarrad.scroll_to_element() contact_jarrad.scroll_to_element()
contact_jarrad.click() contact_jarrad.click()

View File

@ -32,7 +32,7 @@ class TestTransactions(SingleDeviceTestCase):
home_view.add_contact(recipient_key) home_view.add_contact(recipient_key)
if test == 'group_chat': if test == 'group_chat':
home_view.back_button.click(times_to_click=3) home_view.back_button.click(times_to_click=2)
home_view.create_group_chat([transaction_users[recipient]['username']], home_view.create_group_chat([transaction_users[recipient]['username']],
'trg_%s' % get_current_time()) 'trg_%s' % get_current_time())
chat_view = home_view.get_chat_view() chat_view = home_view.get_chat_view()
@ -75,7 +75,10 @@ class TestTransactions(SingleDeviceTestCase):
address = transaction_users['B_USER']['address'] address = transaction_users['B_USER']['address']
initial_balance = api_requests.get_balance(address) initial_balance = api_requests.get_balance(address)
start_new_chat_view = home_view.plus_button.click() start_new_chat_view = home_view.plus_button.click()
start_new_chat_view.open_d_app_button.click()
auction_house = start_new_chat_view.auction_house_button.click() auction_house = start_new_chat_view.auction_house_button.click()
start_new_chat_view.open_button.click()
auction_house.wait_for_d_aap_to_load()
auction_house.toggle_navigation_button.click() auction_house.toggle_navigation_button.click()
auction_house.new_auction_button.click() auction_house.new_auction_button.click()
auction_house.name_to_reserve_input.click() auction_house.name_to_reserve_input.click()

View File

@ -28,7 +28,7 @@ class TestWallet(SingleDeviceTestCase):
home_view = console_view.get_home_view() home_view = console_view.get_home_view()
recipient_key = transaction_users_wallet['B_USER']['public_key'] recipient_key = transaction_users_wallet['B_USER']['public_key']
home_view.add_contact(recipient_key) home_view.add_contact(recipient_key)
home_view.back_button.click(times_to_click=3) home_view.back_button.click(times_to_click=2)
wallet_view = home_view.wallet_button.click() wallet_view = home_view.wallet_button.click()
send_transaction_view = wallet_view.request_button.click() send_transaction_view = wallet_view.request_button.click()
send_transaction_view.amount_edit_box.scroll_to_element() send_transaction_view.amount_edit_box.scroll_to_element()
@ -50,7 +50,7 @@ class TestWallet(SingleDeviceTestCase):
recipient_address = transaction_users_wallet[recipient]['address'] recipient_address = transaction_users_wallet[recipient]['address']
initial_balance_recipient = api_requests.get_balance(recipient_address) initial_balance_recipient = api_requests.get_balance(recipient_address)
home_view.add_contact(recipient_key) home_view.add_contact(recipient_key)
home_view.back_button.click(times_to_click=3) home_view.back_button.click(times_to_click=2)
wallet_view = home_view.wallet_button.click() wallet_view = home_view.wallet_button.click()
send_transaction = wallet_view.send_button.click() send_transaction = wallet_view.send_button.click()
send_transaction.amount_edit_box.click() send_transaction.amount_edit_box.click()
@ -58,10 +58,9 @@ class TestWallet(SingleDeviceTestCase):
send_transaction.send_as_keyevent(amount) send_transaction.send_as_keyevent(amount)
send_transaction.confirm() send_transaction.confirm()
send_transaction.chose_recipient_button.click() send_transaction.chose_recipient_button.click()
send_transaction.deny_button.click() send_transaction.enter_contact_code_button.click()
send_transaction.chose_from_contacts_button.click() send_transaction.enter_recipient_address_input.set_value(recipient_address)
user_contact = send_transaction.element_by_text(transaction_users_wallet[recipient]['username'], 'button') send_transaction.done_button.click()
user_contact.click()
if test == 'sign_later': if test == 'sign_later':
send_transaction.sign_later_button.click() send_transaction.sign_later_button.click()
send_transaction.yes_button.click() send_transaction.yes_button.click()

View File

@ -17,11 +17,8 @@ class BackButton(BaseButton):
def click(self, times_to_click: int = 1): def click(self, times_to_click: int = 1):
for _ in range(times_to_click): for _ in range(times_to_click):
try: self.find_element().click()
self.find_element().click() info('Tap on %s' % self.name)
info('Tap on %s' % self.name)
except (NoSuchElementException, TimeoutException):
pass
return self.navigate() return self.navigate()
@ -117,7 +114,7 @@ class DoneButton(BaseButton):
def __init__(self, driver): def __init__(self, driver):
super(DoneButton, self).__init__(driver) super(DoneButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector( self.locator = self.Locator.xpath_selector(
"//android.widget.TextView[@text='Done']") "//android.widget.TextView[@text='DONE']")
class AppsButton(BaseButton): class AppsButton(BaseButton):

View File

@ -25,7 +25,7 @@ class PublicKeyEditBox(BaseEditBox):
def __init__(self, driver): def __init__(self, driver):
super(PublicKeyEditBox, self).__init__(driver) super(PublicKeyEditBox, self).__init__(driver)
self.locator = \ self.locator = \
self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']") self.Locator.xpath_selector("//*[@text='Enter contact code']")
class ConfirmPublicKeyButton(BaseButton): class ConfirmPublicKeyButton(BaseButton):

View File

@ -9,7 +9,7 @@ class PlusButton(BaseButton):
def __init__(self, driver): def __init__(self, driver):
super(PlusButton, self).__init__(driver) super(PlusButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector( self.locator = self.Locator.xpath_selector(
"//android.widget.TextView[@text='+']") "//android.view.ViewGroup/android.widget.TextView[@text='+']")
def navigate(self): def navigate(self):
from views.start_new_chat_view import StarNewChatView from views.start_new_chat_view import StarNewChatView
@ -57,7 +57,6 @@ class HomeView(BaseView):
start_new_chat.add_new_contact.click() start_new_chat.add_new_contact.click()
start_new_chat.public_key_edit_box.send_keys(public_key) start_new_chat.public_key_edit_box.send_keys(public_key)
start_new_chat.confirm() start_new_chat.confirm()
start_new_chat.confirm_public_key_button.click()
def create_group_chat(self, user_names_to_add: list, group_chat_name: str = 'new_group_chat'): 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 = self.plus_button.click()

View File

@ -57,13 +57,19 @@ class ChooseRecipientButton(BaseButton):
def __init__(self, driver): def __init__(self, driver):
super(ChooseRecipientButton, self).__init__(driver) super(ChooseRecipientButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Choose recipient...']") self.locator = self.Locator.xpath_selector("//*[@text='Specify recipient...']")
class ChooseFromContactsButton(BaseButton): class EnterContactCodeButton(BaseButton):
def __init__(self, driver): def __init__(self, driver):
super(ChooseFromContactsButton, self).__init__(driver) super(EnterContactCodeButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Choose From Contacts']") self.locator = self.Locator.xpath_selector("//*[@text='Enter contact code']")
class EnterRecipientAddressInput(BaseEditBox):
def __init__(self, driver):
super(EnterRecipientAddressInput, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Enter recipient address']")
class SendTransactionView(BaseView): class SendTransactionView(BaseView):
@ -71,7 +77,8 @@ class SendTransactionView(BaseView):
super(SendTransactionView, self).__init__(driver) super(SendTransactionView, self).__init__(driver)
self.chose_recipient_button = ChooseRecipientButton(self.driver) self.chose_recipient_button = ChooseRecipientButton(self.driver)
self.chose_from_contacts_button = ChooseFromContactsButton(self.driver) self.enter_contact_code_button = EnterContactCodeButton(self.driver)
self.enter_recipient_address_input = EnterRecipientAddressInput(self.driver)
self.first_recipient_button = FirstRecipient(self.driver) self.first_recipient_button = FirstRecipient(self.driver)
self.amount_edit_box = AmountEditBox(self.driver) self.amount_edit_box = AmountEditBox(self.driver)
@ -86,6 +93,7 @@ class SendTransactionView(BaseView):
for _ in range(4): for _ in range(4):
try: try:
self.sign_transaction_button.click() self.sign_transaction_button.click()
self.password_input.wait_for_element(5) self.enter_password_input.wait_for_element(5)
return
except (NoSuchElementException, TimeoutException): except (NoSuchElementException, TimeoutException):
pass pass

View File

@ -6,7 +6,7 @@ class AddNewContactButton(BaseButton):
def __init__(self, driver): def __init__(self, driver):
super(AddNewContactButton, self).__init__(driver) super(AddNewContactButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector( self.locator = self.Locator.xpath_selector(
"//android.widget.TextView[@text='Add new contact']") "//android.widget.TextView[@text='Start new chat']")
class NewGroupChatButton(BaseButton): class NewGroupChatButton(BaseButton):
@ -14,7 +14,7 @@ class NewGroupChatButton(BaseButton):
def __init__(self, driver): def __init__(self, driver):
super(NewGroupChatButton, self).__init__(driver) super(NewGroupChatButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector( self.locator = self.Locator.xpath_selector(
"//android.widget.TextView[@text='New group chat']") "//android.widget.TextView[@text='Start group chat']")
class NameEditBox(BaseEditBox): class NameEditBox(BaseEditBox):
@ -24,6 +24,20 @@ class NameEditBox(BaseEditBox):
self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']") self.Locator.xpath_selector("//android.widget.EditText[@NAF='true']")
class OpenDAapButton(BaseButton):
def __init__(self, driver):
super(OpenDAapButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
"//android.widget.TextView[@text='Open ÐApp']")
class OpenButton(BaseButton):
def __init__(self, driver):
super(OpenButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
"//android.widget.TextView[@text='Open']")
class StarNewChatView(ContactsView): class StarNewChatView(ContactsView):
def __init__(self, driver): def __init__(self, driver):
super(StarNewChatView, self).__init__(driver) super(StarNewChatView, self).__init__(driver)
@ -31,4 +45,7 @@ class StarNewChatView(ContactsView):
self.add_new_contact = AddNewContactButton(self.driver) self.add_new_contact = AddNewContactButton(self.driver)
self.new_group_chat_button = NewGroupChatButton(self.driver) self.new_group_chat_button = NewGroupChatButton(self.driver)
self.open_d_app_button = OpenDAapButton(self.driver)
self.open_button = OpenButton(self.driver)
self.name_edit_box = NameEditBox(self.driver) self.name_edit_box = NameEditBox(self.driver)

View File

@ -34,7 +34,6 @@ class AuctionHouseWebView(BaseWebView):
def __init__(self, driver): def __init__(self, driver):
super(AuctionHouseWebView, self).__init__(driver) super(AuctionHouseWebView, self).__init__(driver)
self.driver = driver self.driver = driver
self.wait_for_page_loaded()
self.toggle_navigation_button = ToggleNavigationButton(self.driver) self.toggle_navigation_button = ToggleNavigationButton(self.driver)
self.new_auction_button = ToggleNavigationButton.NewAuctionButton(self.driver) self.new_auction_button = ToggleNavigationButton.NewAuctionButton(self.driver)

View File

@ -1,4 +1,5 @@
from views.base_view import * from views.base_view import *
import pytest
class ProgressBarIcon(BaseElement): class ProgressBarIcon(BaseElement):
@ -16,7 +17,7 @@ class BaseWebView(BaseView):
self.progress_bar_icon = ProgressBarIcon(self.driver) self.progress_bar_icon = ProgressBarIcon(self.driver)
def wait_for_page_loaded(self, wait_time=20): def wait_for_d_aap_to_load(self, wait_time=35):
counter = 0 counter = 0
while self.progress_bar_icon.is_element_present(5): while self.progress_bar_icon.is_element_present(5):
time.sleep(1) time.sleep(1)