e2e: updated GH report and fixed 2 tests

This commit is contained in:
Yevheniia Berdnyk 2023-10-18 06:16:05 +03:00
parent b4b8eb08a6
commit 7da899e29f
No known key found for this signature in database
GPG Key ID: 0642C73C66214825
7 changed files with 63 additions and 44 deletions

View File

@ -78,21 +78,18 @@ class BaseTestReport:
grop_name=test_data['group_name']))
return tests
def get_failed_tests(self):
def get_tests_by_status(self):
tests = self.get_all_tests()
failed = list()
for test in tests:
if not self.is_test_successful(test):
failed.append(test)
return failed
def get_passed_tests(self):
tests = self.get_all_tests()
passed = list()
passed, failed, xfailed = list(), list(), list()
for test in tests:
if self.is_test_successful(test):
passed.append(test)
return passed
else:
if test.testruns[-1].xfail:
xfailed.append(test)
else:
failed.append(test)
return passed, failed, xfailed
def get_sauce_token(self, job_id):
return hmac.new(bytes(self.sauce_username + ":" + self.sauce_access_key, 'latin-1'),

View File

@ -1,7 +1,7 @@
import os
from support.base_test_report import BaseTestReport
from support.testrail_report import TestrailReport
import re
class GithubHtmlReport(BaseTestReport):
@ -19,21 +19,22 @@ class GithubHtmlReport(BaseTestReport):
def build_html_report(self, run_id):
tests = self.get_all_tests()
passed_tests = self.get_passed_tests()
failed_tests = self.get_failed_tests()
passed, failed, xfailed = self.get_tests_by_status()
not_executed_tests = TestrailReport().get_not_executed_tests(run_id)
if len(tests) > 0:
title_html = "## %.0f%% of end-end tests have passed\n" % (len(passed_tests) / len(tests) * 100)
title_html = "## %.0f%% of end-end tests have passed\n" % (len(passed) / len(tests) * 100)
summary_html = "```\n"
summary_html += "Total executed tests: %d\n" % len(tests)
summary_html += "Failed tests: %d\n" % len(failed_tests)
summary_html += "Passed tests: %d\n" % len(passed_tests)
summary_html += "Failed tests: %d\n" % len(failed)
summary_html += "Expected to fail tests: %d\n" % len(xfailed)
summary_html += "Passed tests: %d\n" % len(passed)
if not_executed_tests:
summary_html += "Not executed tests: %d\n" % len(not_executed_tests)
summary_html += "```\n"
not_executed_tests_html = str()
failed_tests_html = str()
xfailed_tests_html = str()
passed_tests_html = str()
if not_executed_tests:
not_executed_tests_html = self.build_tests_table_html(not_executed_tests, run_id,
@ -41,22 +42,30 @@ class GithubHtmlReport(BaseTestReport):
summary_html += "```\n"
summary_html += 'IDs of not executed tests: %s \n' % ','.join([str(i) for i in not_executed_tests])
summary_html += "```\n"
if failed_tests:
failed_tests_html = self.build_tests_table_html(failed_tests, run_id, failed_tests=True)
if failed:
failed_tests_html = self.build_tests_table_html(failed, run_id, failed_tests=True)
summary_html += "```\n"
summary_html += 'IDs of failed tests: %s \n' % self.list_of_failed_testrail_ids(failed_tests)
summary_html += 'IDs of failed tests: %s \n' % self.list_of_failed_testrail_ids(failed)
summary_html += "```\n"
if passed_tests:
passed_tests_html = self.build_tests_table_html(passed_tests, run_id, failed_tests=False)
return title_html + summary_html + not_executed_tests_html + failed_tests_html + passed_tests_html
if xfailed:
xfailed_tests_html = self.build_tests_table_html(xfailed, run_id, xfailed_tests=True)
summary_html += "```\n"
summary_html += 'IDs of expected to fail tests: %s \n' % self.list_of_failed_testrail_ids(xfailed)
summary_html += "```\n"
if passed:
passed_tests_html = self.build_tests_table_html(passed, run_id, failed_tests=False)
return title_html + summary_html + not_executed_tests_html + failed_tests_html + xfailed_tests_html \
+ passed_tests_html
else:
return None
def build_tests_table_html(self, tests, run_id, failed_tests=False, not_executed_tests=False):
def build_tests_table_html(self, tests, run_id, failed_tests=False, xfailed_tests=False, not_executed_tests=False):
if failed_tests:
tests_type = "Failed tests"
elif not_executed_tests:
tests_type = "Not executed tests"
elif xfailed_tests:
tests_type = "Expected to fail tests"
else:
tests_type = "Passed tests"
html = "<h3>%s (%d)</h3>" % (tests_type, len(tests))
@ -66,7 +75,6 @@ class GithubHtmlReport(BaseTestReport):
from tests import pytest_config_global
pr_id = pytest_config_global['pr_number']
apk_name = pytest_config_global['apk']
if not_executed_tests:
html += "<li><a href=\"%s\">Rerun not executed tests</a></li>" % self.get_jenkins_link_to_rerun_e2e(

View File

@ -123,7 +123,7 @@ class TestrailReport(BaseTestReport):
test_cases['pr']['critical'] = 50955
test_cases['pr']['one_to_one_chat'] = 50956
# test_cases['pr']['deep_links'] = 50967
# test_cases['pr']['deep_links'] = 50967
test_cases['pr']['group_chat'] = 50964
test_cases['pr']['community_single'] = 50983
test_cases['pr']['community_multiple'] = 50982
@ -242,26 +242,26 @@ class TestrailReport(BaseTestReport):
def change_test_run_description(self):
tests = self.get_all_tests()
passed_tests = self.get_passed_tests()
failed_tests = self.get_failed_tests()
passed, failed, xfailed = self.get_tests_by_status()
not_executed_tests = self.get_not_executed_tests(self.run_id)
final_description = "Nothing to report this time..."
if len(tests) > 0:
description_title = "# %.0f%% of end-end tests have passed\n" % (len(passed_tests) / len(tests) * 100)
description_title = "# %.0f%% of end-end tests have passed\n" % (len(passed) / len(tests) * 100)
description_title += "\n"
description_title += "Total executed tests: %d\n" % len(tests)
description_title += "Failed tests: %d\n" % len(failed_tests)
description_title += "Passed tests: %d\n" % len(passed_tests)
description_title += "Failed tests: %d\n" % len(failed)
description_title += "Expected to fail tests: %d\n" % len(xfailed)
description_title += "Passed tests: %d\n" % len(passed)
if not_executed_tests:
description_title += "Not executed tests: %d\n" % len(not_executed_tests)
description_title += "\n"
ids_failed_test = []
single_devices_block, group_blocks, case_info = str(), dict(), str()
if failed_tests:
for test in failed_tests:
if failed:
for test in failed:
if test.group_name:
group_blocks[test.group_name] = "\n-------\n## Class: %s:\n" % test.group_name
for test in failed_tests:
for test in failed:
last_testrun = test.testruns[-1]
test_rail_link = self.get_test_result_link(self.run_id, test.testrail_case_id)
ids_failed_test.append(test.testrail_case_id)

View File

@ -303,6 +303,7 @@ def pytest_runtest_makereport(item, call):
test_suite_data.current_test.create_new_testrun()
if is_group:
test_suite_data.current_test.group_name = item.instance.__class__.__name__
test_suite_data.current_test.testruns[-1].xfail = report.wasxfail
error_intro, error = 'Test is not run, e2e blocker ', report.wasxfail
final_error = "%s [[%s]]" % (error_intro, error)
else:

View File

@ -460,7 +460,7 @@ class TestGroupChatMultipleDeviceMergedNewUI(MultipleSharedDeviceTestCase):
after_mute_counter = int(self.homes[1].chats_tab.counter.text)
except NoSuchElementException:
after_mute_counter = 0
if after_mute_counter <= initial_counter:
if after_mute_counter != initial_counter:
self.errors.append("New messages counter near chats tab button is %s after unmute, but should be %s" % (
after_mute_counter, initial_counter + 1))
if not chat.chat_preview.text.startswith("%s: %s" % (self.usernames[2], unmuted_message)):

View File

@ -810,9 +810,9 @@ class TestCommunityMultipleDeviceMergedTwo(MultipleSharedDeviceTestCase):
self.device_1.just_fyi("Admin gets push notification with the mention and tap it")
message_received = False
if self.home_1.get_pn(self.username_1):
message_received = True
self.device_1.click_upon_push_notification_by_text(self.username_1)
if not self.channel_1.chat_element_by_text(self.username_1).is_element_displayed():
message_received = True
if self.channel_1.chat_message_input.is_element_displayed():
self.errors.append("Message with the mention is not shown in the chat for the admin")
else:
@ -821,7 +821,10 @@ class TestCommunityMultipleDeviceMergedTwo(MultipleSharedDeviceTestCase):
else:
self.errors.append("Push notification with the mention was not received by admin")
self.channel_1.click_system_back_button()
if not self.channel_1.chat_message_input.is_element_displayed():
self.channel_1.navigate_back_to_home_view()
self.home_1.communities_tab.click()
self.home_1.get_to_community_channel_from_home(self.community_name)
if message_received:
self.channel_1.just_fyi("Set reaction for the message with a mention")
@ -833,20 +836,25 @@ class TestCommunityMultipleDeviceMergedTwo(MultipleSharedDeviceTestCase):
self.errors.append("Message reaction is not shown for the sender")
self.device_2.just_fyi("Sender edits the message with a mention")
self.channel_2.chat_element_by_text(self.username_1).wait_for_sent_state()
self.channel_2.chat_element_by_text(self.username_1).long_press_element_by_coordinate(rel_y=0)
chat_element = self.channel_2.chat_element_by_text(self.username_1)
chat_element.wait_for_sent_state()
chat_element.long_press_element_by_coordinate()
edit_done = False
edited_message = "0 abc (Edited)"
try:
self.channel_2.element_by_translation_id("edit-message").click()
for i in range(29, 32):
for i in 31, 30, 29:
self.channel_2.driver.press_keycode(i)
self.channel_2.send_message_button.click()
edited_message = self.username_1 + " abc"
if not self.channel_2.chat_element_by_text(edited_message).is_element_displayed():
edit_done = True
if chat_element.message_body_with_mention.text != edited_message:
self.errors.append("Edited message is not shown correctly for the sender")
if not self.channel_1.chat_element_by_text(edited_message).is_element_displayed():
self.errors.append("Edited message is not shown correctly for the (receiver) admin")
except NoSuchElementException:
self.errors.append("Can not edit a message with a mention")
if edit_done:
element = self.channel_1.chat_element_by_text(self.username_1).message_body_with_mention
if not element.is_element_displayed(10) or element.text != edited_message:
self.errors.append("Edited message is not shown correctly for the (receiver) admin")
self.home_2.navigate_back_to_home_view()
if not self.channel_1.chat_message_input.is_element_displayed():

View File

@ -184,6 +184,11 @@ class ChatElementByText(Text):
xpath="//%s//android.widget.TextView[contains(@text,'%s')]" % (self.chat_item_locator, self.message_text)
)
@property
def message_body_with_mention(self):
return Text(self.driver,
xpath=self.message_body.locator + "/../following-sibling::android.widget.TextView")
def click_on_link_inside_message_body(self):
self.message_body.wait_for_visibility_of_element(30)
self.message_body.click_inside_element_by_coordinate(rel_x=0.1, rel_y=0.9)