Skip to content

Commit

Permalink
e2e for PN and set max
Browse files Browse the repository at this point in the history
Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
  • Loading branch information
churik committed Jul 29, 2020
1 parent 788d0d5 commit 56364ea
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 25 deletions.
34 changes: 24 additions & 10 deletions test/appium/tests/atomic/chats/test_chats_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,13 @@ def test_block_user_from_public_chat(self):

@marks.testrail_id(5763)
@marks.medium
def test_block_user_from_one_to_one_header(self):
def test_block_user_from_one_to_one_header_check_push_notification_service(self):
self.create_drivers(2)
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
message_before_block_1 = "Before block from %s" % device_1.driver.number
message_before_block_2 = "Before block from %s" % device_2.driver.number
message_after_block_2 = "After block from %s" % device_2.driver.number
home_1, home_2 = device_1.create_user(), device_2.create_user()
home_1, home_2 = device_1.create_user(enable_notifications=True), device_2.create_user()
profile_1 = home_1.profile_button.click()
device_2_public_key = home_2.get_public_key_and_username()
home_2.get_back_to_home_view()
Expand Down Expand Up @@ -532,11 +532,12 @@ def test_block_user_from_one_to_one_header(self):
device_1.just_fyi('no 1-1, messages from blocked user are hidden in public chat')
if home_1.get_chat(basic_user['username']).is_element_displayed():
home_1.driver.fail("Chat with blocked user '%s' is not deleted" % device_2.driver.number)
public_chat_after_block = home_1.join_public_chat(chat_name)
if public_chat_after_block.chat_element_by_text(message_before_block_2).is_element_displayed():
public_chat_after_block_1 = home_1.join_public_chat(chat_name)
if public_chat_after_block_1.chat_element_by_text(message_before_block_2).is_element_displayed():
self.errors.append(
"Messages from blocked user '%s' are not cleared in public chat '%s'" % (device_2.driver.number,
chat_name))
device_1.click_system_home_button()

device_2.just_fyi('send messages to 1-1 and public chat')
for _ in range(2):
Expand All @@ -550,13 +551,19 @@ def test_block_user_from_one_to_one_header(self):
chat_public_2.chat_message_input.send_keys(message_after_block_2)
chat_public_2.send_message_button.click()

device_1.just_fyi("check that new messages didn't arrived from blocked user")
if public_chat_after_block.chat_element_by_text(message_after_block_2).is_element_displayed():
device_1.just_fyi("check that new messages and push notifications don't arrive from blocked user")
device_1.open_notification_bar()
if device_1.element_by_text_part(message_after_block_2).is_element_displayed():
self.errors.append("Push notification is received from blocked user")
device_1.element_by_text_part("Background notification service").click()

if public_chat_after_block_1.chat_element_by_text(message_after_block_2).is_element_displayed():
self.errors.append("Message from blocked user '%s' is received" % device_2.driver.number)
public_chat_after_block.get_back_to_home_view()
public_chat_after_block_1.get_back_to_home_view()
if home_1.get_chat(basic_user['username']).is_element_displayed():
device_2.driver.fail("Chat with blocked user is reappeared after receiving new messages")
self.drivers[0].close_app()
device_1.open_notification_bar()
home_1.stop_status_service_button.click()

device_2.just_fyi("send messages when device 1 is offline")
for _ in range(2):
Expand All @@ -569,6 +576,7 @@ def test_block_user_from_one_to_one_header(self):
chat_2.send_message_button.click()

