tests: send random NFT

This commit is contained in:
Anastasiya Semenkevich 2024-09-12 17:28:43 +03:00 committed by Anastasiya
parent 7a6144f11a
commit 6f80461371
7 changed files with 96 additions and 27 deletions

View File

@ -66,7 +66,8 @@ class SendPopup(BasePopup):
QObject(item).click()
break
try:
return self._ens_address_text_edit.wait_until_appears(timeout_msec=configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
return self._ens_address_text_edit.wait_until_appears(
timeout_msec=configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
except AssertionError as err:
if attempts:
self._select_asset_or_collectible(attempts - 1)
@ -91,12 +92,16 @@ class SendPopup(BasePopup):
@allure.step('Send {2} {3} to {1}')
def send(self, address: str, amount: int, asset: str):
token_selector = self.open_token_selector()
if asset:
token_selector.select_asset_from_list(asset_name=asset)
assert driver.waitFor(lambda: self._amount_to_send_text_edit.is_visible, timeout_msec=6000), \
f"Asset selector popup was either not closed or send modal is not visible"
self._amount_to_send_text_edit.text = str(amount)
self._ens_address_text_edit.wait_until_appears(timeout_msec=configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
self._ens_address_text_edit.type_text(address)
else:
search_view = token_selector.open_collectibles_search_view()
search_view.select_random_collectible()
self._ens_address_text_edit.wait_until_appears(timeout_msec=configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
self._ens_address_text_edit.type_text(address)
assert driver.waitFor(lambda: self._send_button.is_visible, timeout_msec=8000)
self._send_button.click()

View File

@ -1,5 +1,12 @@
import random
import time
import configs
import driver
from gui.components.base_popup import BasePopup
from gui.components.wallet.send_popup import *
from gui.elements.button import Button
from gui.elements.object import QObject
from gui.elements.text_edit import TextEdit
from gui.objects_map import names
@ -24,3 +31,51 @@ class TokenSelectorPopup(BasePopup):
QObject(item).click()
break
return self
def open_collectibles_search_view(self):
self.collectibles_tab.click()
return SearchableCollectiblesPanelView().wait_until_appears()
class SearchableCollectiblesPanelView(TokenSelectorPopup):
def __init__(self):
super(SearchableCollectiblesPanelView, self).__init__()
self.searchableCollectiblesPanel = QObject(names.searchableCollectiblesPanel)
self.search_bar = QObject(names.tokenSelectorSearchBar)
self.collectibles_list_view = QObject(names.collectiblesListView)
self.collectibles_inner_list_view = QObject(names.collectiblesInnerListView)
self.collectiblesListViewInnerItem = QObject(names.collectiblesListViewInnerItem)
self.collectible_list_item = QObject(names.tokenSelectorCollectibleDelegate_template)
self.back_button = Button(names.tokenSelectorBackButton)
self.search_bar_edit = TextEdit(names.tokenSelectorSearchBarTextEdit)
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
self.search_bar.wait_until_appears(timeout_msec)
return self
def get_list(self, list_view, list_item):
assert driver.waitForObject(list_view.real_name,
60000).count > 0, f'ListView of nested collectibles is empty'
return driver.findAllObjects(list_item.real_name)
def select_random_collectible(self):
collectibles = self.get_list(self.collectibles_list_view, self.collectible_list_item)
collectibles_names = [str(getattr(collectible, 'name', '')) for collectible in collectibles]
random_name = random.choice(collectibles_names).removeprefix('Owner-')
time.sleep(3)
self.search_bar_edit.set_text_property(random_name)
time.sleep(3)
search_results = self.get_list(self.collectibles_list_view, self.collectible_list_item)
for index, item in enumerate(search_results):
if str(getattr(item, 'name', '')).removeprefix('Owner-') == random_name:
QObject(search_results[index]).click()
if self.back_button.is_visible:
inner_collectibles = self.get_list(self.collectibles_inner_list_view, self.collectible_list_item)
item_to_select = random.choice(inner_collectibles)
QObject(item_to_select).click()
break
break
return self

View File

@ -23,6 +23,12 @@ class QObject:
def object(self):
return driver.waitForObject(self.real_name, configs.timeouts.UI_LOAD_TIMEOUT_MSEC)
def set_text_property(self, text):
self.object.forceActiveFocus()
self.object.clear()
self.object.text = text
assert self.object.text == text, 'Text was not set'
@property
@allure.step('Get object exists {0}')
def exists(self) -> bool:

View File

@ -9,6 +9,8 @@ from .object import QObject
LOG = logging.getLogger(__name__)
# TODO: fix scroll https://github.com/status-im/status-desktop/issues/16325
class Scroll(QObject):
@allure.step('Scroll vertical down to object {1}')

View File

@ -552,6 +552,17 @@ tokensTabBar_StatusTabBar = {"container": statusDesktop_mainWindow_overlay, "obj
tokenSelectorPanel_AssetsTab = {"container": tokensTabBar_StatusTabBar, "objectName": "assetsTab", "type": "StatusTabButton", "visible": True}
tokenSelectorPanel_CollectiblesTab = {"container": tokensTabBar_StatusTabBar, "objectName": "collectiblesTab", "type": "StatusTabButton", "visible": True}
tokenSelectorAssetDelegate_template = {"container": statusDesktop_mainWindow_overlay, "objectName": RegularExpression("tokenSelectorAssetDelegate*"), "type": "TokenSelectorAssetDelegate", "visible": True}
searchableCollectiblesPanel = {"container": statusDesktop_mainWindow_overlay, "id": "searchableCollectiblesPanel", "type": "SearchableCollectiblesPanel", "unnamed": 1, "visible": True}
collectiblesListView = {"container": statusDesktop_mainWindow_overlay, "type": "StatusListView", "id": "collectiblesListView", "visible": True}
collectiblesInnerListView = {"container": statusDesktop_mainWindow_overlay, "type": "StatusListView", "unnamed": 1, "visible": True}
collectiblesListViewInnerItem = {"container": collectiblesListView, "type": "Item", "unnamed": 1, "visible": True}
tokenSelectorCollectibleDelegate_template = {"container": statusDesktop_mainWindow_overlay, "objectName": RegularExpression("tokenSelectorCollectibleDelegate_*"), "type": "TokenSelectorCollectibleDelegate", "visible": True}
tokenSelectorBackButton = {"container": statusDesktop_mainWindow_overlay, "id": "backButton", "type": "StatusIconTextButton", "unnamed": 1, "visible": True}
tokenSelectorSearchBar = {"container": statusDesktop_mainWindow_overlay, "objectName": "collectiblesSearchBox", "type": "TokenSearchBox", "visible": True}
# tokenSelectorSearchBarBaseInput = {"container": tokenSelectorSearchBar, "objectName": "statusBaseInput", "occurrence": 2, "type": "StatusBaseInput", "visible": True}
tokenSelectorSearchBarTextEdit = {"container": tokenSelectorSearchBar, "id": "edit", "type": "TextEdit", "unnamed": 1, "visible": True}
# Verify identity popup
profileSendContactRequestModal_sayWhoYouAreInput_TextEdit = {"container": statusDesktop_mainWindow_overlay, "objectName": "ProfileSendContactRequestModal_sayWhoYouAreInput", "type": "TextEdit", "visible": True}

View File

@ -16,11 +16,11 @@ from helpers.WalletHelper import authenticate_with_password, open_send_modal_for
'Send: can send 0 ETH to address pasted into receiver field with Simple flow')
@pytest.mark.case(704527)
@pytest.mark.transaction
@pytest.mark.parametrize('receiver_account_address, amount, asset', [
pytest.param(WalletAddress.RECEIVER_ADDRESS.value, 0, 'ETH')
@pytest.mark.parametrize('receiver_account_address, amount, asset, collectible', [
pytest.param(WalletAddress.RECEIVER_ADDRESS.value, 0, 'ETH', '')
])
@pytest.mark.timeout(timeout=120)
def test_wallet_send_0_eth(main_window, user_account, receiver_account_address, amount, asset):
def test_wallet_send_0_eth(main_window, user_account, receiver_account_address, amount, asset, collectible):
user_account = ReturningUser(
seed_phrase=WALLET_SEED,
status_address='0x44ddd47a0c7681a5b0fa080a56cbb7701db4bb43')

View File

@ -1,7 +1,5 @@
import allure
import pytest
import configs
import driver
from configs import WALLET_SEED
from constants import ReturningUser
@ -16,13 +14,11 @@ from helpers.WalletHelper import authenticate_with_password, open_send_modal_for
'Send: can send ERC 721 token (collectible) to address pasted into receiver field with Simple flow')
@pytest.mark.case(704602)
@pytest.mark.transaction
@pytest.mark.parametrize('tab, receiver_account_address, amount, collectible', [
pytest.param('Collectibles', '0x44ddd47a0c7681a5b0fa080a56cbb7701db4bb43', 1, 'Panda')
@pytest.mark.parametrize('receiver_account_address, amount, asset', [
pytest.param('0x44ddd47a0c7681a5b0fa080a56cbb7701db4bb43', 1, '')
])
@pytest.mark.timeout(timeout=120)
@pytest.mark.skip(reason="https://github.com/status-im/status-desktop/issues/14862")
@pytest.mark.skip(reason="https://github.com/status-im/status-desktop/issues/14509")
def test_wallet_send_nft(main_window, user_account, tab, receiver_account_address, amount, collectible):
def test_wallet_send_nft(main_window, user_account, receiver_account_address, amount, asset):
user_account = ReturningUser(
seed_phrase=WALLET_SEED,
status_address='0x44ddd47a0c7681a5b0fa080a56cbb7701db4bb43')
@ -30,16 +26,10 @@ def test_wallet_send_nft(main_window, user_account, tab, receiver_account_addres
keys_screen = open_generate_new_keys_view()
profile_view = open_import_seed_view_and_do_import(keys_screen, user_account.seed_phrase, user_account)
finalize_onboarding_and_login(profile_view, user_account)
enable_testnet_mode(main_window)
send_popup = open_send_modal_for_account(
main_window, account_name=WalletNetworkSettings.STATUS_ACCOUNT_DEFAULT_NAME)
send_popup.send(receiver_account_address, amount, collectible, tab)
assert driver.waitFor(lambda: send_popup._mainnet_network.is_visible, configs.timeouts.UI_LOAD_TIMEOUT_SEC)
send_popup.send(receiver_account_address, amount, asset)
authenticate_with_password(user_account)
assert WalletTransactions.TRANSACTION_PENDING_TOAST_MESSAGE.value in ' '.join(
main_window.wait_for_notification())