Skip to content
This repository was archived by the owner on Aug 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions gui/components/toast_message.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import typing

import allure

import driver
from driver.objects_access import walk_children
from gui.elements.object import QObject
from gui.objects_map import names

Expand All @@ -11,14 +13,12 @@ def __init__(self):
super(ToastMessage, self).__init__(names.ephemeral_Notification_List)
self._toast_message = QObject(names.ephemeralNotificationList_StatusToastMessage)

@property
@allure.step('Get toast messages')
def get_toast_messages(self):
def get_toast_messages(self) -> typing.List[str]:
messages = []
for obj in driver.findAllObjects(self._toast_message.real_name):
messages.append(str(obj.primaryText))
for child in walk_children(self.object):
if getattr(child, 'id', '') == 'title':
messages.append(str(child.text))
if len(messages) == 0:
raise LookupError(
'Toast messages were not found')
else:
return messages
raise LookupError('Toast message not found')
return messages
5 changes: 2 additions & 3 deletions gui/main_window.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import os
import time
import typing

Expand Down Expand Up @@ -215,11 +214,11 @@ def create_community(self, name, description, intro, outro, logo, banner) -> Com
return app_screen

@allure.step('Wait for notification and get text')
def wait_for_notification(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_SEC) -> str:
def wait_for_notification(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_SEC) -> list[str]:
started_at = time.monotonic()
while True:
try:
return ToastMessage().get_toast_messages
return ToastMessage().get_toast_messages()
except LookupError as err:
LOG.info(err)
assert time.monotonic() - started_at < timeout_msec, str(err)
17 changes: 0 additions & 17 deletions gui/screens/settings_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from gui.components.wallet.testnet_mode_popup import TestnetModePopup

