2017-10-13 08:41:30 +00:00
|
|
|
import pytest
|
|
|
|
import time
|
2018-01-03 09:34:40 +00:00
|
|
|
from views.console_view import ConsoleView
|
|
|
|
from tests.base_test_case import SingleDeviceTestCase
|
|
|
|
from tests import user_flow, transaction_users, api_requests, get_current_time
|
|
|
|
from selenium.common.exceptions import TimeoutException, NoSuchElementException
|
2017-10-13 08:41:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.all
|
|
|
|
class TestTransactions(SingleDeviceTestCase):
|
|
|
|
|
|
|
|
@pytest.mark.transaction
|
2018-01-03 09:34:40 +00:00
|
|
|
@pytest.mark.parametrize("test, recipient", [('group_chat', 'A_USER'),
|
|
|
|
('one_to_one_chat', 'B_USER'),
|
|
|
|
('wrong_password', 'A_USER')],
|
2017-11-15 13:44:21 +00:00
|
|
|
ids=['group_chat',
|
|
|
|
'one_to_one_chat',
|
|
|
|
'wrong_password'])
|
2018-01-03 09:34:40 +00:00
|
|
|
def test_transaction_send_command(self, test, recipient):
|
|
|
|
console_view = ConsoleView(self.driver)
|
|
|
|
user_flow.create_user(console_view)
|
|
|
|
console_view.back_button.click()
|
|
|
|
chats_view = console_view.get_chat_view()
|
2017-10-13 08:41:30 +00:00
|
|
|
recipient_address = transaction_users[recipient]['address']
|
|
|
|
recipient_key = transaction_users[recipient]['public_key']
|
2018-01-03 09:34:40 +00:00
|
|
|
transaction_amount = '0.001'
|
|
|
|
sender_address = user_flow.get_address(chats_view)
|
|
|
|
chats_view.back_button.click()
|
|
|
|
api_requests.get_donate(sender_address)
|
|
|
|
initial_balance_recipient = api_requests.get_balance(recipient_address)
|
2017-10-13 08:41:30 +00:00
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
# next 2 lines are bypassing issue #2417
|
|
|
|
wallet_view = chats_view.wallet_button.click()
|
|
|
|
wallet_view.chats_button.click()
|
2017-10-13 08:41:30 +00:00
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
user_flow.add_contact(chats_view, recipient_key)
|
2017-10-13 08:41:30 +00:00
|
|
|
if test == 'group_chat':
|
2018-01-03 09:34:40 +00:00
|
|
|
for _ in range(3):
|
|
|
|
chats_view.back_button.click()
|
|
|
|
user_flow.create_group_chat(chats_view, transaction_users[recipient]['username'],
|
|
|
|
'trg_%s' % get_current_time())
|
|
|
|
else:
|
|
|
|
chats_view.element_by_text(transaction_users[recipient]['username'], 'button').click()
|
|
|
|
chats_view.send_command.click()
|
2017-10-13 08:41:30 +00:00
|
|
|
if test == 'group_chat':
|
2018-01-03 09:34:40 +00:00
|
|
|
chats_view.first_recipient_button.click()
|
|
|
|
chats_view.send_as_keyevent(transaction_amount)
|
2017-10-13 08:41:30 +00:00
|
|
|
else:
|
2018-01-03 09:34:40 +00:00
|
|
|
chats_view.send_as_keyevent(transaction_amount)
|
|
|
|
chats_view.send_message_button.click()
|
|
|
|
send_transaction_view = chats_view.get_send_transaction_view()
|
|
|
|
send_transaction_view.sign_transaction_button.wait_for_element(5)
|
|
|
|
send_transaction_view.sign_transaction_button.click()
|
2017-10-13 08:41:30 +00:00
|
|
|
if test == 'wrong_password':
|
2018-01-03 09:34:40 +00:00
|
|
|
send_transaction_view.enter_password_input.send_keys('invalid')
|
|
|
|
send_transaction_view.sign_transaction_button.click()
|
|
|
|
send_transaction_view.find_full_text('Wrong password', 20)
|
2017-10-13 08:41:30 +00:00
|
|
|
else:
|
2018-01-03 09:34:40 +00:00
|
|
|
send_transaction_view.enter_password_input.send_keys('qwerty1234')
|
|
|
|
send_transaction_view.sign_transaction_button.click()
|
|
|
|
send_transaction_view.got_it_button.click()
|
|
|
|
send_transaction_view.find_full_text(transaction_amount)
|
2017-10-30 11:11:58 +00:00
|
|
|
try:
|
2018-01-03 09:34:40 +00:00
|
|
|
chats_view.find_full_text('Sent', 10)
|
2017-11-13 10:49:45 +00:00
|
|
|
except TimeoutException:
|
2018-01-03 09:34:40 +00:00
|
|
|
chats_view.find_full_text('Delivered', 10)
|
2017-10-13 08:41:30 +00:00
|
|
|
if test == 'group_chat':
|
2018-01-03 09:34:40 +00:00
|
|
|
chats_view.find_full_text('to ' + transaction_users[recipient]['username'], 60)
|
|
|
|
api_requests.verify_balance_is_updated(initial_balance_recipient, recipient_address)
|
2017-10-13 08:41:30 +00:00
|
|
|
|
|
|
|
@pytest.mark.transaction
|
|
|
|
def test_send_transaction_from_daap(self):
|
2018-01-03 09:34:40 +00:00
|
|
|
console = ConsoleView(self.driver)
|
|
|
|
user_flow.recover_access(console,
|
|
|
|
transaction_users['B_USER']['passphrase'],
|
|
|
|
transaction_users['B_USER']['password'],
|
|
|
|
transaction_users['B_USER']['username'])
|
|
|
|
chats_view = console.get_chat_view()
|
2017-10-23 10:23:14 +00:00
|
|
|
address = transaction_users['B_USER']['address']
|
2018-01-03 09:34:40 +00:00
|
|
|
initial_balance = api_requests.get_balance(address)
|
|
|
|
contacts_view = chats_view.contacts_button.click()
|
|
|
|
auction_house = contacts_view.auction_house_button.click()
|
2017-10-13 08:41:30 +00:00
|
|
|
auction_house.toggle_navigation_button.click()
|
|
|
|
auction_house.new_auction_button.click()
|
|
|
|
auction_house.name_to_reserve_input.click()
|
|
|
|
auction_name = time.strftime('%Y-%m-%d-%H-%M')
|
|
|
|
auction_house.send_as_keyevent(auction_name)
|
|
|
|
auction_house.register_name_button.click()
|
2018-01-03 09:34:40 +00:00
|
|
|
send_transaction_view = chats_view.get_send_transaction_view()
|
|
|
|
send_transaction_view.sign_transaction_button.wait_for_element(20)
|
|
|
|
send_transaction_view.sign_transaction_button.click()
|
|
|
|
send_transaction_view.enter_password_input.send_keys(transaction_users['B_USER']['password'])
|
|
|
|
send_transaction_view.sign_transaction_button.click()
|
|
|
|
send_transaction_view.got_it_button.click()
|
2017-10-13 08:41:30 +00:00
|
|
|
auction_house.find_full_text('You are the proud owner of the name: ' + auction_name, 120)
|
2018-01-03 09:34:40 +00:00
|
|
|
api_requests.verify_balance_is_updated(initial_balance, address)
|