e2e: previews in lomks

Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
This commit is contained in:
Churikova Tetiana 2021-02-23 15:38:17 +01:00
parent 325a860916
commit 61da0db9c9
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
4 changed files with 82 additions and 15 deletions

View File

@ -142,6 +142,7 @@ class TestCreateAccount(SingleDeviceTestCase):
@marks.testrail_id(6246)
@marks.medium
@marks.flaky
def test_keycard_interruption_access_key_onboarding_flow(self):
sign_in = SignInView(self.driver)
sign_in.get_started_button.click()
@ -247,7 +248,6 @@ class TestCreateAccount(SingleDeviceTestCase):
@marks.medium
def test_keycard_can_recover_keycard_account_offline_and_add_watch_only_acc(self):
sign_in = SignInView(self.driver)
recovered_user = transaction_senders['A']
sign_in.toggle_airplane_mode()
sign_in.just_fyi('Recover multiaccount offline')
@ -291,7 +291,7 @@ class TestCreateAccount(SingleDeviceTestCase):
wallet_view.just_fyi('Check that balance is changed after go back to WI-FI')
sign_in.toggle_mobile_data()
for asset in ('LXS', 'ADI', 'STT'):
for asset in ('ADI', 'STT'):
wallet_view.asset_by_name(asset).scroll_to_element()
wallet_view.wait_balance_is_changed(asset, wait_time=60)

View File

@ -367,7 +367,7 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase):
@marks.testrail_id(5373)
@marks.high
def test_send_and_open_links(self):
def test_send_and_open_links_with_previews(self):
self.create_drivers(2)
device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
@ -378,10 +378,10 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase):
public_key_2 = home_2.get_public_key_and_username()
home_2.home_button.click()
home_1.just_fyi("Check that link can be opened from 1-1 chat")
chat_1 = home_1.add_contact(public_key_2)
url_message = 'http://status.im'
chat_1.chat_message_input.send_keys(url_message)
chat_1.send_message_button.click()
chat_1.send_message(url_message)
chat_1.get_back_to_home_view()
chat_2 = home_2.get_chat(default_username_1).click()
chat_2.element_starts_with_text(url_message, 'button').click()
@ -393,17 +393,50 @@ class TestMessagesOneToOneChatMultiple(MultipleDeviceTestCase):
web_view.back_to_home_button.click()
chat_2.home_button.click()
home_1.just_fyi("Check that link can be opened from public chat")
chat_name = ''.join(random.choice(string.ascii_lowercase) for _ in range(7))
home_1.join_public_chat(chat_name)
home_2.join_public_chat(chat_name)
chat_2.chat_message_input.send_keys(url_message)
chat_2.send_message_button.click()
chat_1 = home_1.join_public_chat(chat_name)
chat_2 = home_2.join_public_chat(chat_name)
chat_2.send_message(url_message)
chat_1.element_starts_with_text(url_message, 'button').click()
web_view = chat_1.open_in_status_button.click()
try:
web_view.element_by_text('Private, Secure Communication').find_element()
except TimeoutException:
self.errors.append('Device 1: URL was not opened from 1-1 chat')
home_1.home_button.click(desired_view='chat')
preview_urls = {'github_pr':{'url':'https://github.com/status-im/status-react/pull/11707',
'txt':'Update translations by jinhojang6 · Pull Request #11707 · status-im/status-react',
'subtitle' : 'GitHub'},
'yotube':{'url':'https://www.youtube.com/watch?v=XN-SVmuJH2g&list=PLbrz7IuP1hrgNtYe9g6YHwHO6F3OqNMao',
'txt':'Status & Keycard Hardware-Enforced Security',
'subtitle': 'YouTube'}}
home_1.just_fyi("Check enabling and sending first gif")
giphy_url = 'https://giphy.com/gifs/this-is-fine-QMHoU66sBXqqLqYvGO'
chat_2.send_message(giphy_url)
chat_2.element_by_translation_id("dont-ask").click()
chat_1.element_by_translation_id("enable").wait_and_click()
chat_1.element_by_translation_id("enable-all").wait_and_click()
chat_1.back_button.click()
if not chat_1.get_preview_message_by_text(giphy_url).preview_image:
self.errors.append("No preview is shown for %s" % giphy_url)
for key in preview_urls:
home_2.just_fyi("Checking %s preview case" % key)
data = preview_urls[key]
chat_2.send_message(data['url'])
message = chat_1.get_preview_message_by_text(data['url'])
if message.preview_title.text != data['txt']:
self.errors.append("Title '%s' does not match expected" % message.preview_title.text)
if message.preview_subtitle.text != data['subtitle']:
self.errors.append("Subtitle '%s' does not match expected" % message.preview_subtitle.text)
home_2.just_fyi("Check if after do not ask again previews are not shown and no enable button appear")
if chat_2.element_by_translation_id("enable").is_element_displayed():
self.errors.append("Enable button is still shown after clicking on 'Den't ask again'")
if chat_2.get_preview_message_by_text(giphy_url).preview_image:
self.errors.append("Preview is shown for sender without permission")
self.errors.verify_no_errors()
@marks.testrail_id(5362)

