Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playwright add test for doc_id search #6290

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions playwright_tests/core/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 31 additions & 1 deletion playwright_tests/tests/search_tests/test_main_searchbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down