e2e for mentions, gr chats, fixes

Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
This commit is contained in:
Churikova Tetiana 2020-10-20 17:34:52 +02:00
parent 04cd74e57d
commit e52f6b8753
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
16 changed files with 154 additions and 87 deletions

View File

@ -8,33 +8,34 @@
(let [input-ref (atom nil)
search-active? (or search-active? (reagent/atom nil))]
(fn [{:keys [on-focus on-change on-blur on-cancel search-filter auto-focus]}]
[quo/text-input {:placeholder (i18n/label :t/search)
:blur-on-submit true
:multiline false
:get-ref #(reset! input-ref %)
:default-value search-filter
:auto-focus auto-focus
:on-cancel on-cancel
:show-cancel true
:auto-correct false
:auto-capitalize :none
:input-style {:height 36
:padding-top 2
:padding-bottom 2}
:before {:icon :main-icons/search
:style {:padding-horizontal 8}
:on-press #(some-> ^js @input-ref (.focus))
:icon-opts {:color (:icon-02 @colors/theme)}}
:on-focus #(do
(when on-focus
(on-focus search-filter))
(reset! search-active? true))
:on-blur #(do
(when on-blur
(on-blur))
(reset! search-active? false))
:on-change (fn [e]
(let [^js native-event (.-nativeEvent ^js e)
text (.-text native-event)]
(when on-change
(on-change text))))}])))
[quo/text-input {:placeholder (i18n/label :t/search)
:accessibility-label :search-input
:blur-on-submit true
:multiline false
:get-ref #(reset! input-ref %)
:default-value search-filter
:auto-focus auto-focus
:on-cancel on-cancel
:show-cancel true
:auto-correct false
:auto-capitalize :none
:input-style {:height 36
:padding-top 2
:padding-bottom 2}
:before {:icon :main-icons/search
:style {:padding-horizontal 8}
:on-press #(some-> ^js @input-ref (.focus))
:icon-opts {:color (:icon-02 @colors/theme)}}
:on-focus #(do
(when on-focus
(on-focus search-filter))
(reset! search-active? true))
:on-blur #(do
(when on-blur
(on-blur))
(reset! search-active? false))
:on-change (fn [e]
(let [^js native-event (.-nativeEvent ^js e)
text (.-text native-event)]
(when on-change
(on-change text))))}])))

View File

