From 11e785aa63fa19b9fae92bdc95df4bd5f8ea172d Mon Sep 17 00:00:00 2001 From: Emil Ghitta Date: Thu, 10 Oct 2024 15:43:37 +0300 Subject: [PATCH] - Adding test for doc_id field operator verification in test_main_searchbar.py - Adding a function inside the utilities.py which returns the GET api response. - Enabling test_featured_articles_redirect test inside test_product_solutions_page.py. - Mapping some automated tests with their manual representative via the TestRail tc ID --- playwright_tests/core/utilities.py | 3 ++ .../test_product_solutions_page.py | 5 ++- .../tests/search_tests/test_main_searchbar.py | 32 ++++++++++++++++++- .../test_top_navbar.py | 2 +- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/playwright_tests/core/utilities.py b/playwright_tests/core/utilities.py index 7d84f4ef362..d924a737dfc 100644 --- a/playwright_tests/core/utilities.py +++ b/playwright_tests/core/utilities.py @@ -421,3 +421,6 @@ def _exact_phrase_check(self, search_result: str, search_term: str) -> bool: search_result = search_result.lower() print(f"Search result is: {search_result}") return search_term in search_result + + def get_api_response(self, page: Page, api_url: str): + return page.request.get(api_url) 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 4f8e58dcc11..86dd180b2dd 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 @@ -11,9 +11,8 @@ from playwright_tests.pages.sumo_pages import SumoPages -# Currently fails due to https://github.com/mozilla/sumo/issues/1608 -# C890370 -@pytest.mark.skip +# C890370, C890374 +@pytest.mark.productSolutionsPage def test_featured_articles_redirect(page: Page): utilities = Utilities(page) sumo_pages = SumoPages(page) diff --git a/playwright_tests/tests/search_tests/test_main_searchbar.py b/playwright_tests/tests/search_tests/test_main_searchbar.py index 4e20a38db84..9f499a3b632 100644 --- a/playwright_tests/tests/search_tests/test_main_searchbar.py +++ b/playwright_tests/tests/search_tests/test_main_searchbar.py @@ -388,7 +388,7 @@ def test_exact_phrase_searching(page: Page): assert not sumo_pages.search_page.is_search_content_section_displayed() -# C1352395, C1352397, C1352400 +# C1352395, C1352397, C1352400, C1493903 @pytest.mark.searchTests def test_keywords_field_and_content_operator(page: Page): sumo_pages = SumoPages(page) @@ -608,6 +608,36 @@ def test_field_operators_for_non_us_locales(page: Page): sumo_pages.kb_article_deletion_flow.delete_kb_article() +# C1358447 +@pytest.mark.searchTests +def test_doc_id_field_operator(page: Page): + sumo_pages = SumoPages(page) + utilities = Utilities(page) + + with allure.step("Performing a GET request against the /api/1/kb endpoint and saving the " + "first returned kb article information"): + kb_list = utilities.get_api_response(page, f"{HomepageMessages.STAGE_HOMEPAGE_URL}" + f"/api/1/kb") + first_kb_result = kb_list.json()['results'][0] + kb_result_dict = { + "kb_title": first_kb_result["title"], + "kb_slug": first_kb_result["slug"] + } + + with allure.step("Performing a GET request against the /api/1/kb/{first article slug} and " + "fetching the document_id"): + document_info = utilities.get_api_response(page, f"{HomepageMessages.STAGE_HOMEPAGE_URL}" + f"/api/1/kb/{kb_result_dict['kb_slug']}") + document_id = document_info.json()['id'] + + with allure.step("Searching for the doc_id field operator inside the main searchbar"): + sumo_pages.search_page.fill_into_searchbar(f"field:doc_id.en-US:{document_id}") + utilities.wait_for_given_timeout(2000) + + with allure.step("Verifying that the correct article is returned"): + sumo_pages.search_page.is_a_particular_article_visible(kb_result_dict['kb_title']) + + def _verify_search_results(page: Page, search_term: str, locale: str, search_result_title: str, search_result_bolded_content: list[str], exact_phrase=False) -> bool: utilities = Utilities(page) diff --git a/playwright_tests/tests/top_navbar_section_tests/test_top_navbar.py b/playwright_tests/tests/top_navbar_section_tests/test_top_navbar.py index 2296031dd5e..9129285d5e5 100644 --- a/playwright_tests/tests/top_navbar_section_tests/test_top_navbar.py +++ b/playwright_tests/tests/top_navbar_section_tests/test_top_navbar.py @@ -183,7 +183,7 @@ def test_browse_all_forum_threads_by_topic_redirect(page: Page): == current_option) -# T5696576, T5696591 +# T5696576, T5696591, C2663303 @pytest.mark.topNavbarTests def test_ask_a_question_top_navbar_redirect(page: Page): sumo_pages = SumoPages(page)