From c6316d953253f769857771c06305b18af524701b Mon Sep 17 00:00:00 2001 From: Emil Ghitta Date: Mon, 18 Nov 2024 15:48:39 +0200 Subject: [PATCH] - Adding the newly AAQ topics for AAQ test coverage. - Adding the functionality of creating a new KB article via kb/new API inside the add_kb_article_flow.py - Catching potential failures yielded by load_state events not being fired in conftest.py - Reducing the default navigation timeout from 2 minutes to 30 seconds and using the internal navigate_to_link() function in conftest.py - Creating kb articles via kb/new API calls in several tests. - Removing external link validations in test_edit_my_profile.py - Skipping some flaky tests from Chromium. --- playwright_tests/core/basepage.py | 50 +++++++---- playwright_tests/core/utilities.py | 45 ++++++++-- .../article_flows/add_kb_article_flow.py | 58 ++++++++++++- .../articles/kb_edit_article_meta.py | 2 +- .../messaging_system_pages/inbox_page.py | 2 +- playwright_tests/test_data/aaq_question.json | 12 ++- .../test_product_solutions_page.py | 5 +- playwright_tests/tests/conftest.py | 6 +- .../dashboards_tests/test_kb_dashboard.py | 80 +++++++---------- .../test_recent_revisions_dashboard.py | 43 ++++------ .../tests/contribute_tests/test_groups.py | 2 +- .../articles/test_article_show_history.py | 86 +++++++++++++------ .../articles/test_article_threads.py | 2 +- .../articles/test_product_support_page.py | 4 +- .../test_explore_by_topics.py | 1 + .../user_page_tests/test_edit_my_profile.py | 20 ----- .../user_page_tests/test_my_profile_page.py | 8 +- 17 files changed, 264 insertions(+), 162 deletions(-) diff --git a/playwright_tests/core/basepage.py b/playwright_tests/core/basepage.py index 77ba94e5e38..af190f93742 100644 --- a/playwright_tests/core/basepage.py +++ b/playwright_tests/core/basepage.py @@ -14,14 +14,14 @@ def _get_element_locator(self, xpath: str, with_wait=True) -> Locator: This helper function returns the element locator from a given xpath. """ if with_wait: - self._wait_for_dom_load_to_finish() + self.wait_for_dom_to_load() return self.page.locator(xpath) def _get_elements_locators(self, xpath: str) -> list[Locator]: """ This helper function returns a list of element locators from a given xpath. """ - self._wait_for_dom_load_to_finish() + self.wait_for_dom_to_load() return self.page.locator(xpath).all() def _get_current_page_url(self) -> str: @@ -80,7 +80,7 @@ def _get_element_attribute_value(self, element: Union[str, Locator, list[Locator if isinstance(element, str): return self._get_element_locator(element).get_attribute(attribute) elif isinstance(element, list): - self._wait_for_dom_load_to_finish() + self.wait_for_dom_to_load() values = [] for element in element: values.append(element.get_attribute(attribute)) @@ -127,7 +127,7 @@ def _checkbox_interaction(self, element: [str, ElementHandle], check: bool, retr element (Union[str, ElementHandle]): The element locator to interact with. check (bool): Whether to check or uncheck the checkbox. """ - self.page.wait_for_load_state("networkidle") + self.wait_for_networkidle() for attempt in range(retries): try: locator = self._get_element_locator(element) if isinstance( @@ -155,7 +155,7 @@ def _click(self, element: Union[str, Locator, ElementHandle], expected_locator=N expected_url (str): The expected URL to wait for after the click. with_force (bool): Whether to force the click. """ - self.page.wait_for_load_state("networkidle") + self.wait_for_networkidle() for attempt in range(retries): try: element_locator = self._get_element_locator(element) if isinstance( @@ -178,14 +178,14 @@ def _click_on_an_element_by_index(self, xpath: str, index: int): """ This helper function clicks on a given element locator based on a given index. """ - self.page.wait_for_load_state("networkidle") + self.wait_for_networkidle() self._get_element_locator(xpath).nth(index).click() def _click_on_first_item(self, xpath: str): """ This helper function clicks on the first item from a given web element locator list. """ - self.page.wait_for_load_state("networkidle") + self.wait_for_networkidle() self._get_element_locator(xpath).first.click() def _fill(self, xpath: str, text: str): @@ -267,15 +267,6 @@ def _is_checkbox_checked(self, xpath: str) -> bool: """ return self._get_element_locator(xpath).is_checked() - def _wait_for_dom_load_to_finish(self): - """ - This helper function performs two waits: - 1. Waits for the dom load to finish. - 2. Waits for the load event to be fired when the whole page, including resources has loaded - """ - self.page.wait_for_load_state("domcontentloaded") - self.page.wait_for_load_state("load") - def _wait_for_selector(self, xpath: str, timeout=3500): """ This helper function waits for a given element locator to be visible based on a given @@ -295,3 +286,30 @@ def _move_mouse_to_location(self, x: int, y: int): y (int): The y-coordinate. """ self.page.mouse.move(x, y) + + def wait_for_page_to_load(self): + """ + This helper function awaits for the load event to be fired. + """ + try: + self.page.wait_for_load_state("load") + except PlaywrightTimeoutError: + print("Load event was not fired. Continuing...") + + def wait_for_dom_to_load(self): + """ + This helper function awaits for the DOMContentLoaded event to be fired. + """ + try: + self.page.wait_for_load_state("domcontentloaded") + except PlaywrightTimeoutError: + print("DOMContentLoaded event was not fired. Continuing...") + + def wait_for_networkidle(self): + """ + This helper function waits until there are no network connections for at least 500ms. + """ + try: + self.page.wait_for_load_state("networkidle") + except PlaywrightTimeoutError: + print("Network idle state was not reached. Continuing...") diff --git a/playwright_tests/core/utilities.py b/playwright_tests/core/utilities.py index 23f270faf46..3cbb2eff64a 100644 --- a/playwright_tests/core/utilities.py +++ b/playwright_tests/core/utilities.py @@ -175,7 +175,7 @@ def navigate_to_homepage(self): """ This helper function navigates directly to the SUMO hompage. """ - self.page.goto(HomepageMessages.STAGE_HOMEPAGE_URL) + self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL) def navigate_to_link(self, link: str): """ @@ -262,19 +262,28 @@ def wait_for_page_to_load(self): """ This helper function awaits for the load event to be fired. """ - self.page.wait_for_load_state("load") + try: + self.page.wait_for_load_state("load") + except PlaywrightTimeoutError: + print("Load event was not fired. Continuing...") def wait_for_dom_to_load(self): """ This helper function awaits for the DOMContentLoaded event to be fired. """ - self.page.wait_for_load_state("domcontentloaded") + try: + self.page.wait_for_load_state("domcontentloaded") + except PlaywrightTimeoutError: + print("DOMContentLoaded event was not fired. Continuing...") def wait_for_networkidle(self): """ This helper function waits until there are no network connections for at least 500ms. """ - self.page.wait_for_load_state("networkidle") + try: + self.page.wait_for_load_state("networkidle") + except PlaywrightTimeoutError: + print("Network idle state was not reached. Continuing...") def store_session_cookies(self, session_file_name: str): """ @@ -340,7 +349,10 @@ def refresh_page(self): """ This helper function performs a page reload. """ - self.page.reload(wait_until="networkidle") + try: + self.page.reload(wait_until="networkidle") + except PlaywrightTimeoutError: + print("Network idle state was not reached. Continuing...") def get_user_agent(self) -> str: """ @@ -575,6 +587,22 @@ def get_api_response(self, page: Page, api_url: str): """ return page.request.get(api_url) + def post_api_request(self, page: Page, api_url: str, data: dict): + """Post the API request + + Args: + page (Page): The page object + api_url (str): The API URL + data (dict): The data to be posted + """ + + # It seems that playwright doesn't send the correct origin header by default. + headers = { + 'origin': HomepageMessages.STAGE_HOMEPAGE_URL + } + + return page.request.post(api_url, form=data, headers=headers) + def block_request(self, route): """ This function blocks a certain request @@ -601,3 +629,10 @@ def re_call_function_on_error(self, func, *args, **kwargs): if attempt < 2: continue break + + def get_csrfmiddlewaretoken(self) -> str: + """ + This helper function fetches the csrfmiddlewaretoken from the page. + """ + return self.page.evaluate("document.querySelector('input[name=csrfmiddlewaretoken]')" + ".value") diff --git a/playwright_tests/flows/explore_articles_flows/article_flows/add_kb_article_flow.py b/playwright_tests/flows/explore_articles_flows/article_flows/add_kb_article_flow.py index 00a0b238874..acf6d32e47a 100644 --- a/playwright_tests/flows/explore_articles_flows/article_flows/add_kb_article_flow.py +++ b/playwright_tests/flows/explore_articles_flows/article_flows/add_kb_article_flow.py @@ -1,5 +1,8 @@ from playwright.sync_api import Page from typing import Any + +from slugify import slugify + from playwright_tests.core.utilities import Utilities from playwright_tests.flows.explore_articles_flows.article_flows.add_kb_media_flow import \ AddKbMediaFlow @@ -48,7 +51,7 @@ def submit_simple_kb_article(self, approve_first_revision=False, ready_for_localization=False ) -> dict[str, Any]: - self.page.goto(KBArticlePageMessages.CREATE_NEW_KB_ARTICLE_STAGE_URL) + self.utilities.navigate_to_link(KBArticlePageMessages.CREATE_NEW_KB_ARTICLE_STAGE_URL) kb_article_test_data = self.utilities.kb_article_test_data @@ -314,3 +317,56 @@ def submit_new_kb_revision(self, "revision_time": revision_time, "changes_description": self.utilities.kb_article_test_data['changes_description'] } + + def kb_article_creation_via_api(self, page: Page, approve_revision=False, + is_template=False) -> dict[str, Any]: + kb_article_test_data = self.utilities.kb_article_test_data + self.utilities.navigate_to_link(KBArticlePageMessages.CREATE_NEW_KB_ARTICLE_STAGE_URL) + if is_template: + kb_title = (kb_article_test_data["kb_template_title"] + self.utilities. + generate_random_number(0, 5000)) + category = "60" + else: + kb_title = (kb_article_test_data["kb_article_title"] + self.utilities. + generate_random_number(0, 5000)) + category = "10" + + slug = slugify(kb_title) + + form_data = { + "csrfmiddlewaretoken": self.utilities.get_csrfmiddlewaretoken(), + "title": kb_title, + "slug": slug, + "category": category, + "is_localizable": "on", + "products": "1", + "topics": "383", + "allow_discussion": "on", + "keywords": kb_article_test_data["keywords"], + "summary": kb_article_test_data["search_result_summary"], + "content": kb_article_test_data["article_content"], + "expires": "", + "based_on": "", + "comment": kb_article_test_data["changes_description"] + } + + response = self.utilities.post_api_request( + page, KBArticlePageMessages.CREATE_NEW_KB_ARTICLE_STAGE_URL, data=form_data + ) + print(response) + self.utilities.navigate_to_link(response.url) + + first_revision_id = self.kb_article_show_history_page.get_last_revision_id() + if approve_revision: + self.approve_kb_revision(first_revision_id) + + return {"article_title": kb_title, + "article_content": kb_article_test_data["article_content"], + "article_slug": slug, + "keyword": kb_article_test_data["keywords"], + "search_results_summary": kb_article_test_data["search_result_summary"], + "article_url": response.url.removesuffix("/history"), + "article_show_history_url": self.utilities.get_page_url(), + "first_revision_id": first_revision_id, + "article_review_description": kb_article_test_data["changes_description"] + } diff --git a/playwright_tests/pages/explore_help_articles/articles/kb_edit_article_meta.py b/playwright_tests/pages/explore_help_articles/articles/kb_edit_article_meta.py index 780e9251c10..fe3a3074ad6 100644 --- a/playwright_tests/pages/explore_help_articles/articles/kb_edit_article_meta.py +++ b/playwright_tests/pages/explore_help_articles/articles/kb_edit_article_meta.py @@ -99,4 +99,4 @@ def fill_needs_change_textarea(self, text: str): def click_on_save_changes_button(self): self._click(self.__save_changes_button) - self._wait_for_dom_load_to_finish() + self.wait_for_page_to_load() diff --git a/playwright_tests/pages/messaging_system_pages/inbox_page.py b/playwright_tests/pages/messaging_system_pages/inbox_page.py index 2d69a721b3b..a7f646686ed 100644 --- a/playwright_tests/pages/messaging_system_pages/inbox_page.py +++ b/playwright_tests/pages/messaging_system_pages/inbox_page.py @@ -237,7 +237,7 @@ def delete_all_inbox_messages_via_delete_selected_button(self, excerpt='', expec excerpt: The excerpt of the message. expected_url: The expected URL after deleting all the messages. """ - self._wait_for_dom_load_to_finish() + self.wait_for_dom_to_load() if excerpt != '': inbox_messages_count = self._inbox_message_element_handles(excerpt) else: diff --git a/playwright_tests/test_data/aaq_question.json b/playwright_tests/test_data/aaq_question.json index 1f4546d1f56..80dea1d78a1 100644 --- a/playwright_tests/test_data/aaq_question.json +++ b/playwright_tests/test_data/aaq_question.json @@ -83,10 +83,12 @@ }, "Firefox for Enterprise": { "Accounts": "accounts", + "Browse": "browse", "Installation and updates": "installation-and-updates", + "Performance and connectivity": "performance-and-connectivity", "Privacy and security": "privacy-and-security", "Settings": "settings", - "default_slug": "none" + "default_slug": "firefox-enterprise" }, "Thunderbird": { "Accessibility": "accessibility", @@ -98,16 +100,22 @@ "Privacy and security": "privacy-and-security", "Search, tag, and share": "search-tag-and-share", "Settings": "settings", - "default_slug": "none" + "default_slug": "thunderbird" }, "Thunderbird for Android": { + "Accessibility": "accessibility", + "Accounts": "accounts", "Email and messaging": "email-and-messaging", "Installation and updates": "installation-and-updates", + "Passwords and sign in": "passwords-and-sign-in", + "Performance and connectivity": "performance-and-connectivity", "Privacy and security": "privacy-and-security", + "Search, tag, and share": "search-tag-and-share", "Settings": "settings", "default_slug": "thunderbird-android" }, "Firefox Focus": { + "Browse": "browse", "Installation and updates": "installation-and-updates", "Performance and connectivity": "performance-and-connectivity", "Privacy and security": "privacy-and-security", diff --git a/playwright_tests/tests/ask_a_question_tests/product_solutions_page_tests/test_product_solutions_page.py b/playwright_tests/tests/ask_a_question_tests/product_solutions_page_tests/test_product_solutions_page.py index 50dda638938..1f5a57e5ae3 100644 --- a/playwright_tests/tests/ask_a_question_tests/product_solutions_page_tests/test_product_solutions_page.py +++ b/playwright_tests/tests/ask_a_question_tests/product_solutions_page_tests/test_product_solutions_page.py @@ -1,7 +1,6 @@ import allure import pytest from pytest_check import check - from playwright.sync_api import expect, TimeoutError, Page from playwright_tests.core.utilities import Utilities from playwright_tests.messages.ask_a_question_messages.AAQ_messages.aaq_widget import ( @@ -13,7 +12,9 @@ # C890370, C890374 @pytest.mark.productSolutionsPage -def test_featured_articles_redirect(page: Page): +def test_featured_articles_redirect(page: Page, is_chromium): + if is_chromium: + pytest.skip("Skipping this test for chromium browser") utilities = Utilities(page) sumo_pages = SumoPages(page) with allure.step("Accessing the contact support page via the top navbar Get Help > " diff --git a/playwright_tests/tests/conftest.py b/playwright_tests/tests/conftest.py index ee6e2ffa46e..53ed478657a 100644 --- a/playwright_tests/tests/conftest.py +++ b/playwright_tests/tests/conftest.py @@ -15,8 +15,8 @@ def navigate_to_homepage(page: Page): object. """ utilities = Utilities(page) - # Set default navigation timeout to 2 minutes. - page.set_default_navigation_timeout(120000) + # Set default navigation timeout to 30 seconds. + page.set_default_navigation_timeout(30000) # Block pontoon requests in the current page context. page.route("**/pontoon.mozilla.org/**", utilities.block_request) @@ -36,7 +36,7 @@ def handle_502_error(response): page.context.on("response", handle_502_error) # Navigate to the SUMO stage homepage. - page.goto(HomepageMessages.STAGE_HOMEPAGE_URL) + utilities.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL) return page diff --git a/playwright_tests/tests/contribute_tests/dashboards_tests/test_kb_dashboard.py b/playwright_tests/tests/contribute_tests/dashboards_tests/test_kb_dashboard.py index 5141eac6bd1..892b4086675 100644 --- a/playwright_tests/tests/contribute_tests/dashboards_tests/test_kb_dashboard.py +++ b/playwright_tests/tests/contribute_tests/dashboards_tests/test_kb_dashboard.py @@ -20,9 +20,7 @@ def test_unreviewed_articles_visibility_in_kb_dashboard(page: Page): )) with allure.step("Create a new simple article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article() - sumo_pages.kb_article_page.click_on_article_option() - article_url = utilities.get_page_url() + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api(page) with allure.step("Navigating to the kb dashboards and clicking on the 'Complete " "overview' option"): @@ -75,7 +73,7 @@ def test_unreviewed_articles_visibility_in_kb_dashboard(page: Page): sumo_pages.kb_dashboard_page._click_on_article_title(article_details['article_title']) with allure.step("Verifying that the user is redirected to the correct kb page"): - expect(page).to_have_url(article_url) + expect(page).to_have_url(article_details['article_url']) with allure.step("Approving the article revision"): sumo_pages.submit_kb_article_flow.approve_kb_revision(article_details['first_revision_id']) @@ -134,13 +132,10 @@ def test_kb_dashboard_articles_status(page: Page): )) with allure.step("Creating a new simple article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article( - approve_first_revision=True - ) + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api( + page=page,approve_revision=True) - article_url = utilities.get_page_url() - - with allure.step("Creating a anew revision for the document"): + with allure.step("Creating a new revision for the document"): second_revision = sumo_pages.submit_kb_article_flow.submit_new_kb_revision() with check, allure.step("Navigating to the kb overview dashboard and verifying that the " @@ -154,7 +149,7 @@ def test_kb_dashboard_articles_status(page: Page): ) with allure.step("Navigating back to the article history and deleting the revision"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.kb_article_show_history_page.click_on_delete_revision_button( second_revision['revision_id'] ) @@ -184,11 +179,10 @@ def test_kb_dashboard_revision_deferred_status(page: Page): )) with allure.step("Creating a new simple article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article( - approve_first_revision=True - ) + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api( + page=page,approve_revision=True) - article_url = utilities.get_page_url() + article_show_history_url = utilities.get_page_url() with allure.step("Creating a new revision for the document"): second_revision = sumo_pages.submit_kb_article_flow.submit_new_kb_revision() @@ -202,7 +196,7 @@ def test_kb_dashboard_revision_deferred_status(page: Page): second_revision['changes_description']) with allure.step("Navigating back to the article history page and deferring the revision"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_show_history_url) sumo_pages.kb_article_show_history_page.click_on_review_revision( second_revision['revision_id'] ) @@ -217,7 +211,7 @@ def test_kb_dashboard_revision_deferred_status(page: Page): ) == kb_dashboard_page_messages.KB_LIVE_STATUS with allure.step("Deleting the article"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_show_history_url) sumo_pages.kb_article_deletion_flow.delete_kb_article() @@ -232,11 +226,8 @@ def test_kb_dashboard_needs_update_when_reviewing_a_revision(page: Page): )) with allure.step("Creating a new simple article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article( - approve_first_revision=True - ) - - article_url = utilities.get_page_url() + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api( + page=page,approve_revision=True) with allure.step("Creating an new article revision for the document"): second_revision = sumo_pages.submit_kb_article_flow.submit_new_kb_revision() @@ -252,7 +243,7 @@ def test_kb_dashboard_needs_update_when_reviewing_a_revision(page: Page): ).strip() == utilities.kb_revision_test_data['needs_change_message'] with allure.step("Deleting the article"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.kb_article_deletion_flow.delete_kb_article() @@ -268,11 +259,8 @@ def test_kb_dashboard_needs_update_edit_metadata(page: Page): )) with allure.step("Create a new simple article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article( - approve_first_revision=True - ) - - article_url = utilities.get_page_url() + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api( + page=page, approve_revision=True) with allure.step("Clicking on the 'Edit Article Metadata' option and enabling the 'Needs " "change with comment' option"): @@ -289,7 +277,7 @@ def test_kb_dashboard_needs_update_edit_metadata(page: Page): with allure.step("Navigating back to the article's 'Edit Article Metadata' page and " "removing the comment from the needs change textarea"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.edit_article_metadata_flow.edit_article_metadata(needs_change=True) with allure.step("Navigating to the complete dashboard list and verifying that the " @@ -301,7 +289,7 @@ def test_kb_dashboard_needs_update_edit_metadata(page: Page): with allure.step("Navigating back to the article's 'Edit Article Metadata' page and " "removing the needs change updates"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.edit_article_metadata_flow.edit_article_metadata() with check, allure.step("Navigating to the kb overview page and verifying that the " @@ -312,7 +300,7 @@ def test_kb_dashboard_needs_update_edit_metadata(page: Page): ) with allure.step("Deleting the article"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.kb_article_deletion_flow.delete_kb_article() @@ -328,11 +316,9 @@ def test_ready_for_l10n_kb_dashboard_revision_approval(page: Page): )) with allure.step("Create a new simple article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article() + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api(page=page) - article_url = utilities.get_page_url() - - revision_id = sumo_pages.kb_article_show_history_page.get_last_revision_id() + revision_id = article_details['first_revision_id'] with allure.step("Approving the first revision and marking it as ready for l10n"): sumo_pages.submit_kb_article_flow.approve_kb_revision( @@ -346,7 +332,7 @@ def test_ready_for_l10n_kb_dashboard_revision_approval(page: Page): ) == kb_dashboard_page_messages.GENERAL_POSITIVE_STATUS with allure.step("Deleting the article"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.kb_article_deletion_flow.delete_kb_article() @@ -362,11 +348,8 @@ def test_ready_for_l10n_kb_dashboard_revision_l10n_status(page: Page): )) with allure.step("Creating a new kb article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article( - approve_first_revision=True - ) - - article_url = utilities.get_page_url() + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api( + page=page, approve_revision=True) with check, allure.step("Navigating to the kb dashboard overview page and verifying that " "the correct l10n status is displayed"): @@ -377,7 +360,7 @@ def test_ready_for_l10n_kb_dashboard_revision_l10n_status(page: Page): with allure.step("Navigating back to the article page and marking the revision as ready " "for l10n"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.kb_article_show_history_page.click_on_ready_for_l10n_option( article_details['first_revision_id'] ) @@ -391,7 +374,7 @@ def test_ready_for_l10n_kb_dashboard_revision_l10n_status(page: Page): ) == kb_dashboard_page_messages.GENERAL_POSITIVE_STATUS with allure.step("Navigating to the article and deleting it"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.kb_article_deletion_flow.delete_kb_article() @@ -490,11 +473,8 @@ def test_article_title_update(page: Page): )) with allure.step("Creating a new kb article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article( - approve_first_revision=True - ) - - article_url = utilities.get_page_url() + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api( + page=page, approve_revision=True) with allure.step("Navigating to the kb dashboard overview page and verifying that the " "correct title is displayed"): @@ -507,7 +487,7 @@ def test_article_title_update(page: Page): with allure.step("Navigating to the article's 'Edit Metadata page' page and changing the " "title"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) new_article_title = "Updated " + article_details['article_title'] sumo_pages.edit_article_metadata_flow.edit_article_metadata(title=new_article_title) @@ -519,5 +499,5 @@ def test_article_title_update(page: Page): ).to_be_visible() with allure.step("Deleting the kb article"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.kb_article_deletion_flow.delete_kb_article() diff --git a/playwright_tests/tests/contribute_tests/dashboards_tests/test_recent_revisions_dashboard.py b/playwright_tests/tests/contribute_tests/dashboards_tests/test_recent_revisions_dashboard.py index 26d63c22c1e..b67f40eec20 100644 --- a/playwright_tests/tests/contribute_tests/dashboards_tests/test_recent_revisions_dashboard.py +++ b/playwright_tests/tests/contribute_tests/dashboards_tests/test_recent_revisions_dashboard.py @@ -23,9 +23,7 @@ def test_recent_revisions_revision_availability(page: Page): username = sumo_pages.top_navbar.get_text_of_logged_in_username() with allure.step("Creating a new kb article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article() - - article_url = utilities.get_page_url() + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api(page=page) with allure.step("Navigating to the recent revisions dashboard and verifying that the " "posted article is displayed for admin accounts"): @@ -89,7 +87,7 @@ def test_recent_revisions_revision_availability(page: Page): )) with allure.step("Navigating to the article page and deleting it"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.kb_article_deletion_flow.delete_kb_article() with allure.step("Navigating back to the recent revisions page and verifying that the " @@ -115,11 +113,8 @@ def test_second_revisions_availability(page: Page): )) with allure.step("Creating a new kb article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article( - approve_first_revision=True - ) - - article_url = utilities.get_page_url() + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api( + page=page, approve_revision=True) with allure.step("Signing in with a non-admin account"): utilities.start_existing_session(utilities.username_extraction_from_email( @@ -175,7 +170,7 @@ def test_second_revisions_availability(page: Page): ).to_be_visible() with allure.step("Navigating to the article and approving the revision"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.submit_kb_article_flow.approve_kb_revision(second_revision['revision_id']) utilities.wait_for_given_timeout(1000) @@ -205,7 +200,7 @@ def test_second_revisions_availability(page: Page): utilities.start_existing_session(utilities.username_extraction_from_email( utilities.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] )) - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details["article_show_history_url"]) sumo_pages.kb_article_deletion_flow.delete_kb_article() with allure.step("Navigating back to the recent revision dashboard, signing out and " @@ -246,12 +241,8 @@ def test_recent_revisions_dashboard_links(page: Page): first_username = sumo_pages.top_navbar.get_text_of_logged_in_username() with allure.step("Creating a new kb article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article( - approve_first_revision=True - ) - - sumo_pages.kb_article_page.click_on_article_option() - article_url = utilities.get_page_url() + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api( + page=page, approve_revision=True) with allure.step("Navigating to the recent revisions dashboard and verifying that the " "'Show Diff' option is not available for first revisions"): @@ -265,7 +256,7 @@ def test_recent_revisions_dashboard_links(page: Page): with allure.step("Navigating to the article page, signing in with a non-admin user and " "creating a new revision for the article"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details['article_url']) utilities.start_existing_session(utilities.username_extraction_from_email( utilities.user_secrets_accounts["TEST_ACCOUNT_13"] )) @@ -282,7 +273,7 @@ def test_recent_revisions_dashboard_links(page: Page): article_title=article_details['article_title'], username=username ) expect(page).to_have_url( - article_url + KBArticleRevision. + article_details['article_url'] + KBArticleRevision. KB_REVISION_PREVIEW + str(utilities.number_extraction_from_string( second_revision['revision_id'] )) @@ -298,7 +289,7 @@ def test_recent_revisions_dashboard_links(page: Page): sumo_pages.recent_revisions_page._click_on_article_title( article_title=article_details['article_title'], creator=username ) - expect(page).to_have_url(article_url) + expect(page).to_have_url(article_details['article_url']) with check, allure.step("Navigating back and verifying that the correct comment is " "displayed"): @@ -333,7 +324,7 @@ def test_recent_revisions_dashboard_links(page: Page): utilities.start_existing_session(utilities.username_extraction_from_email( utilities.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] )) - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details['article_url']) sumo_pages.kb_article_deletion_flow.delete_kb_article() @@ -349,12 +340,8 @@ def test_recent_revisions_dashboard_title_and_username_update(page: Page): first_username = sumo_pages.top_navbar.get_text_of_logged_in_username() with allure.step("Creating a new kb article"): - article_details = sumo_pages.submit_kb_article_flow.submit_simple_kb_article( - approve_first_revision=True - ) - - sumo_pages.kb_article_page.click_on_article_option() - article_url = utilities.get_page_url() + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api( + page=page, approve_revision=True) with allure.step("Changing the article title via the 'Edit Article Metadata' page"): sumo_pages.edit_article_metadata_flow.edit_article_metadata( @@ -390,7 +377,7 @@ def test_recent_revisions_dashboard_title_and_username_update(page: Page): ) with allure.step("Deleting the article"): - utilities.navigate_to_link(article_url) + utilities.navigate_to_link(article_details['article_url']) sumo_pages.kb_article_deletion_flow.delete_kb_article() diff --git a/playwright_tests/tests/contribute_tests/test_groups.py b/playwright_tests/tests/contribute_tests/test_groups.py index 27532526551..9c4ba95208c 100644 --- a/playwright_tests/tests/contribute_tests/test_groups.py +++ b/playwright_tests/tests/contribute_tests/test_groups.py @@ -271,7 +271,7 @@ def test_add_new_group_leader(page: Page): sumo_pages.user_group_flow.remove_a_user_from_group(test_user) -# C2083499, C2715807 +# C2083499, C2715807, C891410 @pytest.mark.userGroupsTests @pytest.mark.parametrize("user", ['TEST_ACCOUNT_MESSAGE_2', 'TEST_ACCOUNT_MODERATOR']) def test_add_group_members(page: Page, user): diff --git a/playwright_tests/tests/explore_help_articles_tests/articles/test_article_show_history.py b/playwright_tests/tests/explore_help_articles_tests/articles/test_article_show_history.py index 5be52be17cf..29a6680e582 100644 --- a/playwright_tests/tests/explore_help_articles_tests/articles/test_article_show_history.py +++ b/playwright_tests/tests/explore_help_articles_tests/articles/test_article_show_history.py @@ -22,12 +22,16 @@ # C891309, C2102170, C2102168, C2489545, C910271 @pytest.mark.kbArticleShowHistory -@pytest.mark.create_delete_article(False) -def test_kb_article_removal(page: Page, create_delete_article): +def test_kb_article_removal(page: Page): utilities = Utilities(page) sumo_pages = SumoPages(page) kb_show_history_page_messages = KBArticleShowHistoryPageMessages() - article_details = create_delete_article("TEST_ACCOUNT_12")[0] + + utilities.start_existing_session(utilities.username_extraction_from_email( + utilities.user_secrets_accounts["TEST_ACCOUNT_12"] + )) + + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api(page=page) revision_id_number = utilities.number_extraction_from_string( article_details['first_revision_id'] ) @@ -52,7 +56,7 @@ def test_kb_article_removal(page: Page, create_delete_article): with allure.step("Navigating back and verifying that the delete button for the article " "is not displayed"): - utilities.navigate_to_link(article_details["article_url"]) + utilities.navigate_to_link(article_details["article_show_history_url"]) expect(sumo_pages.kb_article_show_history_page.get_delete_this_document_button_locator( )).to_be_hidden() @@ -68,7 +72,7 @@ def test_kb_article_removal(page: Page, create_delete_article): assert response.status == 403 with allure.step("Navigating back and deleting the user session"): - utilities.navigate_to_link(article_details["article_url"]) + utilities.navigate_to_link(article_details["article_show_history_url"]) utilities.delete_cookies() with check, allure.step("Manually navigating to the delete revision endpoint and " @@ -80,7 +84,7 @@ def test_kb_article_removal(page: Page, create_delete_article): with check, allure.step("Navigating back and verifying that manually navigating to the " "delete endpoint returns the auth page"): - utilities.navigate_to_link(article_details["article_url"]) + utilities.navigate_to_link(article_details["article_show_history_url"]) utilities.navigate_to_link( KBArticlePageMessages .KB_ARTICLE_PAGE_URL + article_details['article_slug'] + QuestionPageMessages @@ -90,7 +94,7 @@ def test_kb_article_removal(page: Page, create_delete_article): with allure.step("Navigating back and verifying that the delete button is not available " "for the only revision"): - utilities.navigate_to_link(article_details["article_url"]) + utilities.navigate_to_link(article_details["article_show_history_url"]) expect(sumo_pages.kb_article_show_history_page.get_delete_revision_button_locator( article_details['first_revision_id'])).to_be_hidden() @@ -165,19 +169,23 @@ def test_kb_article_removal(page: Page, create_delete_article): # C2490047, C2490048 @pytest.mark.kbArticleShowHistory -def test_kb_article_category_link_and_header(page: Page, create_delete_article): +def test_kb_article_category_link_and_header(page: Page): utilities = Utilities(page) sumo_pages = SumoPages(page) + utilities.start_existing_session(utilities.username_extraction_from_email( + utilities.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) for category in utilities.general_test_data["kb_article_categories"]: if category != "Templates": with allure.step("Creating a new article"): - article_info = create_delete_article("TEST_ACCOUNT_MODERATOR", - {"article_category": category})[0] + article_info = sumo_pages.submit_kb_article_flow.submit_simple_kb_article( + article_category=category + ) else: with allure.step("Creating a new template article"): - article_info = create_delete_article("TEST_ACCOUNT_MODERATOR", - {"article_category": category, - "is_template": True})[0] + article_info = sumo_pages.submit_kb_article_flow.submit_simple_kb_article( + article_category=category, is_template=True + ) with check, allure.step("Verifying that the correct page header is displayed"): assert sumo_pages.kb_article_show_history_page.get_show_history_page_title( @@ -203,15 +211,21 @@ def test_kb_article_category_link_and_header(page: Page, create_delete_article): with allure.step("Navigating back and deleting the article"): utilities.navigate_back() + sumo_pages.kb_article_deletion_flow.delete_kb_article() # C2101637, C2489543, C2102169, C2489542 @pytest.mark.kbArticleShowHistory -def test_kb_article_contributor_removal(page: Page, create_delete_article): +def test_kb_article_contributor_removal(page: Page): utilities = Utilities(page) sumo_pages = SumoPages(page) kb_show_history_page_messages = KBArticleShowHistoryPageMessages() - article_details, username_one = create_delete_article("TEST_ACCOUNT_MODERATOR") + + username_one = utilities.start_existing_session(utilities.username_extraction_from_email( + utilities.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api(page=page) with allure.step("Verifying that no users are added inside the contributors list"): expect(sumo_pages.kb_article_show_history_page.get_all_contributors_locator() ).to_be_hidden() @@ -379,16 +393,22 @@ def test_kb_article_contributor_removal(page: Page, create_delete_article): sumo_pages.kb_article_page.click_on_article_option() assert username_two in sumo_pages.kb_article_page.get_list_of_kb_article_contributors() + with allure.step("Deleting the artice"): + sumo_pages.kb_article_deletion_flow.delete_kb_article() + # C2101638 @pytest.mark.kbArticleShowHistory -def test_contributors_can_be_manually_added(page: Page, create_delete_article): +def test_contributors_can_be_manually_added(page: Page): utilities = Utilities(page) sumo_pages = SumoPages(page) kb_show_history_page_messages = KBArticleShowHistoryPageMessages() + utilities.start_existing_session(utilities.username_extraction_from_email( + utilities.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) with allure.step("Clicking on the 'Edit Contributors' option, adding and selecting the " "username from the search field"): - create_delete_article("TEST_ACCOUNT_MODERATOR") + sumo_pages.submit_kb_article_flow.kb_article_creation_via_api(page=page) sumo_pages.kb_article_show_history_page.click_on_edit_contributors_option() new_contributor = utilities.username_extraction_from_email( utilities.user_secrets_accounts["TEST_ACCOUNT_12"] @@ -414,14 +434,22 @@ def test_contributors_can_be_manually_added(page: Page, create_delete_article): sumo_pages.kb_article_page.click_on_article_option() assert new_contributor in sumo_pages.kb_article_page.get_list_of_kb_article_contributors() + with allure.step("Deleting the article"): + sumo_pages.kb_article_deletion_flow.delete_kb_article() + # C2101634, C2489553, C2102186 @pytest.mark.kbArticleShowHistory -def test_kb_article_contributor_profile_access(page: Page, create_delete_article): +def test_kb_article_contributor_profile_access(page: Page): utilities = Utilities(page) sumo_pages = SumoPages(page) kb_article_show_history_page = KBArticleShowHistoryPage(page) - create_delete_article("TEST_ACCOUNT_MODERATOR", {"approve_first_revision": True}) + utilities.start_existing_session(utilities.username_extraction_from_email( + utilities.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + sumo_pages.submit_kb_article_flow.kb_article_creation_via_api( + page=page, approve_revision=True) sumo_pages.kb_article_page.click_on_article_option() article_url = utilities.get_page_url() @@ -495,19 +523,21 @@ def test_kb_article_contributor_profile_access(page: Page, create_delete_article with allure.step("Navigating back and deleting the created article"): utilities.navigate_back() + sumo_pages.kb_article_deletion_flow.delete_kb_article() # C2499415, C2271120, C2101633 @pytest.mark.kbArticleShowHistory -def test_kb_article_revision_date_functionality(page: Page, create_delete_article): +def test_kb_article_revision_date_functionality(page: Page): utilities = Utilities(page) sumo_pages = SumoPages(page) with allure.step("Signing in with an admin account and creating a new article and " "approving it's first revision"): - article_details, main_user = create_delete_article("TEST_ACCOUNT_MODERATOR", - {"approve_first_revision": True}) - sumo_pages.kb_article_page.click_on_article_option() - article_url = utilities.get_page_url() + main_user = utilities.start_existing_session(utilities.username_extraction_from_email( + utilities.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + article_details = sumo_pages.submit_kb_article_flow.kb_article_creation_via_api( + page=page, approve_revision=True) with allure.step("Signing in with a non-admin account"): creator_username = utilities.start_existing_session( @@ -696,6 +726,10 @@ def test_kb_article_revision_date_functionality(page: Page, create_delete_articl (sumo_pages.kb_article_preview_revision_page ._click_on_edit_article_based_on_this_revision_link()) expect(page).to_have_url( - article_url + QuestionPageMessages.EDIT_QUESTION_URL_ENDPOINT + "/" + str( - utilities.number_extraction_from_string(second_revision_info['revision_id'])) + article_details['article_url'] + QuestionPageMessages. + EDIT_QUESTION_URL_ENDPOINT + "/" + str(utilities.number_extraction_from_string( + second_revision_info['revision_id'])) ) + + with allure.step("Deleting the article"): + sumo_pages.kb_article_deletion_flow.delete_kb_article() diff --git a/playwright_tests/tests/explore_help_articles_tests/articles/test_article_threads.py b/playwright_tests/tests/explore_help_articles_tests/articles/test_article_threads.py index 912b13267e7..56d718400f9 100644 --- a/playwright_tests/tests/explore_help_articles_tests/articles/test_article_threads.py +++ b/playwright_tests/tests/explore_help_articles_tests/articles/test_article_threads.py @@ -906,7 +906,7 @@ def test_posting_a_new_kb_test_article(page: Page): utilities.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] )) - sumo_pages.submit_kb_article_flow.submit_simple_kb_article(approve_first_revision=True) + sumo_pages.submit_kb_article_flow.kb_article_creation_via_api(page=page, approve_revision=True) sumo_pages.kb_article_page.click_on_article_option() with open("test_data/test_article", 'w') as file: file.write(utilities.get_page_url()) diff --git a/playwright_tests/tests/explore_help_articles_tests/articles/test_product_support_page.py b/playwright_tests/tests/explore_help_articles_tests/articles/test_product_support_page.py index eb7c8e37f83..ece8dcd7575 100644 --- a/playwright_tests/tests/explore_help_articles_tests/articles/test_product_support_page.py +++ b/playwright_tests/tests/explore_help_articles_tests/articles/test_product_support_page.py @@ -123,7 +123,9 @@ def test_product_support_page_frequent_topics_redirect(page: Page): # T5696580, C891335, C891336 @pytest.mark.productSupportPage -def test_product_support_page_featured_articles_redirect(page: Page): +def test_product_support_page_featured_articles_redirect(page: Page, is_chromium): + if is_chromium: + pytest.skip("Skipping this test for chromium browser") utilities = Utilities(page) sumo_pages = SumoPages(page) with allure.step("Navigating to products page via top-navbar"): diff --git a/playwright_tests/tests/explore_help_articles_tests/explore_by_topic_tests/test_explore_by_topics.py b/playwright_tests/tests/explore_help_articles_tests/explore_by_topic_tests/test_explore_by_topics.py index 18a6ab2e7d3..c93190896fb 100644 --- a/playwright_tests/tests/explore_help_articles_tests/explore_by_topic_tests/test_explore_by_topics.py +++ b/playwright_tests/tests/explore_help_articles_tests/explore_by_topic_tests/test_explore_by_topics.py @@ -26,6 +26,7 @@ def test_explore_by_topic_product_filter(page: Page): topic = topic.strip() if topic != "Browse": sumo_pages.explore_by_topic_page.click_on_a_topic_filter(topic) + utilities.wait_for_dom_to_load() with allure.step("Verifying that the correct page header is displayed"): assert topic == (sumo_pages.explore_by_topic_page .get_explore_by_topic_page_header().strip()) diff --git a/playwright_tests/tests/user_page_tests/test_edit_my_profile.py b/playwright_tests/tests/user_page_tests/test_edit_my_profile.py index acc4fcaa004..8198decf9e0 100644 --- a/playwright_tests/tests/user_page_tests/test_edit_my_profile.py +++ b/playwright_tests/tests/user_page_tests/test_edit_my_profile.py @@ -687,10 +687,6 @@ def _validate_profile_info(page: Page, target: str, profile_info: str, username: "involved_from_month": sumo_pages.my_profile_page.get_my_contributed_from_text, "involved_from_year": sumo_pages.my_profile_page.get_my_contributed_from_text, } - link_click_methods = { - "community_portal": sumo_pages.my_profile_page.click_on_community_portal_link, - "people_directory": sumo_pages.my_profile_page.click_on_people_directory_link, - } with allure.step("Signing in with a different non-admin user"): utilities.start_existing_session(utilities.username_extraction_from_email( @@ -704,27 +700,11 @@ def _validate_profile_info(page: Page, target: str, profile_info: str, username: if profile_info not in profile_info_getters.get(target, lambda: None)(): return False - if target in link_click_methods: - with allure.step("Clicking on the link and verifying redirection"): - link_click_methods[target]() - utilities.wait_for_networkidle() - print(utilities.get_page_url()) - if profile_info not in utilities.get_page_url(): - return False - utilities.navigate_to_link(MyProfileMessages.get_my_profile_stage_url(username)) - with allure.step("Signing out and verifying the information again"): utilities.delete_cookies() utilities.navigate_to_link(MyProfileMessages.get_my_profile_stage_url(username)) if profile_info not in profile_info_getters.get(target, lambda: None)(): return False - if target in link_click_methods: - with allure.step("Clicking on the link and verifying redirection"): - link_click_methods[target]() - utilities.wait_for_networkidle() - if profile_info not in utilities.get_page_url(): - return False - utilities.navigate_to_link(MyProfileMessages.get_my_profile_stage_url(username)) return True diff --git a/playwright_tests/tests/user_page_tests/test_my_profile_page.py b/playwright_tests/tests/user_page_tests/test_my_profile_page.py index 4c6e79fe664..ebba2796ea1 100644 --- a/playwright_tests/tests/user_page_tests/test_my_profile_page.py +++ b/playwright_tests/tests/user_page_tests/test_my_profile_page.py @@ -38,7 +38,7 @@ def test_my_profile_page_can_be_accessed_via_top_navbar(page: Page): ) == UserProfileNavbarMessages.NAVBAR_OPTIONS[0] -# C891411 +# C891411, C891410 @pytest.mark.userProfile def test_my_profile_sign_out_button_functionality(page: Page): utilities = Utilities(page) @@ -63,7 +63,7 @@ def test_my_profile_sign_out_button_functionality(page: Page): expect(sumo_pages.top_navbar.sign_in_up_button_displayed_element()).to_be_visible() -# C2108828 +# C2108828, C891410 @pytest.mark.userProfile def test_provided_solutions_number_is_successfully_displayed(page: Page): utilities = Utilities(page) @@ -133,7 +133,7 @@ def test_provided_solutions_number_is_successfully_displayed(page: Page): expect(sumo_pages.product_support_page.product_product_title_element()).to_be_visible() -# C890832, C2094281 +# C890832, C2094281, C891410 @pytest.mark.userProfile def test_number_of_my_profile_answers_is_successfully_displayed(page: Page): utilities = Utilities(page) @@ -201,7 +201,7 @@ def test_number_of_my_profile_answers_is_successfully_displayed(page: Page): expect(sumo_pages.product_support_page.product_product_title_element()).to_be_visible() -# C2094285, C2094284, C891309 +# C2094285, C2094284, C891309, C891410 @pytest.mark.userProfile def test_number_of_posted_articles_is_successfully_displayed(page: Page): utilities = Utilities(page)