@ -245,7 +245,8 @@
(when (and (seq suggestions) @chat-input-height)
(let [height (+ 16 (* 52 (min 4.5 (count suggestions))))]
[rn/view
{:style (styles/autocomplete-container @chat-input-height)}
{:style (styles/autocomplete-container @chat-input-height)
:accessibility-label :suggestions-list}
[rn/view
{:style {:height height}}
[list/flat-list

View File

@ -29,7 +29,9 @@ class NetworkApi(object):
def get_transactions(self, address: str) -> List[dict]:
method = self.network_url + 'module=account&action=txlist&address=0x%s&sort=desc&apikey=%s' % (address, self.api_key)
try:
return requests.request('GET', url=method, headers=self.headers).json()['result']
transactions_response = requests.request('GET', url=method, headers=self.headers).json()
if transactions_response:
return transactions_response['result']
except TypeError as e:
self.log("Check response from etherscan API. Returned values do not match expected. %s" % e)
except JSONDecodeError as e:
@ -39,7 +41,9 @@ class NetworkApi(object):
def get_token_transactions(self, address: str) -> List[dict]:
method = self.network_url + 'module=account&action=tokentx&address=0x%s&sort=desc&apikey=%s' % (address, self.api_key)
try:
return requests.request('GET', url=method, headers=self.headers).json()['result']
transactions_response = requests.request('GET', url=method, headers=self.headers).json()
if transactions_response:
return transactions_response['result']
except TypeError as e:
self.log("Check response from etherscan API. Returned values do not match expected. %s" % str(e))
except JSONDecodeError as e:
@ -55,9 +59,11 @@ class NetworkApi(object):
for i in range(5):
try:
self.log('Trying to get balance for %s, attempt %s' % (address, i + 1))
balance = requests.request('GET', method, headers=self.headers).json()["result"]
self.log('Balance is %s Gwei' % balance)
return int(balance)
balance_json = requests.request('GET', method, headers=self.headers).json()
if balance_json:
balance = balance_json["result"]
self.log('Balance is %s Gwei' % balance)
return int(balance)
except JSONDecodeError as e:
self.log(str(e))
time.sleep(5)
@ -107,7 +113,7 @@ class NetworkApi(object):
(amount, address))
return transaction
except TypeError as e:
self.log("Failed iterate transactions " + str(e))
self.log("Failed iterate transactions: " + str(e))
continue
def wait_for_confirmation_of_transaction(self, address, amount, confirmations=12, token=False):
@ -123,13 +129,13 @@ class NetworkApi(object):
counter = 0
while True:
if counter >= wait_time:
pytest.fail('Balance is not changed during %s seconds, funds were not received!' % wait_time)
pytest.fail('Balance is not changed during %s seconds' % wait_time)
elif initial_balance == self.get_balance(recipient_address):
counter += 10
time.sleep(10)
self.log('Waiting %s seconds for funds' % counter)
self.log('Waiting %s seconds for for changing account balance from %s' % (counter, initial_balance))
else:
self.log('Transaction is received')
self.log('Balance is updated!')
return
def verify_balance_is(self, expected_balance: int, recipient_address: str, errors: list):

View File

@ -60,7 +60,7 @@ class TestCreateAccount(SingleDeviceTestCase):
self.errors.append("'%s' text is not shown" % text)
for chat in ('#status', '#crypto'):
sign_in.element_by_text(chat).click()
sign_in.back_button.click_until_presence_of_element(home_view.search_chat_input)
sign_in.back_button.click_until_presence_of_element(home_view.search_input)
profile_view = home_view.profile_button.click()
shown_username = profile_view.default_username_text.text
if shown_username != username:

View File

@ -1075,7 +1075,7 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase):
@marks.testrail_id(6226)
@marks.critical
def test_ens_and_nickname_in_public_and_1_1_chats(self):
def test_ens_mentions_and_nickname_in_public_and_1_1_chats(self):
self.create_drivers(2)
device_1, device_2 = self.drivers[0], self.drivers[1]
sign_in_1, sign_in_2 = SignInView(device_1), SignInView(device_2)
@ -1123,9 +1123,23 @@ class TestProfileMultipleDevice(MultipleDeviceTestCase):
if not chat_2.wait_for_element_starts_with_text(ens_name):
self.errors.append('ENS username is not shown in public chat')
home_2.just_fyi('check that can mention user with ENS name')
# chat_2.chat_message_input.send_keys('@' + user_1['username'][0:4])
# chat_2.search_user_in_mention_suggestion_list(user_1['ens']).click()
chat_2.select_mention_from_suggestion_list(user_1['ens'])
if chat_2.chat_message_input.text != ens_name + ' ':
self.errors.append('ENS username is not resolved in chat input after selecting it in mention suggestions list!')
chat_2.send_message_button.click()
chat_2.element_starts_with_text(ens_name,'button').click()
for element in (chat_2.element_by_text(user_1['username']), chat_2.add_to_contacts):
if not element.is_element_displayed():
self.errors.append('Was not redirected to user profile after tappin on mention!')
chat_1.element_starts_with_text(user_1['ens'] +'.stateofus.eth','button').click()
if not profile_1.privacy_and_security_button.is_element_displayed():
self.errors.append('Was not redirected to own profile after tapping on mention of myself from another user!')
home_2.just_fyi('check that ENS name is shown in 1-1 chat without adding user as contact in header, profile, options')
chat_2.get_back_to_home_view()
chat_2_one_to_one = home_2.add_contact(ens_user['public_key'], False)
chat_2_one_to_one = chat_2.profile_send_message.click()
if chat_2_one_to_one.user_name_text.text != ens_name:
self.errors.append('ENS username is not shown in 1-1 chat header')
chat_2_one_to_one.chat_options.click()

View File

@ -117,7 +117,7 @@ class TestWalletManagement(SingleDeviceTestCase):
if wallet.backup_recovery_phrase_warning_text.is_element_present():
self.driver.fail("'Back up your seed phrase' warning is shown on Wallet while no funds are present")
address = wallet.get_wallet_address()
self.network_api.get_donate(address[2:])
self.network_api.get_donate(address[2:], external_faucet=False)
wallet.back_button.click()
wallet.wait_balance_is_changed()
if not wallet.backup_recovery_phrase_warning_text.is_element_present(30):

View File

@ -400,8 +400,8 @@ class TestChatManagement(SingleDeviceTestCase):
home.just_fyi('Can search for public chat while offline')
home.toggle_airplane_mode()
home.search_chat_input.click()
home.search_chat_input.send_keys(chat_name)
home.search_input.click()
home.search_input.send_keys(chat_name)
search_results = home.chat_name_text.find_elements()
if not search_results:
self.errors.append('No search results after searching by %s keyword' % chat_name)
@ -532,27 +532,35 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase):
@marks.testrail_id(5332)
@marks.critical
def test_add_and_remove_contact_with_nickname_from_public_chat(self):
def test_add_and_remove_mention_contact_with_nickname_from_public_chat(self):
self.create_drivers(2)
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
home_1, home_2 = device_1.create_user(), device_2.create_user()
public_key_2, username_2 = home_2.get_public_key_and_username(return_username=True)
home_2.get_back_to_home_view()
chat_name = 'testaddcontact'
device_1.just_fyi('join same public chat')
chat_1, chat_2 = home_1.join_public_chat(chat_name), home_2.join_public_chat(chat_name)
message = 'test message' + str(round(time.time()))
chat_2.send_message(message)
chat_2.chat_message_input.send_keys(message)
chat_2.send_message_button.click()
home_2.just_fyi('check that can mention user with 3-random name in public chat')
chat_1.select_mention_from_suggestion_list(username_2, typed_search_pattern=username_2[0:4])
if chat_1.chat_message_input.text != '@' + username_2 + ' ':
self.errors.append('3-random username is not resolved in chat input after selecting it in mention suggestions list!')
chat_1.send_message_button.click()
chat_1.chat_element_by_text(username_2).click()
chat_1.profile_add_to_contacts.wait_for_visibility_of_element(20)
chat_1.back_button.click()
chat_2.driver.quit()
device_1.just_fyi('Tap on userpic and check redirect to user profile')
chat_element = chat_1.chat_element_by_text(message)
chat_element.find_element()
username = chat_element.username.text
chat_element.member_photo.click()
for element in [chat_1.contact_profile_picture,
chat_1.element_by_text(username, 'text'),
chat_1.element_by_text(username_2, 'text'),
chat_1.add_to_contacts,
chat_1.profile_send_message,
chat_1.profile_address_text,
@ -566,16 +574,33 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase):
nickname = 'Name1'
chat_1.set_nickname(nickname)
chat_1.back_button.click()
expected_username = '%s %s' % (nickname, username)
expected_username = '%s %s' % (nickname, username_2)
if chat_element.username.text != expected_username:
self.errors.append('Username %s in public chat does not match expected %s' % (chat_element.username.text, expected_username))
device_1.just_fyi('Add user to contacts, check contact list in Profile')
device_1.just_fyi('Add user to contacts, mention it by nickname check contact list in Profile')
chat_element.member_photo.click()
chat_1.add_to_contacts.click()
if not chat_1.remove_from_contacts.is_element_displayed():
self.errors.append("'Add to contacts' is not changed to 'Remove from contacts'")
chat_1.back_button.click()
home_2.just_fyi('check that can mention user with nickname in public chat')
chat_1.select_mention_from_suggestion_list(username_in_list=nickname + ' ' +username_2,
typed_search_pattern=nickname[0:2])
if chat_1.chat_message_input.text != '@' + username_2 + ' ':
self.errors.append('3-random username is not resolved in chat input after selecting it in mention '
'suggestions list by nickname!')
additional_text = 'and more'
chat_1.send_as_keyevent(additional_text)
chat_1.send_message_button.click()
chat_1.chat_element_by_text('%s %s' % (nickname, additional_text)).click()
for element in (chat_1.element_by_text(username_2), chat_1.remove_from_contacts):
if not element.is_element_displayed():
self.errors.append('Was not redirected to user profile after tapping on mention by nickname!')
chat_1.get_back_to_home_view()
device_1.just_fyi('check contact list in Profile after setting nickname')
profile_1 = chat_1.profile_button.click()
userprofile = profile_1.open_contact_from_profile(nickname)
if not userprofile.remove_from_contacts.is_element_displayed():
@ -585,10 +610,10 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase):
device_1.just_fyi('Check that user is added to contacts below "Start new chat" and you redirected to 1-1 on tap')
home_1.plus_button.click()
home_1.start_new_chat_button.click()
for name in (nickname, username):
for name in (nickname, username_2):
if not home_1.element_by_text(name).is_element_displayed():
home_1.driver.fail('List of contacts below "Start new chat" does not contain added user')
home_1.element_by_text(username).click()
home_1.element_by_text(username_2).click()
if not chat_1.chat_message_input.is_element_displayed():
home_1.driver.fail('No redirect to 1-1 chat if tap on Contact below "Start new chat"')
for element in (chat_1.chat_message_input, chat_1.element_by_text(nickname)):
@ -599,7 +624,7 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase):
device_1.just_fyi('Remove user from contacts')
chat_1.profile_button.click()
userprofile = profile_1.open_contact_from_profile(username)
userprofile = profile_1.open_contact_from_profile(username_2)
userprofile.remove_from_contacts.click()
if userprofile.remove_from_contacts.is_element_displayed():
self.errors.append("'Remove from contacts' is not changed to 'Add to contacts'")
@ -608,7 +633,7 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase):
device_1.just_fyi('Check that user is removed from contact list in profile')
userprofile.back_button.click()
if profile_1.element_by_text(username).is_element_displayed():
if profile_1.element_by_text(username_2).is_element_displayed():
self.errors.append('List of contacts in profile contains removed user')
profile_1.home_button.click()
if not chat_1.add_to_contacts.is_element_displayed():

