2021-07-23 11:48:14 +00:00
|
|
|
from tests import marks, test_dapp_name, test_dapp_url
|
2018-07-26 18:58:05 +00:00
|
|
|
from tests.base_test_case import SingleDeviceTestCase
|
2018-09-17 08:50:01 +00:00
|
|
|
from tests.users import basic_user
|
2018-07-26 18:58:05 +00:00
|
|
|
from views.sign_in_view import SignInView
|
|
|
|
|
|
|
|
|
|
|
|
class TestDApps(SingleDeviceTestCase):
|
|
|
|
|
2021-02-05 11:29:35 +00:00
|
|
|
@marks.testrail_id(6635)
|
|
|
|
@marks.medium
|
|
|
|
def test_webview_camera_permission(self):
|
|
|
|
web_view_camera_url = 'https://simpledapp.status.im/webviewtest/webviewcamera.html'
|
|
|
|
home = SignInView(self.driver).create_user()
|
|
|
|
self.driver.set_clipboard_text(web_view_camera_url)
|
|
|
|
dapp = home.dapp_tab_button.click()
|
|
|
|
dapp.enter_url_editbox.click()
|
|
|
|
dapp.paste_text()
|
|
|
|
dapp.confirm()
|
|
|
|
|
|
|
|
from views.web_views.base_web_view import BaseWebView
|
|
|
|
camera_dapp = BaseWebView(self.driver)
|
|
|
|
camera_dapp.just_fyi("Check camera request blocked (because it's not enabled in app yet)")
|
|
|
|
camera_request_blocked = home.get_translation_by_key("page-camera-request-blocked")
|
|
|
|
if not dapp.element_by_text_part(camera_request_blocked).is_element_displayed():
|
|
|
|
self.driver.fail("There is no pop-up notifying that camera access need to be granted in app")
|
|
|
|
camera_dapp.swipe_down()
|
|
|
|
if not camera_dapp.camera_image_in_dapp.is_element_image_similar_to_template('blank_camera_image.png'):
|
|
|
|
self.driver.fail("Even camera permissions not allowed - acccess to camera granted")
|
|
|
|
|
|
|
|
profile = home.profile_button.click()
|
|
|
|
profile.privacy_and_security_button.click()
|
|
|
|
|
|
|
|
camera_dapp.just_fyi("Enable camera requests in Dapps")
|
2021-09-15 15:21:05 +00:00
|
|
|
profile.element_by_translation_id("webview-camera-permission-requests").scroll_and_click()
|
2021-02-05 11:29:35 +00:00
|
|
|
home.dapp_tab_button.click(desired_element_text='webview')
|
|
|
|
|
|
|
|
camera_dapp.just_fyi("Check DApp asks now to allow camera aceess but Deny in DApp")
|
|
|
|
camera_dapp.browser_refresh_page_button.click()
|
|
|
|
camera_dapp.deny_button.click()
|
|
|
|
if not camera_dapp.camera_image_in_dapp.is_element_image_similar_to_template('blank_camera_image.png'):
|
|
|
|
self.driver.fail("Even camera access Denied to Dapp, - acccess to camera granted")
|
|
|
|
|
|
|
|
camera_dapp.just_fyi("Check DApp asks now to allow camera aceess and Allow access to DApp")
|
|
|
|
camera_dapp.browser_refresh_page_button.click()
|
|
|
|
camera_dapp.allow_button.click()
|
|
|
|
if camera_dapp.camera_image_in_dapp.is_element_image_similar_to_template('blank_camera_image.png'):
|
|
|
|
self.driver.fail("Even camera access Accepted to Dapp, - camera view is not shown")
|
|
|
|
|
|
|
|
camera_dapp.just_fyi("Relogin and check camera access still needs to be allowed")
|
|
|
|
home.profile_button.click()
|
|
|
|
profile.relogin()
|
|
|
|
home.dapp_tab_button.click()
|
|
|
|
camera_dapp.open_tabs_button.click()
|
|
|
|
dapp.element_by_text_part("https").click()
|
|
|
|
if not camera_dapp.allow_button.is_element_displayed():
|
|
|
|
self.driver.fail("No request to camera access after relogin")
|
|
|
|
|
2020-09-02 15:57:19 +00:00
|
|
|
@marks.testrail_id(6323)
|
|
|
|
@marks.medium
|
2020-11-23 12:07:24 +00:00
|
|
|
@marks.flaky
|
2020-09-02 15:57:19 +00:00
|
|
|
def test_resolve_ipns_name(self):
|
|
|
|
user = basic_user
|
|
|
|
ipns_url = 'uniswap.eth'
|
2021-09-15 15:21:05 +00:00
|
|
|
home = SignInView(self.driver).recover_access(passphrase=user['passphrase'])
|
|
|
|
profile = home.profile_button.click()
|
|
|
|
profile.switch_network()
|
2020-09-02 15:57:19 +00:00
|
|
|
self.driver.set_clipboard_text(ipns_url)
|
2021-09-15 15:21:05 +00:00
|
|
|
dapp = home.dapp_tab_button.click()
|
|
|
|
dapp.enter_url_editbox.click()
|
|
|
|
dapp.paste_text()
|
|
|
|
dapp.confirm()
|
|
|
|
if not dapp.allow_button.is_element_displayed(30):
|
2020-09-02 15:57:19 +00:00
|
|
|
self.driver.fail('No permission is asked for dapp, so IPNS name is not resolved')
|
|
|
|
|
2019-10-18 13:23:36 +00:00
|
|
|
@marks.testrail_id(6232)
|
|
|
|
@marks.medium
|
|
|
|
def test_switching_accounts_in_dapp(self):
|
2021-09-15 15:21:05 +00:00
|
|
|
home = SignInView(self.driver).create_user()
|
|
|
|
wallet = home.wallet_button.click()
|
2019-10-18 13:23:36 +00:00
|
|
|
|
2021-09-15 15:21:05 +00:00
|
|
|
wallet.just_fyi('create new account in multiaccount')
|
|
|
|
status_account = home.status_account_name
|
2020-01-16 15:47:04 +00:00
|
|
|
account_name = 'Subaccount'
|
2021-09-15 15:21:05 +00:00
|
|
|
wallet.add_account(account_name)
|
|
|
|
address = wallet.get_wallet_address(account_name)
|
2019-10-18 13:23:36 +00:00
|
|
|
|
2021-09-15 15:21:05 +00:00
|
|
|
home.just_fyi('can see two accounts in DApps')
|
|
|
|
dapp = home.dapp_tab_button.click()
|
|
|
|
dapp.select_account_button.click()
|
2019-10-18 13:23:36 +00:00
|
|
|
for text in 'Select the account', status_account, account_name:
|
2021-09-15 15:21:05 +00:00
|
|
|
if not dapp.element_by_text_part(text).is_element_displayed():
|
2019-10-18 13:23:36 +00:00
|
|
|
self.driver.fail("No expected element %s is shown in menu" % text)
|
|
|
|
|
2021-09-15 15:21:05 +00:00
|
|
|
home.just_fyi('add permission to Status account')
|
|
|
|
dapp.enter_url_editbox.click()
|
|
|
|
status_test_dapp = home.open_status_test_dapp()
|
|
|
|
|
|
|
|
home.just_fyi('check that permissions from previous account was removed once you choose another')
|
|
|
|
dapp.select_account_button.click()
|
|
|
|
dapp.select_account_by_name(account_name).wait_for_element(30)
|
|
|
|
dapp.select_account_by_name(account_name).click()
|
|
|
|
profile = dapp.profile_button.click()
|
|
|
|
profile.privacy_and_security_button.click()
|
|
|
|
profile.dapp_permissions_button.click()
|
|
|
|
if profile.element_by_text(test_dapp_name).is_element_displayed():
|
2019-10-18 13:23:36 +00:00
|
|
|
self.errors.append("Permissions for %s are not removed" % test_dapp_name)
|
|
|
|
|
2021-09-15 15:21:05 +00:00
|
|
|
home.just_fyi('check that can change account')
|
|
|
|
profile.dapp_tab_button.click()
|
|
|
|
if profile.element_by_text("Can't find web3 library").is_element_displayed():
|
|
|
|
status_test_dapp.browser_refresh_page_button.wait_and_click()
|
2020-12-14 17:39:29 +00:00
|
|
|
if not status_test_dapp.element_by_text_part(account_name).is_element_displayed():
|
2019-10-18 13:23:36 +00:00
|
|
|
self.errors.append("No expected account %s is shown in authorize web3 popup for wallet" % account_name)
|
2020-12-14 17:39:29 +00:00
|
|
|
status_test_dapp.allow_button.click()
|
2021-09-15 15:21:05 +00:00
|
|
|
dapp.profile_button.click(desired_element_text='DApp permissions')
|
|
|
|
profile.element_by_text(test_dapp_name).click()
|
2019-10-18 13:23:36 +00:00
|
|
|
for text in 'Chat key', account_name:
|
2021-09-15 15:21:05 +00:00
|
|
|
if not dapp.element_by_text_part(text).is_element_displayed():
|
2019-10-18 13:23:36 +00:00
|
|
|
self.errors.append("Access is not granted to %s" % text)
|
|
|
|
|
2021-09-15 15:21:05 +00:00
|
|
|
home.just_fyi('check correct account is shown for transaction if sending from DApp')
|
|
|
|
profile.dapp_tab_button.click(desired_element_text='Accounts')
|
2019-10-18 13:23:36 +00:00
|
|
|
status_test_dapp.assets_button.click()
|
2021-09-15 15:21:05 +00:00
|
|
|
send_transaction = status_test_dapp.request_stt_button.click()
|
|
|
|
send_transaction.ok_got_it_button.wait_and_click()
|
|
|
|
address = send_transaction.get_formatted_recipient_address(address)
|
|
|
|
if not send_transaction.element_by_text(address).is_element_displayed():
|
2019-10-18 13:23:36 +00:00
|
|
|
self.errors.append("Wallet address %s in not shown in 'From' on Send Transaction screen" % address)
|
|
|
|
|
2021-09-15 15:21:05 +00:00
|
|
|
home.just_fyi('Relogin and check multiaccount loads fine')
|
|
|
|
send_transaction.cancel_button.click()
|
|
|
|
home.profile_button.click()
|
|
|
|
home.relogin()
|
|
|
|
home.wallet_button.click()
|
|
|
|
if not wallet.element_by_text(account_name).is_element_displayed():
|
2020-01-16 15:47:04 +00:00
|
|
|
self.errors.append("Subaccount is gone after relogin in Wallet!")
|
2021-09-15 15:21:05 +00:00
|
|
|
home.profile_button.click()
|
|
|
|
profile.privacy_and_security_button.click()
|
|
|
|
profile.dapp_permissions_button.click()
|
|
|
|
profile.element_by_text(test_dapp_name).click()
|
|
|
|
if not profile.element_by_text(account_name).is_element_displayed():
|
2020-01-16 15:47:04 +00:00
|
|
|
self.errors.append("Subaccount is not selected after relogin in Dapps!")
|
2019-10-29 08:25:57 +00:00
|
|
|
self.errors.verify_no_errors()
|
2019-10-18 13:23:36 +00:00
|
|
|
|