from gui.components.wallet.wallet_account_popups import AccountPopup, EditAccountFromSettingsPopup
from gui.components.toast_message import ToastMessage
from gui.elements.button import Button
from gui.elements.check_box import CheckBox
from gui.elements.object import QObject
Expand Down Expand Up @@ -313,22 +312,6 @@ def click_revert_to_default_and_go_to_networks_main_screen(self, attempts: int =
else:
raise f"Networks screen was not opened"

@allure.step('Check toast message')
def check_toast_message(self, network_tab):
match network_tab:
case WalletNetworkSettings.EDIT_NETWORK_LIVE_TAB.value:
assert len(ToastMessage().get_toast_messages) == 1, \
f"Multiple toast messages appeared"
message = ToastMessage().get_toast_messages[0]
assert message == WalletNetworkSettings.REVERT_TO_DEFAULT_LIVE_MAINNET_TOAST_MESSAGE.value, \
f"Toast message is incorrect, current message is {message}"
case WalletNetworkSettings.EDIT_NETWORK_TEST_TAB.value:
assert len(ToastMessage().get_toast_messages) == 1, \
f"Multiple toast messages appeared"
message = ToastMessage().get_toast_messages[0]
assert message == WalletNetworkSettings.REVERT_TO_DEFAULT_TEST_MAINNET_TOAST_MESSAGE.value, \
f"Toast message is incorrect, current message is {message}"

@allure.step('Verify elements for the edit network view')
def check_available_elements_on_edit_view(self, network_tab):
match network_tab:
Expand Down
33 changes: 15 additions & 18 deletions tests/communities/test_communities_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import configs
from gui.components.changes_detected_popup import PermissionsChangesDetectedToastMessage
from gui.components.delete_popup import DeletePermissionPopup
from gui.components.toast_message import ToastMessage
from gui.screens.community_settings import PermissionsIntroView
from . import marks

Expand Down Expand Up @@ -54,13 +53,13 @@ def test_add_edit_and_remove_permissions(main_screen: MainWindow, params, checkb
permissions_settings.set_in(in_channel)
permissions_settings.create_permission()

# TODO: https://github.com/status-im/desktop-qa-automation/issues/547
# with step('Check toast message for permission creation'):
# assert len(ToastMessage().get_toast_messages) == 1, \
# f"Multiple toast messages appeared"
# message = ToastMessage().get_toast_messages[0]
# assert message == ToastMessages.CREATE_PERMISSION_TOAST.value, \
# f"Toast message is incorrect, current message is {message}"
with step('Check toast message for permission creation'):
toast_messages = main_screen.wait_for_notification()
assert len(toast_messages) == 1, \
f"Multiple toast messages appeared"
message = toast_messages[0]
assert message == ToastMessages.CREATE_PERMISSION_TOAST.value, \
f"Toast message is incorrect, current message is {message}"

with step('Created permission is displayed on permission page'):
if asset_title is not False:
Expand Down Expand Up @@ -108,11 +107,10 @@ def test_add_edit_and_remove_permissions(main_screen: MainWindow, params, checkb
assert driver.waitFor(lambda: permissions_intro_view.is_hide_icon_visible,
configs.timeouts.UI_LOAD_TIMEOUT_MSEC)

# TODO: https://github.com/status-im/desktop-qa-automation/issues/547
# with step('Check toast message for edited permission'):
# messages = ToastMessage().get_toast_messages
# assert ToastMessages.UPDATE_PERMISSION_TOAST.value in messages, \
# f"Toast message is incorrect, current message is {message}"
with step('Check toast message for edited permission'):
messages = main_screen.wait_for_notification()
assert ToastMessages.UPDATE_PERMISSION_TOAST.value in messages, \
f"Toast message is incorrect, current message is {message}"

with step('Delete permission'):
permissions_intro_view.click_delete_permission()
Expand All @@ -121,8 +119,7 @@ def test_add_edit_and_remove_permissions(main_screen: MainWindow, params, checkb
with step('Verify that permission was deleted'):
assert driver.waitFor(lambda: PermissionsIntroView().is_visible)

# TODO: https://github.com/status-im/desktop-qa-automation/issues/547
# with step('Check toast message for deleted permission'):
# messages = ToastMessage().get_toast_messages
# assert ToastMessages.DELETE_PERMISSION_TOAST.value in messages, \
# f"Toast message is incorrect, current message is {message}"
with step('Check toast message for deleted permission'):
messages = main_screen.wait_for_notification()
assert ToastMessages.DELETE_PERMISSION_TOAST.value in messages, \
f"Toast message is incorrect, current message is {message}"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import constants
from constants import UserAccount
from constants.messaging import Messaging
from gui.components.toast_message import ToastMessage
from gui.main_window import MainWindow

pytestmark = marks
Expand Down Expand Up @@ -67,13 +66,13 @@ def test_messaging_settings_accepting_request(multiple_instance, user_data_one,
assert user_one.name == contacts_settings.contact_items[0].contact
assert len(contacts_settings.contact_items) == 1

# TODO: https://github.com/status-im/desktop-qa-automation/issues/547
# with step('Verify toast message about new contact request received'):
# assert len(ToastMessage().get_toast_messages) == 1, \
# f"Multiple toast messages appeared"
# message = ToastMessage().get_toast_messages[0]
# assert message == Messaging.NEW_CONTACT_REQUEST.value, \
# f"Toast message is incorrect, current message is {message}"
with step('Verify toast message about new contact request received'):
toast_messages = main_window.wait_for_notification()
assert len(toast_messages) == 1, \
f"Multiple toast messages appeared"
message = toast_messages[0]
assert message == Messaging.NEW_CONTACT_REQUEST.value, \
f"Toast message is incorrect, current message is {message}"

with step(f'User {user_two.name}, accept contact request from {user_one.name}'):
contacts_settings.accept_contact_request(user_one.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ def test_messaging_settings_identity_verification(multiple_instance, user_data_o
assert not verify_identity_popup.is_send_verification_button_enabled
verify_identity_popup.type_message('Hi. Is that you?').send_verification()

# TODO https://github.com/status-im/desktop-qa-automation/issues/547 - will be enabled in this task
# with step('Verify toast message about sent ID verification request'):
# toast_messages = main_window.wait_for_notification()
# assert Messaging.ID_VERIFICATION_REQUEST_SENT.value in toast_messages
# main_window.hide()
with step('Verify toast message about sent ID verification request'):
toast_messages = main_window.wait_for_notification()
assert Messaging.ID_VERIFICATION_REQUEST_SENT.value in toast_messages
main_window.hide()

with step(f'Check incoming identity request for {user_two.name}'):
aut_two.attach()
Expand All @@ -83,7 +82,6 @@ def test_messaging_settings_identity_verification(multiple_instance, user_data_o
respond_identity_popup = contacts_settings.open_more_options_popup(user_one.name).respond_to_id_request()
respond_identity_popup.type_message('Hi. Yes, its me').send_answer()

# TODO https://github.com/status-im/desktop-qa-automation/issues/547 - will be enabled in this task
# with step('Verify toast message about sent ID verification reply'):
# toast_messages = main_window.wait_for_notification()
# assert Messaging.ID_VERIFICATION_REPLY_SENT.value in toast_messages
with step('Verify toast message about sent ID verification reply'):
toast_messages = main_window.wait_for_notification()
assert Messaging.ID_VERIFICATION_REPLY_SENT.value in toast_messages
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_delete_generated_account_from_wallet_settings(
delete_confirmation_popup.remove_account_with_confirmation()

with step('Verify toast message notification when removing account'):
messages = ToastMessage().get_toast_messages
messages = main_screen.wait_for_notification()
assert f'"{account_name}" successfully removed' in messages, \
f"Toast message about account removal is not correct or not present. Current list of messages: {messages}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def test_add_new_account_from_wallet_settings(
add_account_popup.wait_until_hidden()

with step('Verify toast message notification when adding account'):
assert len(ToastMessage().get_toast_messages) == 1, \
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = ToastMessage().get_toast_messages[0]
message = main_screen.wait_for_notification()[0]
assert message == f'"{account_name}" successfully added'

with step('Verify that the account is correctly displayed in accounts list on main wallet screen'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,18 @@ def test_settings_networks_edit_restore_defaults(main_screen: MainWindow, networ
edit_network_form.click_revert_to_default_and_go_to_networks_main_screen()

with step('Verify toast message appears for reverting to defaults'):
edit_network_form.check_toast_message(network_tab)
if network_tab == WalletNetworkSettings.EDIT_NETWORK_LIVE_TAB.value:
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = main_screen.wait_for_notification()[0]
assert message == WalletNetworkSettings.REVERT_TO_DEFAULT_LIVE_MAINNET_TOAST_MESSAGE.value, \
f"Toast message is incorrect, current message is {message}"
elif network_tab == WalletNetworkSettings.EDIT_NETWORK_TEST_TAB.value:
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = main_screen.wait_for_notification()[0]
assert message == WalletNetworkSettings.REVERT_TO_DEFAULT_TEST_MAINNET_TOAST_MESSAGE.value, \
f"Toast message is incorrect, current message is {message}"

with step('Open Ethereum Mainnet network item to edit'):
edit_network_form = networks.click_network_item_to_open_edit_view(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def test_switch_testnet_mode(main_screen: MainWindow):
networks.switch_testnet_mode_toggle().turn_on_testnet_mode_in_testnet_modal()

with step('Verify that Testnet mode turned on'):
assert len(ToastMessage().get_toast_messages) == 1, \
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = ToastMessage().get_toast_messages[0]
message = main_screen.wait_for_notification()[0]
assert message == WalletNetworkSettings.TESTNET_ENABLED_TOAST_MESSAGE.value, \
f"Toast message is incorrect, current message is {message}"
if not configs.system.TEST_MODE:
Expand All @@ -52,8 +52,8 @@ def test_switch_testnet_mode(main_screen: MainWindow):
networks.switch_testnet_mode_toggle().turn_off_testnet_mode_in_testnet_modal()

with step('Verify that Testnet mode turned off'):
assert len(ToastMessage().get_toast_messages) == 2
message = ToastMessage().get_toast_messages[1]
assert len(main_screen.wait_for_notification()) == 2
message = main_screen.wait_for_notification()[1]
assert message == WalletNetworkSettings.TESTNET_DISABLED_TOAST_MESSAGE.value, \
f"Toast message is incorrect, current message is {message}"
if not configs.system.TEST_MODE:
Expand Down Expand Up @@ -105,9 +105,9 @@ def test_switch_testnet_off_by_toggle_and_cancel_in_confirmation(main_screen: Ma
testnet_modal.turn_on_testnet_mode_in_testnet_modal()

with step('Verify testnet mode is enabled'):
assert len(ToastMessage().get_toast_messages) == 1, \
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = ToastMessage().get_toast_messages[0]
message = main_screen.wait_for_notification()[0]
assert message == WalletNetworkSettings.TESTNET_ENABLED_TOAST_MESSAGE.value, \
f"Toast message is incorrect, current message is {message}"
if not configs.system.TEST_MODE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_wallet_settings_add_saved_address(main_screen: MainWindow, address: str
configs.timeouts.UI_LOAD_TIMEOUT_MSEC), f'Address: {name} not found'

with step('Verify toast message when adding saved address'):
messages = ToastMessage().get_toast_messages
messages = main_screen.wait_for_notification()
assert f'{name} successfully added to your saved addresses' in messages, \
f"Toast message about adding saved address is not correct or not present. \
Current list of messages: {messages}"
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def test_add_generated_account_restart_add_again(
account_popup.wait_until_hidden()

with step('Verify toast message notification when adding account'):
assert len(ToastMessage().get_toast_messages) == 1, \
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = ToastMessage().get_toast_messages[0]
message = main_screen.wait_for_notification()[0]
assert message == f'"{name}" successfully added'

with step('Verify that the account is correctly displayed in accounts list'):
Expand All @@ -67,9 +67,9 @@ def test_add_generated_account_restart_add_again(
account_popup.wait_until_hidden()

with step('Verify toast message notification when adding account'):
assert len(ToastMessage().get_toast_messages) == 1, \
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = ToastMessage().get_toast_messages[0]
message = main_screen.wait_for_notification()[0]
assert message == f'"{name2}" successfully added'

with step('Verify that the account is correctly displayed in accounts list'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def test_plus_button_add_watched_address(
f"Authentication should not appear for adding watched addresses"

with step('Verify toast message notification when adding account'):
assert len(ToastMessage().get_toast_messages) == 1, \
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = ToastMessage().get_toast_messages[0]
message = main_screen.wait_for_notification()[0]
assert message == f'"{name}" successfully added'

with step('Verify that the account is correctly displayed in accounts list'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def test_plus_button_manage_account_added_for_new_seed(main_screen: MainWindow,
account_popup.wait_until_hidden()

with step('Verify toast message notification when adding account'):
assert len(ToastMessage().get_toast_messages) == 1, \
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = ToastMessage().get_toast_messages[0]
message = main_screen.wait_for_notification()[0]
assert message == f'"{name}" successfully added'

with step('Verify that the account is correctly displayed in accounts list'):
Expand All @@ -67,7 +67,7 @@ def test_plus_button_manage_account_added_for_new_seed(main_screen: MainWindow,
wallet.left_panel.delete_account_from_context_menu(new_name).agree_and_confirm()

with step('Verify toast message notification when removing account'):
messages = ToastMessage().get_toast_messages
messages = main_screen.wait_for_notification()
assert f'"{new_name}" successfully removed' in messages, \
f"Toast message about account removal is not correct or not present. Current list of messages: {messages}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def test_plus_button_manage_account_from_private_key(main_screen: MainWindow, us
account_popup.wait_until_hidden()

with step('Verify toast message notification when adding account'):
assert len(ToastMessage().get_toast_messages) == 1, \
assert len(main_screen.wait_for_notification()) == 1, \
f"Multiple toast messages appeared"
message = ToastMessage().get_toast_messages[0]
message = main_screen.wait_for_notification()[0]
assert message == f'"{name}" successfully added'

with step('Verify that the account is correctly displayed in accounts list'):
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_plus_button_manage_account_from_private_key(main_screen: MainWindow, us
wallet.left_panel.delete_account_from_context_menu(new_name).agree_and_confirm()

with step('Verify toast message notification when removing account'):
messages = ToastMessage().get_toast_messages
messages = main_screen.wait_for_notification()
assert f'"{new_name}" successfully removed' in messages, \
f"Toast message about account removal is not correct or not present. Current list of messages: {messages}"

Expand Down
Loading