View File

@ -1,6 +1,6 @@
from tests import marks
from tests.base_test_case import MultipleDeviceTestCase, SingleDeviceTestCase
from tests.users import transaction_recipients, basic_user
from tests.users import transaction_senders, basic_user
from views.sign_in_view import SignInView
from views.chat_view import ChatView
from time import sleep
@ -527,28 +527,32 @@ class TestCommandsSingleDevices(SingleDeviceTestCase):
@marks.testrail_id(5721)
@marks.medium
def test_cant_add_more_ten_participants_to_group_chat(self):
def test_cant_add_more_twenty_participants_to_group_chat(self):
sign_in = SignInView(self.driver)
home = sign_in.create_user()
users = [transaction_senders['A'], transaction_senders['B'], transaction_senders['C'], transaction_senders['D'],
transaction_senders['E'], transaction_senders['F'], transaction_senders['G'], transaction_senders['H'],
transaction_senders['I'], transaction_senders['K'], transaction_senders['L'], transaction_senders['M'],
transaction_senders['N'], transaction_senders['O'], transaction_senders['P'], transaction_senders['Q'],
transaction_senders['R'], transaction_senders['S'], transaction_senders['T'], transaction_senders['U'],
]
usernames = []
home.just_fyi('Add 10 users to contacts')
for user in transaction_recipients:
home.add_contact(transaction_recipients[user]['public_key'])
usernames.append(transaction_recipients[user]['username'])
home.just_fyi('Add 20 users to contacts')
for user in users:
home.add_contact(user['public_key'])
usernames.append(user['username'])
home.get_back_to_home_view()
home.just_fyi('Create group chat with max amount of users')
chat = home.create_group_chat(usernames, 'some_group_chat')
if chat.element_by_text(transaction_recipients['J']['username']).is_element_displayed():
self.errors.append('11 users are in chat (10 users and admin)!')
home.just_fyi('Verify that can not add more users via group info')
chat.chat_options.click()
group_info_view = chat.group_info.click()
if group_info_view.add_members.is_element_displayed():
self.errors.append('Add members button is displayed when max users are added in chat')
if not group_info_view.element_by_text_part('10 members').is_element_displayed():
if not group_info_view.element_by_text_part('20 members').is_element_displayed():
self.errors.append('Amount of users is not shown on Group info screen')
self.errors.verify_no_errors()

