e2e: update for wallet tests
This commit is contained in:
parent
6a3794f380
commit
88b97d1151
|
@ -46,9 +46,10 @@
|
|||
[rn/view
|
||||
{:style style/transaction-header-container}
|
||||
[text/text
|
||||
{:weight :semi-bold
|
||||
:size :paragraph-1
|
||||
:style (style/transaction-header theme)}
|
||||
{:weight :semi-bold
|
||||
:size :paragraph-1
|
||||
:style (style/transaction-header theme)
|
||||
:accessibility-label :transaction-header}
|
||||
(transaction transaction-translation)]
|
||||
(when (> counter 1)
|
||||
[rn/view (style/transaction-counter-container theme blur?)
|
||||
|
@ -59,9 +60,10 @@
|
|||
(i18n/label :t/x-counter {:counter counter})]])
|
||||
[rn/view {:style style/timestamp-container}
|
||||
[text/text
|
||||
{:weight :regular
|
||||
:size :label
|
||||
:style (style/timestamp theme blur?)}
|
||||
{:weight :regular
|
||||
:size :label
|
||||
:style (style/timestamp theme blur?)
|
||||
:accessibility-label :transaction-timestamp}
|
||||
timestamp]]])
|
||||
|
||||
(defn transaction-icon-view
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import datetime
|
||||
import time
|
||||
|
||||
import pytest
|
||||
from _pytest.outcomes import Failed
|
||||
from selenium.common import TimeoutException
|
||||
from selenium.common import TimeoutException, NoSuchElementException
|
||||
|
||||
from base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
|
||||
from support.api.network_api import NetworkApi
|
||||
|
@ -32,8 +33,6 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
|
|||
self.home_1, self.home_2 = self.sign_in_1.get_home_view(), self.sign_in_2.get_home_view()
|
||||
self.wallet_1, self.wallet_2 = self.sign_in_1.get_wallet_view(), self.sign_in_2.get_wallet_view()
|
||||
|
||||
# ToDo: Add verification of Activity tabs when the feature is ready in the next 2 tests:
|
||||
|
||||
def _get_balances_before_tx(self):
|
||||
sender_balance = self.network_api.get_balance(self.sender['address'])
|
||||
receiver_balance = self.network_api.get_balance(self.receiver['address'])
|
||||
|
@ -74,8 +73,6 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
|
|||
return
|
||||
if user_name == 'receiver' and new_eth_amount >= exp_amount:
|
||||
return
|
||||
# wallet_view.chats_tab.click()
|
||||
# time.sleep(10)
|
||||
self.errors.append(
|
||||
"Eth amount in the %ss wallet is %s but should be %s" % (user_name, new_eth_amount, exp_amount))
|
||||
|
||||
|
@ -83,8 +80,8 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
|
|||
self.home_1.just_fyi("Relogin for getting an updated balance")
|
||||
self.home_2.just_fyi("Relogin for getting an updated balance")
|
||||
for _ in range(6): # just waiting 1 minute here to be sure that balances are updated
|
||||
self.wallet_1.wallet_tab.click()
|
||||
self.wallet_2.wallet_tab.click()
|
||||
self.wallet_1.wallet_tab.is_element_displayed()
|
||||
self.wallet_2.wallet_tab.is_element_displayed()
|
||||
time.sleep(10)
|
||||
self.loop.run_until_complete(
|
||||
run_in_parallel(((self.home_1.reopen_app,),
|
||||
|
@ -97,7 +94,30 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
|
|||
'user_name': self.receiver_username,
|
||||
'initial_eth_amount': eth_amount_receiver}))))
|
||||
|
||||
self.errors.verify_no_errors()
|
||||
def _check_last_transaction_in_activity(self, wallet_view, device_time, amount_to_send, sender=True):
|
||||
wallet_view.get_account_element().click()
|
||||
wallet_view.activity_tab.click()
|
||||
wallet_view.just_fyi("Checking the transaction in the activity tab")
|
||||
current_time = datetime.datetime.strptime(device_time, "%Y-%m-%dT%H:%M:%S%z")
|
||||
expected_time = "Today %s" % current_time.strftime('%-I:%M %p')
|
||||
possible_times = [expected_time,
|
||||
"Today %s" % (current_time + datetime.timedelta(minutes=1)).strftime('%-I:%M %p')]
|
||||
sender_address_short = self.sender['address'].replace(self.sender['address'][5:-3], '...').lower()
|
||||
receiver_address_short = self.receiver['address'].replace(self.receiver['address'][5:-3], '...').lower()
|
||||
activity_element = wallet_view.get_activity_element()
|
||||
try:
|
||||
if not all((activity_element.header == 'Send' if sender else 'Receive',
|
||||
activity_element.timestamp in possible_times,
|
||||
activity_element.amount == '%s ETH' % amount_to_send,
|
||||
activity_element.from_text == sender_address_short,
|
||||
activity_element.to_text == receiver_address_short)):
|
||||
self.errors.append(
|
||||
"The last transaction is not listed in activity for the %s, expected timestamp is %s" %
|
||||
('sender' if sender else 'receiver', expected_time))
|
||||
except NoSuchElementException:
|
||||
self.errors.append("Can't find the last transaction for the %s" % ('sender' if sender else 'receiver'))
|
||||
finally:
|
||||
wallet_view.close_account_button.click_until_presence_of_element(wallet_view.show_qr_code_button)
|
||||
|
||||
@marks.testrail_id(727229)
|
||||
def test_wallet_send_eth(self):
|
||||
|
@ -109,27 +129,48 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
|
|||
self.wallet_1.just_fyi("Sending funds from wallet")
|
||||
amount_to_send = 0.0001
|
||||
self.wallet_1.send_asset(address=self.receiver['address'], asset_name='Ether', amount=amount_to_send)
|
||||
self.wallet_1.close_account_button.click_until_presence_of_element(self.home_1.show_qr_code_button)
|
||||
|
||||
device_time = self.wallet_1.driver.device_time
|
||||
|
||||
self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
|
||||
eth_amount_receiver)
|
||||
|
||||
self.loop.run_until_complete(
|
||||
run_in_parallel(((self._check_last_transaction_in_activity, {'wallet_view': self.wallet_1,
|
||||
'device_time': device_time,
|
||||
'amount_to_send': amount_to_send}),
|
||||
(self._check_last_transaction_in_activity, {'wallet_view': self.wallet_2,
|
||||
'device_time': device_time,
|
||||
'amount_to_send': amount_to_send,
|
||||
'sender': False}))))
|
||||
self.errors.verify_no_errors()
|
||||
|
||||
@marks.testrail_id(727230)
|
||||
def test_wallet_send_asset_from_drawer(self):
|
||||
self.wallet_1.navigate_back_to_wallet_view()
|
||||
sender_balance, receiver_balance, eth_amount_sender, eth_amount_receiver = self._get_balances_before_tx()
|
||||
self.wallet_2.close_account_button.click()
|
||||
self.wallet_2.close_account_button.click_if_shown()
|
||||
self.wallet_2.chats_tab.click()
|
||||
|
||||
self.wallet_1.just_fyi("Sending asset from drawer")
|
||||
amount_to_send = 0.0001
|
||||
self.wallet_1.send_asset_from_drawer(address=self.receiver['address'], asset_name='Ether',
|
||||
amount=amount_to_send)
|
||||
self.wallet_1.close_account_button.click_until_presence_of_element(self.home_1.show_qr_code_button)
|
||||
device_time = self.wallet_1.driver.device_time
|
||||
|
||||
self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
|
||||
eth_amount_receiver)
|
||||
|
||||
self.loop.run_until_complete(
|
||||
run_in_parallel(((self._check_last_transaction_in_activity, {'wallet_view': self.wallet_1,
|
||||
'device_time': device_time,
|
||||
'amount_to_send': amount_to_send}),
|
||||
(self._check_last_transaction_in_activity, {'wallet_view': self.wallet_2,
|
||||
'device_time': device_time,
|
||||
'amount_to_send': amount_to_send,
|
||||
'sender': False}))))
|
||||
self.errors.verify_no_errors()
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="new_one_2")
|
||||
@marks.new_ui_critical
|
||||
|
|
|
@ -325,7 +325,8 @@ class BaseView(object):
|
|||
self.next_button = Button(self.driver, accessibility_id="next-button")
|
||||
|
||||
# share contact screen
|
||||
self.show_qr_button = Button(self.driver, accessibility_id="show-qr-button")
|
||||
self.show_qr_code_button = Button(self.driver, accessibility_id="show-qr-button")
|
||||
|
||||
self.link_to_profile_button = Button(self.driver, accessibility_id="share-qr-code-info-text")
|
||||
self.sharing_text_native = Text(self.driver, xpath="//*[@resource-id='android:id/content_preview_text']")
|
||||
|
||||
|
|
|
@ -265,7 +265,6 @@ class HomeView(BaseView):
|
|||
# Notification centre
|
||||
self.notifications_button = Button(self.driver, accessibility_id="notifications-button")
|
||||
self.notifications_unread_badge = BaseElement(self.driver, accessibility_id="activity-center-unread-count")
|
||||
self.show_qr_code_button = Button(self.driver, accessibility_id="show-qr-button")
|
||||
self.open_activity_center_button = Button(self.driver, accessibility_id="open-activity-center-button")
|
||||
self.close_activity_centre = Button(self.driver, accessibility_id="close-activity-center")
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from tests import common_password
|
||||
from views.base_element import Button, EditBox, Text
|
||||
from views.base_element import Button, EditBox, Text, BaseElement
|
||||
from views.base_view import BaseView
|
||||
from views.home_view import HomeView
|
||||
from views.sign_in_view import SignInView
|
||||
|
@ -28,12 +28,41 @@ class AssetElement(Button):
|
|||
pytest.fail("Cannot get %s amount" % self.asset_name)
|
||||
|
||||
|
||||
class ActivityElement(BaseElement):
|
||||
def __init__(self, driver, index: int):
|
||||
self.locator = "(//*[@content-desc='wallet-activity'])[%s]" % index
|
||||
super().__init__(driver=driver, xpath=self.locator)
|
||||
|
||||
@property
|
||||
def header(self):
|
||||
return Text(self.driver, prefix=self.locator, xpath="//*[@content-desc='transaction-header']").text
|
||||
|
||||
@property
|
||||
def timestamp(self):
|
||||
return Text(self.driver, prefix=self.locator, xpath="//*[@content-desc='transaction-timestamp']").text
|
||||
|
||||
@property
|
||||
def amount(self):
|
||||
return Text(self.driver, prefix=self.locator,
|
||||
xpath="//*[@content-desc='context-tag'][1]/android.widget.TextView").text
|
||||
|
||||
@property
|
||||
def from_text(self):
|
||||
return Text(self.driver, prefix=self.locator,
|
||||
xpath="//*[@content-desc='context-tag'][2]/android.widget.TextView").text
|
||||
|
||||
@property
|
||||
def to_text(self):
|
||||
return Text(self.driver, prefix=self.locator,
|
||||
xpath="//*[@content-desc='context-tag'][3]/android.widget.TextView").text
|
||||
|
||||
|
||||
class WalletView(BaseView):
|
||||
def __init__(self, driver):
|
||||
super().__init__(driver)
|
||||
# Wallet view
|
||||
self.network_drop_down = Button(self.driver, accessibility_id='network-dropdown')
|
||||
self.collectibles_tab = Button(self.driver, accessibility_id='Collectibles')
|
||||
self.collectibles_tab = Button(self.driver, accessibility_id='collectibles-tab')
|
||||
self.add_account_button = Button(self.driver, accessibility_id='add-account')
|
||||
|
||||
# Account adding
|
||||
|
@ -58,6 +87,8 @@ class WalletView(BaseView):
|
|||
self.remove_account_button = Button(self.driver, accessibility_id='remove-account')
|
||||
self.derivation_path_note_checkbox = Button(self.driver, accessibility_id='checkbox-off')
|
||||
|
||||
self.activity_tab = Button(self.driver, accessibility_id='activity-tab')
|
||||
|
||||
# Sending transaction
|
||||
self.address_text_input = EditBox(self.driver, accessibility_id='address-text-input')
|
||||
self.continue_button = Button(self.driver, accessibility_id='continue-button')
|
||||
|
@ -85,7 +116,6 @@ class WalletView(BaseView):
|
|||
def confirm_transaction(self):
|
||||
self.confirm_button.click_until_presence_of_element(self.slide_button_track)
|
||||
self.slide_and_confirm_with_password()
|
||||
self.done_button.click()
|
||||
|
||||
def set_amount(self, amount: float):
|
||||
for i in '{:f}'.format(amount).rstrip('0'):
|
||||
|
@ -94,7 +124,7 @@ class WalletView(BaseView):
|
|||
def send_asset(self, address: str, asset_name: str, amount: float):
|
||||
self.send_button.click()
|
||||
self.address_text_input.send_keys(address)
|
||||
self.continue_button.click_until_presence_of_element(self.collectibles_tab)
|
||||
self.continue_button.click()
|
||||
self.select_asset(asset_name).click()
|
||||
self.set_amount(amount)
|
||||
self.confirm_transaction()
|
||||
|
@ -104,7 +134,7 @@ class WalletView(BaseView):
|
|||
asset_element.long_press_element()
|
||||
self.send_from_drawer_button.click()
|
||||
self.address_text_input.send_keys(address)
|
||||
self.continue_button.click_until_presence_of_element(self.confirm_button)
|
||||
self.continue_button.click()
|
||||
self.set_amount(amount)
|
||||
self.confirm_transaction()
|
||||
|
||||
|
@ -130,3 +160,6 @@ class WalletView(BaseView):
|
|||
if not watch_only:
|
||||
self.derivation_path_note_checkbox.click()
|
||||
self.confirm_button.click()
|
||||
|
||||
def get_activity_element(self, index=1):
|
||||
return ActivityElement(self.driver, index=index)
|
||||
|
|
Loading…
Reference in New Issue