device_1.just_fyi("reopen app and check that messages from blocked user are not fetched")
device_1.click_system_home_button()
self.drivers[0].launch_app()
device_1.accept_agreements()
device_1.sign_in()
Expand All @@ -577,10 +585,16 @@ def test_block_user_from_one_to_one_header(self):
home_1.join_public_chat(chat_name)
home_1.get_chat_view()
if chat_public_1.chat_element_by_text(message_after_block_2).is_element_displayed():
self.errors.append(
"Message from blocked user '%s' is received after fetching new messages from offline"
self.errors.append("Message from blocked user '%s' is received after fetching new messages from offline"
% device_2.driver.number)

device_1.just_fyi("check that PNs are still enabled in profile after closing 'background notification centre' "
"message and relogin")
home_1.profile_button.click()
profile_1.push_notification_toggle.scroll_to_element()
if not profile_1.push_notification_toggle.is_element_image_equals_template('enabled_toggle.png'):
self.errors.append('Toggle is not enabled')

self.errors.verify_no_errors()

@marks.testrail_id(6233)
Expand Down
8 changes: 2 additions & 6 deletions test/appium/tests/atomic/chats/test_keycard_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_keycard_send_eth_in_1_1_chat(self):
self.errors.verify_no_errors()

@marks.testrail_id(6294)
@marks.critical
@marks.medium
def test_keycard_request_and_receive_stt_in_1_1_chat_offline(self):
sender = transaction_senders['D']
self.create_drivers(2)
Expand Down Expand Up @@ -161,13 +161,9 @@ def test_keycard_request_and_receive_stt_in_1_1_chat_offline(self):
self.network_api.wait_for_confirmation_of_transaction(sender['address'], amount, token=True)
chat_2.toggle_airplane_mode()
chat_2.connection_status.wait_for_invisibility_of_element(60)
if chat_2_sender_message.transaction_status.text != 'Confirmed':
if not chat_2.element_by_text('Confirmed').is_element_displayed(30):
self.errors.append('Wrong state is shown for outgoing transaction: "Confirmed" is expected, in fact'
' %s ' % chat_2_sender_message.transaction_status.text)
try:
self.network_api.find_transaction_by_unique_amount(recipient_address[2:], amount, token=True)
except Failed as e:
self.errors.append(e.msg)
self.errors.verify_no_errors()


Expand Down
6 changes: 2 additions & 4 deletions test/appium/tests/atomic/chats/test_one_to_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ def test_push_notification_1_1_chat(self):
device_1.driver.fail("Failed to open chat view after tap on PN")

device_1.just_fyi("Checks there are no PN after message was seen")
device_1.click_system_home_button()
device_2.click_system_home_button()
device_1.open_notification_bar()
device_2.open_notification_bar()
[device.click_system_home_button() for device in (device_1, device_2)]
[device.open_notification_bar() for device in (device_1, device_2)]
if (device_2.element_by_text_part(message).is_element_displayed()
or device_1.element_by_text_part(emoji_unicode).is_element_displayed()):
self.errors.append("PN are keep staying after message was seen by user")
Expand Down
18 changes: 17 additions & 1 deletion test/appium/tests/atomic/transactions/test_keycard_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_keycard_send_funds_between_accounts_in_multiaccount_instance(self):
send_transaction.sign_transaction_button.click()
send_transaction.sign_transaction(keycard=True)
self.network_api.wait_for_confirmation_of_transaction(status_account_address, transaction_amount)
self.network_api.verify_balance_is_updated('0.1', status_account_address)
self.network_api.verify_balance_is_updated('0', status_account_address)

wallet_view.just_fyi("Verifying previously sent transaction in new account")
wallet_view.back_button.click()
Expand Down Expand Up @@ -186,3 +186,19 @@ def test_keycard_send_funds_between_accounts_in_multiaccount_instance(self):
if total_eth_from_two_accounts != expected_balance:
self.driver.fail('Total wallet balance %s != of Status account (%s) + SubAccount (%s)' % (
total_eth_from_two_accounts, balance_of_status_account, balance_of_sub_account))

wallet_view.just_fyi("Check that can set max and send transaction with max amount from subaccount")
wallet_view.get_account_by_name(account_name).click()
wallet_view.send_transaction_button.click()
send_transaction.set_max_button.click()
set_amount = float(send_transaction.amount_edit_box.text)
if set_amount == 0.0 or set_amount >= balance_of_sub_account:
self.driver.fail('Value after setting up max amount is set to %s' % str(set_amount))
send_transaction.confirm()
send_transaction.chose_recipient_button.click()
send_transaction.accounts_button.click()
send_transaction.element_by_text('Status account').click()
send_transaction.sign_transaction_button.click()
send_transaction.sign_transaction(keycard=True)
wallet_view.element_by_text('Assets').click()
wallet_view.wait_balance_is_equal_expected_amount(asset='ETH', expected_balance=0)
4 changes: 2 additions & 2 deletions test/appium/tests/atomic/transactions/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def test_validation_amount_errors(self):
wallet_view.back_button.click()

screen = 'sending screen from wallet'
sign_in_view.just_fyi('Checking %s on %s' % (errors['sending_screen']['Network fee'],screen))
sign_in_view.just_fyi('Checking %s on %s' % (errors['sending_screen']['Network fee'], screen))
account_name = 'new'
wallet_view.add_account(account_name)
wallet_view.get_account_by_name(account_name).click()
Expand Down Expand Up @@ -613,7 +613,7 @@ def test_validation_amount_errors(self):
send_transaction.cancel_button.click()

screen = 'sending screen from DApp'
sign_in_view.just_fyi('Checking %s on %s' % (errors['sending_screen']['Network fee'],screen))
sign_in_view.just_fyi('Checking %s on %s' % (errors['sending_screen']['Network fee'], screen))
home_view = wallet_view.home_button.click()
dapp_view = sign_in_view.dapp_tab_button.click()
dapp_view.select_account_button.click()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions test/appium/views/home_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def __init__(self, driver):
super(ChatsMenuInviteFriendsButton, self).__init__(driver)
self.locator = self.Locator.accessibility_id('chats-menu-invite-friends-button')

class StopStatusServiceButton(BaseButton):
def __init__(self, driver):
super(StopStatusServiceButton, self).__init__(driver)
self.locator = self.Locator.accessibility_id('STOP')

class UserNameBelowNewChatButton(BaseButton):
def __init__(self, driver, username_part):
Expand Down Expand Up @@ -177,6 +181,7 @@ def __init__(self, driver):
self.delete_chat_button = DeleteChatButton(self.driver)
self.clear_history_button = ClearHistoryButton(self.driver)
self.mark_all_messages_as_read_button = MarkAllMessagesAsReadButton(self.driver)
self.stop_status_service_button = StopStatusServiceButton(self.driver)

def wait_for_syncing_complete(self):
self.driver.info('Waiting for syncing complete:')
Expand Down
9 changes: 9 additions & 0 deletions test/appium/views/profile_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,12 @@ def __init__(self, driver):
self.locator = self.Locator.xpath_selector(
"//*[@text='Ask me when on mobile network']/following-sibling::android.widget.Switch[1]")

class PushNotificationToggle(BaseButton):
def __init__(self, driver):
super(PushNotificationToggle, self).__init__(driver)
self.locator = self.Locator.xpath_selector(
"//*[@content-desc='notifications-button']//*[@content-desc='switch']")

class ENSUsernameInChatSettings(BaseElement):
def __init__(self, driver):
super(ENSUsernameInChatSettings, self).__init__(driver)
Expand Down Expand Up @@ -672,6 +678,9 @@ def __init__(self, driver):
self.use_mobile_data = UseMobileDataToggle(self.driver)
self.ask_me_when_on_mobile_network = AskMeWhenOnMobileNetworkToggle(self.driver)

#Push notifications
self.push_notification_toggle = PushNotificationToggle(self.driver)

def switch_network(self, network='Mainnet with upstream RPC'):
self.advanced_button.click()
self.network_settings_button.click()
Expand Down
11 changes: 9 additions & 2 deletions test/appium/views/send_transaction_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, driver):
class CancelButton(BaseButton):
def __init__(self, driver):
super(CancelButton, self).__init__(driver)
self.locator = self.Locator.xpath_selector("//*[@text='Cancel']")
self.locator = self.Locator.text_selector("Cancel")