View File

@ -373,7 +373,7 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase):
device_2.home_button.click()
home_2.get_chat(default_username_1).click()
chat_2.play_audio_message(listen_time)
if chat_2.audio_message_in_chat_timer.text not in ("00:05", "00:06", "00:07"):
if chat_2.audio_message_in_chat_timer.text not in ("00:05", "00:06", "00:07", "00:08"):
self.errors.append("Listened 5 seconds but timer shows different listened time in audio message")
self.errors.verify_no_errors()

View File

@ -112,7 +112,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
wallet_view.set_up_wallet()
status_account_address = wallet_view.get_wallet_address()[2:]
wallet_view.back_button.click()
self.network_api.get_donate(status_account_address)
self.network_api.get_donate(status_account_address, external_faucet=False)
wallet_view.wait_balance_is_changed()
account_name = 'subaccount'
wallet_view.add_account(account_name, keycard=True)

View File

@ -240,7 +240,7 @@ class TestTransactionWalletSingleDevice(SingleDeviceTestCase):
wallet_view.set_up_wallet()
status_account_address = wallet_view.get_wallet_address()[2:]
wallet_view.back_button.click()
self.network_api.get_donate(status_account_address)
self.network_api.get_donate(status_account_address, external_faucet=False)
wallet_view.wait_balance_is_changed()
account_name = 'subaccount'
wallet_view.add_account(account_name)

