mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-12 09:44:13 +00:00
e2e: added test for Add contact validation
This commit is contained in:
parent
6436e82990
commit
17e9ce7513
@ -3,6 +3,7 @@ from selenium.common.exceptions import TimeoutException
|
||||
|
||||
from tests import marks, run_in_parallel
|
||||
from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
|
||||
from tests.users import transaction_senders
|
||||
from views.sign_in_view import SignInView
|
||||
|
||||
|
||||
@ -33,8 +34,14 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC
|
||||
self.home_2.add_a_contact_chat_bottom_sheet_button.click()
|
||||
self.home_2.element_by_translation_id("paste").click()
|
||||
self.home_2.element_by_translation_id("user-found").wait_for_visibility_of_element(10)
|
||||
if not self.home_2.element_by_text(self.username_1).is_element_displayed(30):
|
||||
self.errors.append("Username is not shown on 'Add contact' page after entering valid public key")
|
||||
if self.home_2.user_name_text.is_element_displayed(30):
|
||||
text_name = self.home_2.user_name_text.text
|
||||
if text_name != self.username_1 and text_name != "%s...%s" % (
|
||||
self.public_key_1[:3], self.public_key_1[-6:]):
|
||||
self.errors.append(
|
||||
"Neither username nor public key is shown on 'Add contact' page after entering valid public key")
|
||||
else:
|
||||
self.errors.append("User is not found on 'Add contact' page after entering valid public key")
|
||||
chat = self.home_2.get_chat_view()
|
||||
|
||||
chat.view_profile_new_contact_button.click_until_presence_of_element(chat.profile_block_contact_button)
|
||||
@ -128,6 +135,73 @@ class TestActivityCenterContactRequestMultipleDevicePR(MultipleSharedDeviceTestC
|
||||
|
||||
self.errors.verify_no_errors()
|
||||
|
||||
@marks.testrail_id(702777)
|
||||
def test_add_contact_field_validation(self):
|
||||
self.home_2.just_fyi("Device 2 creates a new user")
|
||||
self.home_2.navigate_back_to_home_view()
|
||||
self.home_2.profile_button.click()
|
||||
self.profile_2.logout()
|
||||
new_username_2 = "test user 123"
|
||||
self.device_2.create_user(third_user=True, username=new_username_2)
|
||||
|
||||
self.device_2.just_fyi('Device2 sends a contact request to Device1 using his profile link')
|
||||
self.home_2.driver.set_clipboard_text("https://join.status.im/u/" + self.public_key_1)
|
||||
self.home_2.chats_tab.click()
|
||||
self.home_2.new_chat_button.click_until_presence_of_element(self.home_2.add_a_contact_chat_bottom_sheet_button)
|
||||
self.home_2.add_a_contact_chat_bottom_sheet_button.click()
|
||||
self.home_2.element_by_translation_id("paste").click()
|
||||
self.home_2.element_by_translation_id("user-found").wait_for_visibility_of_element(10)
|
||||
if self.home_2.user_name_text.is_element_displayed(30):
|
||||
text_name = self.home_2.user_name_text.text
|
||||
if text_name != self.username_1 and text_name != "%s...%s" % (
|
||||
self.public_key_1[:3], self.public_key_1[-6:]):
|
||||
self.errors.append(
|
||||
"Neither username nor public key is shown on 'Add contact' page after entering valid profile link")
|
||||
else:
|
||||
self.errors.append("User is not found on 'Add contact' page after entering valid public key")
|
||||
chat_2 = self.home_2.get_chat_view()
|
||||
chat_2.view_profile_new_contact_button.click_until_presence_of_element(chat_2.profile_block_contact_button)
|
||||
chat_2.profile_add_to_contacts_button.click()
|
||||
|
||||
self.home_1.just_fyi("Device 1 accepts contact request")
|
||||
self.home_1.handle_contact_request(new_username_2)
|
||||
|
||||
self.home_2.just_fyi("Device 2 checks that can find already added contact using public key")
|
||||
self.home_2.navigate_back_to_home_view()
|
||||
self.home_2.driver.set_clipboard_text(self.public_key_1)
|
||||
self.home_2.new_chat_button.click_until_presence_of_element(self.home_2.add_a_contact_chat_bottom_sheet_button)
|
||||
self.home_2.add_a_contact_chat_bottom_sheet_button.click()
|
||||
self.home_2.element_by_translation_id("paste").click()
|
||||
self.home_2.element_by_translation_id("user-found").wait_for_visibility_of_element(10)
|
||||
if self.home_2.user_name_text.is_element_displayed(30):
|
||||
text_name = self.home_2.user_name_text.text
|
||||
if text_name != self.username_1 and text_name != "%s...%s" % (
|
||||
self.public_key_1[:3], self.public_key_1[-6:]):
|
||||
self.errors.append(
|
||||
"Neither username nor public key is shown on 'Add contact' page after entering valid public key")
|
||||
else:
|
||||
self.errors.append("User is not found on 'Add contact' page after entering valid public key")
|
||||
|
||||
self.home_1.just_fyi("Device 1 gets sync code")
|
||||
self.home_1.navigate_back_to_home_view()
|
||||
self.home_1.profile_button.click_until_presence_of_element(self.profile_1.default_username_text)
|
||||
sync_code = self.profile_1.get_sync_code()
|
||||
|
||||
invalid_values = [self.public_key_1[:-1], "random string 123",
|
||||
'0x' + transaction_senders['ETH_ADI_STT_3']['address'], sync_code]
|
||||
for value in invalid_values:
|
||||
self.home_2.just_fyi("Device 2 checks adding a contact with invalid value \"%s\"" % value)
|
||||
chat_2.public_key_edit_box.clear()
|
||||
self.home_2.element_by_translation_id("invalid-ens-or-key").wait_for_invisibility_of_element()
|
||||
self.home_2.driver.set_clipboard_text(value)
|
||||
self.home_2.element_by_translation_id("paste").click()
|
||||
try:
|
||||
self.home_2.element_by_translation_id("invalid-ens-or-key").wait_for_visibility_of_element()
|
||||
except TimeoutException:
|
||||
self.errors.append("Error message is not shown for value \"%s\"" % value)
|
||||
|
||||
self.errors.verify_no_errors()
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="new_four_2")
|
||||
@marks.new_ui_critical
|
||||
|
@ -294,12 +294,12 @@ class BaseElement(object):
|
||||
width, height = size['width'], size['height']
|
||||
self.driver.swipe(start_x=x + width * 0.75, start_y=y + height / 2, end_x=x, end_y=y + height / 2)
|
||||
|
||||
def swipe_right_on_element(self):
|
||||
def swipe_right_on_element(self, width_percentage=0.75):
|
||||
self.driver.info("Swiping right on element %s" % self.name)
|
||||
location, size = self.get_element_coordinates()
|
||||
x, y = location['x'], location['y']
|
||||
width, height = size['width'], size['height']
|
||||
self.driver.swipe(start_x=x, start_y=y + height / 2, end_x=x + width * 0.75, end_y=y + height / 2)
|
||||
self.driver.swipe(start_x=x, start_y=y + height / 2, end_x=x + width * width_percentage, end_y=y + height / 2)
|
||||
|
||||
def swipe_to_web_element(self, depth=700):
|
||||
element = self.find_element()
|
||||
|
@ -244,6 +244,8 @@ class BaseView(object):
|
||||
self.send_message_button = SendMessageButton(self.driver)
|
||||
self.send_contact_request_button = Button(self.driver, translation_id="send-request")
|
||||
self.password_input = EditBox(self.driver, accessibility_id="password-input")
|
||||
from views.sign_in_view import LogInButton
|
||||
self.login_button = LogInButton(self.driver)
|
||||
|
||||
# Old UI Tabs
|
||||
self.home_button = HomeButton(self.driver)
|
||||
@ -263,8 +265,7 @@ class BaseView(object):
|
||||
self.community_floating_screen = BaseElement(self.driver,
|
||||
accessibility_id=":community-overview-floating-screen")
|
||||
self.discover_communities_floating_screen = BaseElement(self.driver,
|
||||
accessibility_id=":discover-communities-floating-screen")
|
||||
|
||||
accessibility_id=":discover-communities-floating-screen")
|
||||
|
||||
self.jump_to_button = Button(self.driver, accessibility_id="jump-to")
|
||||
|
||||
|
@ -758,10 +758,6 @@ class ChatView(BaseView):
|
||||
self.view_profile_new_contact_button = Button(self.driver, accessibility_id="new-contact-button")
|
||||
|
||||
# Chat header
|
||||
self.user_name_text = Text(self.driver, accessibility_id="chat-name-text")
|
||||
self.user_name_text_new_UI = Text(
|
||||
self.driver,
|
||||
xpath="//*[@content-desc='user-avatar']/../following-sibling::android.widget.TextView")
|
||||
self.add_to_contacts = Button(self.driver, accessibility_id="add-to-contacts-button")
|
||||
## Options
|
||||
self.chat_options = ChatOptionsButton(self.driver)
|
||||
|
@ -234,6 +234,10 @@ class HomeView(BaseView):
|
||||
self.create_token_gated_community_button = ChatButton(self.driver,
|
||||
accessibility_id="create-token-gated-community")
|
||||
self.ens_banner_close_button = Button(self.driver, accessibility_id=":ens-banner-close-button")
|
||||
self.user_name_text = Text(
|
||||
self.driver,
|
||||
xpath="//*[@content-desc='new-contact-button']/preceding-sibling::*[1]/*[@content-desc='user-avatar']" + \
|
||||
"/following-sibling::android.widget.TextView[1]")
|
||||
|
||||
# Notification centre
|
||||
self.notifications_button = Button(self.driver, accessibility_id="notifications-button")
|
||||
|
@ -1,4 +1,6 @@
|
||||
import time
|
||||
|
||||
from tests import common_password
|
||||
from tests.base_test_case import AbstractTestCase
|
||||
from views.base_element import Text, Button, EditBox, SilentButton
|
||||
from views.base_view import BaseView
|
||||
@ -243,7 +245,8 @@ class ProfileView(BaseView):
|
||||
|
||||
# Notifications
|
||||
self.profile_notifications_button = Button(self.driver, accessibility_id="notifications-settings-button")
|
||||
self.profile_notifications_toggle_button = Button(self.driver, accessibility_id="local-notifications-settings-button")
|
||||
self.profile_notifications_toggle_button = Button(self.driver,
|
||||
accessibility_id="local-notifications-settings-button")
|
||||
self.push_notification_toggle = Button(self.driver,
|
||||
xpath="//*[@content-desc='notifications-button']//*[@content-desc='switch']")
|
||||
self.wallet_push_notifications = Button(self.driver, accessibility_id="notifications-button")
|
||||
@ -282,6 +285,10 @@ class ProfileView(BaseView):
|
||||
uppercase=True)
|
||||
self.advertise_device_button = Button(self.driver, accessibility_id="advertise-device")
|
||||
self.sync_all_button = Button(self.driver, translation_id="sync-all-devices")
|
||||
self.syncing_button = Button(self.driver, accessibility_id="syncing")
|
||||
self.sync_plus_button = Button(self.driver,
|
||||
xpath="//*[@text='Syncing']/following-sibling::android.view.ViewGroup[1]")
|
||||
self.slide_button_track = Button(self.driver, xpath="//*[@resource-id='slide-button-track']")
|
||||
|
||||
# Keycard
|
||||
self.keycard_button = Button(self.driver, accessibility_id="keycard-button")
|
||||
@ -379,7 +386,7 @@ class ProfileView(BaseView):
|
||||
self.profile_notifications_toggle_button.click()
|
||||
self.navigate_back_to_home_view()
|
||||
|
||||
def add_custom_network(self, rpc_url: str, name: str, symbol: str, netwrok_id:str):
|
||||
def add_custom_network(self, rpc_url: str, name: str, symbol: str, netwrok_id: str):
|
||||
self.driver.info("## Add custom network", device=False)
|
||||
self.advanced_button.click()
|
||||
self.network_settings_button.scroll_to_element()
|
||||
@ -520,3 +527,12 @@ class ProfileView(BaseView):
|
||||
self.advanced_button.click()
|
||||
self.active_network_name.scroll_to_element(10, 'up')
|
||||
return self.active_network_name.text
|
||||
|
||||
def get_sync_code(self):
|
||||
self.syncing_button.scroll_and_click()
|
||||
self.sync_plus_button.click()
|
||||
self.slide_button_track.swipe_right_on_element(width_percentage=1.3)
|
||||
self.password_input.send_keys(common_password)
|
||||
self.login_button.click()
|
||||
self.element_by_translation_id("copy-qr").click()
|
||||
return self.driver.get_clipboard_text()
|
||||
|
@ -143,7 +143,6 @@ class SignInView(BaseView):
|
||||
self.i_m_new_in_status_button = Button(self.driver, accessibility_id="new-to-status-button")
|
||||
|
||||
self.migration_password_input = EditBox(self.driver, accessibility_id="enter-password-input")
|
||||
self.login_button = LogInButton(self.driver)
|
||||
self.access_key_button = AccessKeyButton(self.driver)
|
||||
self.generate_key_button = Button(self.driver, accessibility_id="generate-old-key")
|
||||
self.your_keys_more_icon = Button(self.driver, xpath="//androidx.appcompat.widget.LinearLayoutCompat")
|
||||
@ -220,7 +219,7 @@ class SignInView(BaseView):
|
||||
pass
|
||||
|
||||
def create_user(self, password=common_password, keycard=False, enable_notifications=False, second_user=False,
|
||||
username="test user"):
|
||||
third_user=False, username="test user"):
|
||||
self.driver.info("## Creating new multiaccount (password:'%s', keycard:'%s', enable_notification: '%s')" %
|
||||
(password, str(keycard), str(enable_notifications)), device=False)
|
||||
if self.element_by_text('CONTINUE').is_element_displayed(5):
|
||||
@ -229,10 +228,12 @@ class SignInView(BaseView):
|
||||
self.show_profiles_button.wait_and_click(20)
|
||||
self.plus_profiles_button.click()
|
||||
self.create_new_profile_button.click()
|
||||
self.generate_keys_button.click_until_presence_of_element(self.profile_your_name_edit_box)
|
||||
elif third_user:
|
||||
self.plus_profiles_button.click()
|
||||
self.create_new_profile_button.click()
|
||||
else:
|
||||
self.i_m_new_in_status_button.click_until_presence_of_element(self.generate_keys_button)
|
||||
self.generate_keys_button.click_until_presence_of_element(self.profile_your_name_edit_box)
|
||||
self.generate_keys_button.click_until_presence_of_element(self.profile_your_name_edit_box)
|
||||
self.set_profile(username)
|
||||
self.set_password(password)
|
||||
if self.enable_biometric_maybe_later_button.is_element_displayed(10):
|
||||
|
Loading…
x
Reference in New Issue
Block a user