<commit_before>import pytest

from tests import marks, unique_password, common_password
from tests.base_test_case import SingleDeviceTestCase
from tests.users import transaction_senders, transaction_recipients, basic_user
from views.send_transaction_view import SendTransactionView
from views.sign_in_view import SignInView
from decimal import Decimal


class TestTransactionDApp(SingleDeviceTestCase):

    @marks.testrail_id(5309)
    @marks.critical
    def test_send_transaction_from_daap(self):
        sender = transaction_senders['K']
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.recover_access(sender['passphrase'])
        address = sender['address']
        initial_balance = self.network_api.get_balance(address)
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.assets_button.click()
        send_transaction_view = status_test_dapp.request_stt_button.click()
        send_transaction_view.sign_transaction()
        self.network_api.verify_balance_is_updated(initial_balance, address)

    @marks.testrail_id(5342)
    @marks.critical
    def test_sign_message_from_daap(self):
        password = '<PASSWORD>'
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.create_user(password=password)
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.transactions_button.click()
        send_transaction_view = status_test_dapp.sign_message_button.click()
        send_transaction_view.find_full_text('Test message')
        send_transaction_view.enter_password_input.send_keys(password)
        send_transaction_view.sign_button.click()

    @marks.testrail_id(5333)
    @marks.critical
    def test_deploy_contract_from_daap(self):
        sender = transaction_senders['L']
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.recover_access(sender['passphrase'])
        wallet_view = home_view.wallet_button.click()
        wallet_view.set_up_wallet()
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.transactions_button.click()
        send_transaction_view = status_test_dapp.deploy_contract_button.click()
        send_transaction_view.sign_transaction()
        for text in 'Contract deployed at: ', 'Call contract get function', \
                    'Call contract set function', 'Call function 2 times in a row':
            if not status_test_dapp.element_by_text(text).is_element_displayed(120):
                pytest.fail('Contract was not created')

    @marks.testrail_id(5784)
    @marks.critical
    def test_sign_typed_message(self):
        sender = transaction_senders['W']
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.recover_access(sender['passphrase'])
        wallet_view = home_view.wallet_button.click()
        wallet_view.set_up_wallet()
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.transactions_button.click()
        send_transaction_view = status_test_dapp.sign_typed_message_button.click()
        send_transaction_view.enter_password_input.send_keys(common_password)
        send_transaction_view.sign_button.click()
        status_test_dapp.find_text_part('0xde3048417e5881acc9ca8466ab0b3e2f9f965a70acabbda2d140e95a28b13d2d'
                                        '2d38eba6c0a5bfdc50e5d59e0ed3226c749732fd4a9374b57f34121eaff2a5081c')

    @marks.testrail_id(5743)
    @marks.high
    def test_send_two_transactions_in_batch_in_dapp(self):
        sender = transaction_senders['W']
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.recover_access(sender['passphrase'])
        wallet_view = home_view.wallet_button.click()
        wallet_view.set_up_wallet()
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.transactions_button.click()
        send_transaction_view = status_test_dapp.send_two_tx_in_batch_button.click()
        send_transaction_view.sign_transaction()

        # Check that second 'Send transaction' screen appears
        if not send_transaction_view.element_by_text('Sign transaction').is_element_displayed(10):
            pytest.fail('Second send transaction screen did not appear!')

        send_transaction_view.sign_transaction()

    @marks.testrail_id(5744)
    @marks.critical
    def test_send_two_transactions_one_after_another_in_dapp(self):
        sender = transaction_senders['Z']
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.recover_access(sender['passphrase'])
        wallet_view = home_view.wallet_button.click()
        wallet_view.set_up_wallet()
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.transactions_button.click()
        send_transaction_view = status_test_dapp.send_two_tx_one_by_one_button.click()
        send_transaction_view.sign_transaction()

        # Check that second 'Send transaction' screen appears
        if not send_transaction_view.element_by_text('Sign transaction').is_element_displayed(20):
            pytest.fail('Second send transaction screen did not appear!')

        send_transaction_view.sign_transaction()

    @marks.logcat
    @marks.testrail_id(5418)
    @marks.critical
    def test_logcat_send_transaction_from_daap(self):<commit_msg>More e2e fixes<commit_after>import pytest

from tests import marks, unique_password, common_password
from tests.base_test_case import SingleDeviceTestCase
from tests.users import transaction_senders, transaction_recipients, basic_user
from views.send_transaction_view import SendTransactionView
from views.sign_in_view import SignInView
from decimal import Decimal