class SignTransactionButton(BaseButton):
Expand All @@ -28,6 +28,12 @@ def __init__(self, driver):
super(AmountEditBox, self).__init__(driver)
self.locator = self.Locator.accessibility_id('amount-input')

class SetMaxButton(BaseButton):

def __init__(self, driver):
super(SetMaxButton, self).__init__(driver)
self.locator = self.Locator.text_selector('Set max')


class SignInPhraseText(BaseText):
def __init__(self, driver):
Expand Down Expand Up @@ -189,7 +195,7 @@ def __init__(self, driver, field):
class ValidationIconOnSendTransaction(BaseButton):
def __init__(self, driver):
super(ValidationIconOnSendTransaction, self).__init__(driver)
self.locator = self.Locator.xpath_selector('//*[@content-desc="custom-gas-fee"]/../android.view.ViewGroup/*[@content-desc="icon"]')
self.locator = self.Locator.xpath_selector('//*[@content-desc="custom-gas-fee"]/../android.view.ViewGroup//*[@content-desc="icon"]')



Expand Down Expand Up @@ -288,6 +294,7 @@ def __init__(self, driver):
self.enter_recipient_address_text = EnterRecipientAddressInputText(self.driver)
self.recent_recipients_button = RecentRecipientsButton(self.driver)
self.amount_edit_box = AmountEditBox(self.driver)
self.set_max_button = SetMaxButton(self.driver)
self.validation_error_element = ValidationIconOnSendTransaction(self.driver)

self.network_fee_button = NetworkFeeButton(self.driver)
Expand Down

0 comments on commit 56364ea

Please sign in to comment.