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
|
2018-01-14 17:43:36 +00:00
|
|
|
from selenium.common.exceptions import TimeoutException
|
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'),
|
2018-01-14 17:43:36 +00:00
|
|
|
('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()
|
2018-01-14 17:43:36 +00:00
|
|
|
home_view = console_view.get_home_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'
|
2018-01-14 17:43:36 +00:00
|
|
|
sender_address = user_flow.get_address(home_view)
|
|
|
|
home_view.home_button.click()
|
2018-01-03 09:34:40 +00:00
|
|
|
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-14 17:43:36 +00:00
|
|
|
user_flow.add_contact(home_view, recipient_key)
|
2017-10-13 08:41:30 +00:00
|
|
|
if test == 'group_chat':
|
2018-01-14 17:43:36 +00:00
|
|
|
home_view.back_button.click(times_to_click=3)
|
|
|
|
user_flow.create_group_chat(home_view, transaction_users[recipient]['username'],
|
2018-01-03 09:34:40 +00:00
|
|
|
'trg_%s' % get_current_time())
|
2018-01-14 17:43:36 +00:00
|
|
|
chat_view = home_view.get_chat_view()
|
2018-01-03 09:34:40 +00:00
|
|
|
else:
|
2018-01-14 17:43:36 +00:00
|
|
|
chat_view = home_view.get_chat_with_user(transaction_users[recipient]['username']).click()
|
|
|
|
chat_view.send_command.click()
|
2017-10-13 08:41:30 +00:00
|
|
|
if test == 'group_chat':
|
2018-01-14 17:43:36 +00:00
|
|
|
chat_view.first_recipient_button.click()
|
|
|
|
chat_view.send_as_keyevent(transaction_amount)
|
2017-10-13 08:41:30 +00:00
|
|
|
else:
|
2018-01-14 17:43:36 +00:00
|
|
|
chat_view.send_as_keyevent(transaction_amount)
|
|
|
|
chat_view.send_message_button.click()
|
|
|
|
send_transaction_view = chat_view.get_send_transaction_view()
|
2018-01-03 09:34:40 +00:00
|
|
|
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-14 17:43:36 +00:00
|
|
|
chat_view.find_full_text('Sent', 10)
|
2017-11-13 10:49:45 +00:00
|
|
|
except TimeoutException:
|
2018-01-14 17:43:36 +00:00
|
|
|
chat_view.find_full_text('Delivered', 10)
|
2017-10-13 08:41:30 +00:00
|
|
|
if test == 'group_chat':
|
2018-01-14 17:43:36 +00:00
|
|
|
chat_view.find_full_text('to ' + transaction_users[recipient]['username'], 60)
|
2018-01-03 09:34:40 +00:00
|
|
|
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'])
|
2018-01-14 17:43:36 +00:00
|
|
|
home_view = console.get_home_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)
|
2018-01-14 17:43:36 +00:00
|
|
|
start_new_chat_view = home_view.plus_button.click()
|
|
|
|
auction_house = start_new_chat_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-14 17:43:36 +00:00
|
|
|
send_transaction_view = home_view.get_send_transaction_view()
|
2018-01-03 09:34:40 +00:00
|
|
|
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)
|