class TestTransactionDApp(SingleDeviceTestCase):

    @marks.testrail_id(5309)
    @marks.critical
    def test_send_transaction_from_daap(self):
        sender = transaction_senders['K']
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.recover_access(sender['passphrase'])
        address = sender['address']
        initial_balance = self.network_api.get_balance(address)
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.assets_button.click()
        send_transaction_view = status_test_dapp.request_stt_button.click()
        send_transaction_view.sign_transaction()
        self.network_api.verify_balance_is_updated(initial_balance, address)

    @marks.testrail_id(5342)
    @marks.critical
    def test_sign_message_from_daap(self):
        password = '<PASSWORD>'
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.create_user(password=password)
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.transactions_button.click()
        send_transaction_view = status_test_dapp.sign_message_button.click()
        send_transaction_view.find_full_text('Test message')
        send_transaction_view.enter_password_input.send_keys(password)
        send_transaction_view.sign_button.click()

    @marks.testrail_id(5333)
    @marks.critical
    def test_deploy_contract_from_daap(self):
        sender = transaction_senders['L']
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.recover_access(sender['passphrase'])
        wallet_view = home_view.wallet_button.click()
        wallet_view.set_up_wallet()
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.transactions_button.click()
        send_transaction_view = status_test_dapp.deploy_contract_button.click()
        send_transaction_view.sign_transaction()
        for text in 'Contract deployed at: ', 'Call contract get function', \
                    'Call contract set function', 'Call function 2 times in a row':
            if not status_test_dapp.element_by_text(text).is_element_displayed(120):
                pytest.fail('Contract was not created')

    @marks.testrail_id(5784)
    @marks.critical
    def test_sign_typed_message(self):
        sender = transaction_senders['W']
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.recover_access(sender['passphrase'])
        wallet_view = home_view.wallet_button.click()
        wallet_view.set_up_wallet()
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.transactions_button.click()
        send_transaction_view = status_test_dapp.sign_typed_message_button.click()
        send_transaction_view.enter_password_input.send_keys(common_password)
        send_transaction_view.sign_button.click()
        status_test_dapp.find_text_part('0xde3048417e5881acc9ca8466ab0b3e2f9f965a70acabbda2d140e95a28b13d2d'
                                        '2d38eba6c0a5bfdc50e5d59e0ed3226c749732fd4a9374b57f34121eaff2a5081c')

    @marks.testrail_id(5743)
    @marks.high
    def test_send_two_transactions_in_batch_in_dapp(self):
        sender = transaction_senders['W']
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.recover_access(sender['passphrase'])
        wallet_view = home_view.wallet_button.click()
        wallet_view.set_up_wallet()
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.transactions_button.click()
        send_transaction_view = status_test_dapp.send_two_tx_in_batch_button.click()
        send_transaction_view.sign_transaction()

        # Check that second 'Send transaction' screen appears
        if not send_transaction_view.element_by_text('Sign with password').is_element_displayed(10):
            pytest.fail('Second send transaction screen did not appear!')

        send_transaction_view.sign_transaction()

    @marks.testrail_id(5744)
    @marks.critical
    def test_send_two_transactions_one_after_another_in_dapp(self):
        sender = transaction_senders['Z']
        sign_in_view = SignInView(self.driver)
        home_view = sign_in_view.recover_access(sender['passphrase'])
        wallet_view = home_view.wallet_button.click()
        wallet_view.set_up_wallet()
        status_test_dapp = home_view.open_status_test_dapp()
        status_test_dapp.wait_for_d_aap_to_load()
        status_test_dapp.transactions_button.click()
        send_transaction_view = status_test_dapp.send_two_tx_one_by_one_button.click()
        send_transaction_view.sign_transaction()

        # Check that second 'Send transaction' screen appears
        if not send_transaction_view.element_by_text('Sign with password').is_element_displayed(20):
            pytest.fail('Second send transaction screen did not appear!')

        send_transaction_view.sign_transaction()

    @marks.logcat
    @marks.testrail_id(5418)
    @marks.critical
    def test_logcat_send_transaction_from_daap(self):
{'fraction_non_alphanumeric': 0.07556142668428005, 'fraction_numerical': 0.019815059445178335, 'mean_word_length': 3.9224100563502384, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3955887', 'n_tokens_mistral': 3738, 'n_tokens_neox': 3612, 'n_words': 461}