View File

@ -353,10 +353,10 @@ class AirplaneModeButton(BaseButton):
self.driver.press_keycode(4)
class SearchChatInput(BaseEditBox):
class SearchInput(BaseEditBox):
def __init__(self, driver):
super().__init__(driver)
self.locator = self.Locator.text_selector('Search')
self.locator = self.Locator.accessibility_id('search-input')
class BaseView(object):
@ -393,7 +393,7 @@ class BaseView(object):
self.cross_icon_iside_welcome_screen_button = CrossIconInWelcomeScreen(self.driver)
self.status_in_background_button = StatusInBackgroundButton(self.driver)
self.cancel_button = CancelButton(self.driver)
self.search_chat_input = SearchChatInput(self.driver)
self.search_input = SearchInput(self.driver)
self.share_button = ShareButton(self.driver)
# external browser
@ -731,8 +731,8 @@ class BaseView(object):
def search_by_keyword(self, keyword):
self.driver.info('Search for %s' % keyword)
self.search_chat_input.click()
self.search_chat_input.send_keys(keyword)
self.search_input.click()
self.search_input.send_keys(keyword)
# Method-helper
def write_page_source_to_file(self, full_path_to_file):

View File

@ -354,11 +354,8 @@ class ProfileSendMessageButton(BaseButton):
super(ProfileSendMessageButton, self).__init__(driver)
self.locator = self.Locator.accessibility_id('start-conversation-button')
class ProfileSendTransactionButton(BaseButton):
def __init__(self, driver):
super(ProfileSendTransactionButton, self).__init__(driver)
self.locator = self.Locator.accessibility_id('send-transaction-button')
def navigate(self):
return ChatView(self.driver)
class ProfileBlockContactButton(BaseButton):
@ -401,7 +398,7 @@ class MakeAdminButton(BaseButton):
self.locator = self.Locator.accessibility_id('make-admin')
class ChatElementByText(BaseText):
class ChatElementByText(BaseElement):
def __init__(self, driver, text):
super(ChatElementByText, self).__init__(driver)
self.message_text = text
@ -600,7 +597,6 @@ class StikerMessageItem(BaseElement):
self.locator = self.Locator.accessibility_id('sticker-message')
class ImageChatItem(BaseElement):
def __init__(self, driver):
super().__init__(driver)
@ -656,6 +652,7 @@ class DoneButton(BaseButton):
super(DoneButton, self).__init__(driver)
self.locator = self.Locator.accessibility_id("done")
class GroupChatInfoView(BaseView):
def __init__(self, driver):
super(GroupChatInfoView, self).__init__(driver)
@ -700,6 +697,7 @@ class PlayPauseAudioMessageButton(BaseButton):
super(PlayPauseAudioMessageButton, self).__init__(driver)
self.locator = self.Locator.accessibility_id("play-pause-audio-message-button")
class AudioMessageInChatTimer(BaseText):
def __init__(self, driver):
super(AudioMessageInChatTimer, self).__init__(driver)
@ -801,7 +799,6 @@ class ChatView(BaseView):
# Contact's profile
self.contact_profile_picture = ProfilePictureElement(self.driver)
self.profile_send_message = ProfileSendMessageButton(self.driver)
self.profile_send_transaction = ProfileSendTransactionButton(self.driver)
self.profile_address_text = ProfileAddressText(self.driver)
self.profile_block_contact = ProfileBlockContactButton(self.driver)
self.profile_add_to_contacts = ProfileAddToContactsButton(self.driver)
@ -940,6 +937,18 @@ class ChatView(BaseView):
element.click()
element.wait_for_invisibility_of_element()
def search_user_in_mention_suggestion_list(self, username):
element = BaseButton(self.driver)
element.locator = element.Locator.xpath_selector(
"//*[@content-desc='suggestions-list']//*[@text='%s']" % username)
element.wait_for_visibility_of_element(10)
return element
def select_mention_from_suggestion_list(self, username_in_list, typed_search_pattern = ''):
self.chat_message_input.set_value('@' + typed_search_pattern)
self.chat_message_input.click()
self.search_user_in_mention_suggestion_list(username_in_list).click()
def record_audio_message(self, message_length_in_seconds=5):
self.audio_message_button.click()
self.allow_button.click()