View File

@ -68,7 +68,7 @@ class AbstractTestCase:
desired_caps['deviceName'] = 'Android GoogleAPI Emulator'
desired_caps['deviceOrientation'] = "portrait"
desired_caps['commandTimeout'] = 600
desired_caps['idleTimeout'] = 1000
desired_caps['idleTimeout'] = 600
desired_caps['unicodeKeyboard'] = True
desired_caps['automationName'] = 'UiAutomator2'
desired_caps['setWebContentDebuggingEnabled'] = True
@ -143,10 +143,6 @@ class Driver(webdriver.Remote):
return test_suite_data.current_test.testruns[-1].jobs[self.session_id]
def info(self, text: str):
# if "Base" not in text:
# text = 'Device %s: %s' % (self.number, text)
# logging.info(text)
# test_suite_data.current_test.testruns[-1].steps.append(text)
text = 'Device %s: %s ' % (self.number, text)
logging.info(text)
test_suite_data.current_test.testruns[-1].steps.append(text)

View File

@ -184,7 +184,7 @@ class ChatElementByText(Text):
class RepliedToUsernameText(Text):
def __init__(self, driver, parent_locator: str):
super().__init__(driver, prefix=parent_locator,
xpath="%s/preceding-sibling::*[1]/android.widget.TextView[1]")
xpath="/preceding-sibling::*[1]/android.widget.TextView[1]")
try:
return RepliedToUsernameText(self.driver, self.message_locator).text
except NoSuchElementException:
@ -250,6 +250,40 @@ class GroupChatInfoView(BaseView):
return Text(self.driver, xpath="//*[@text='%s']" % username)
class PreviewMessage(ChatElementByText):
def __init__(self, driver, text:str):
super().__init__(driver, text=text)
self.locator+="/android.view.ViewGroup/android.view.ViewGroup/"
@staticmethod
def return_element_or_empty(obj):
try:
return obj.find_element()
except NoSuchElementException:
return ''
@property
def preview_image(self):
class PreviewImage(SilentButton):
def __init__(self, driver, parent_locator: str):
super().__init__(driver, prefix=parent_locator, xpath="android.widget.ImageView")
return PreviewMessage.return_element_or_empty(PreviewImage(self.driver, self.locator))
@property
def preview_title(self):
class PreviewTitle(SilentButton):
def __init__(self, driver, parent_locator: str):
super().__init__(driver, prefix=parent_locator, xpath="android.widget.TextView[1]")
return PreviewMessage.return_element_or_empty(PreviewTitle(self.driver, self.locator))
@property
def preview_subtitle(self):
class PreviewSubTitle(SilentButton):
def __init__(self, driver, parent_locator: str):
super().__init__(driver, prefix=parent_locator, xpath="android.widget.TextView[2]")
return PreviewMessage.return_element_or_empty(PreviewSubTitle(self.driver, self.locator))
class TransactionMessage(ChatElementByText):
def __init__(self, driver, text:str):
super().__init__(driver, text=text)
@ -445,6 +479,10 @@ class ChatView(BaseView):
account = self.status_account_name
return IncomingTransaction(self.driver, account)
def get_preview_message_by_text(self, text=None):
self.driver.info('**Getting preview message for link:%s**' % text)
return PreviewMessage(self.driver, text)
def delete_chat(self):
self.driver.info("**Delete chat via options**")