View File

@ -44,9 +44,9 @@ class UsernameCheckbox(BaseButton):
def click(self):
self.driver.info('Click %s username checkbox' % self.username)
try:
self.scroll_to_element().click()
self.scroll_to_element(20).click()
except NoSuchElementException:
self.scroll_to_element(direction='up').click()
self.scroll_to_element(direction='up', depth=20).click()
class ChatNameEditBox(BaseEditBox):

View File

@ -226,7 +226,14 @@ class HomeView(BaseView):
self.plus_button.click()
contacts_view = self.new_group_chat_button.click()
for user_name in user_names_to_add:
contacts_view.get_username_checkbox(user_name).click()
if len(user_names_to_add) > 5:
from views.chat_view import ChatView
contact_view_with_search = ChatView(self.driver)
contact_view_with_search.search_by_keyword(user_name[:4])
contacts_view.get_username_checkbox(user_name).click()
contact_view_with_search.search_input.clear()
else:
contacts_view.get_username_checkbox(user_name).click()
contacts_view.next_button.click()
contacts_view.chat_name_editbox.send_keys(group_chat_name)
contacts_view.create_button.click()

View File

@ -416,7 +416,7 @@ class SendTransactionView(BaseView):
data = {
'amount': self.amount_edit_box.text,
'asset': self.asset_text.text,
'address': self.recipient_text.text
'address': self.enter_recipient_address_text.text
}
if gas:
self.sign_transaction_button.click_until_presence_of_element(self.sign_with_password)