From c629cf7d2dc2332fe10116db8dfea3c16f43fcda Mon Sep 17 00:00:00 2001 From: Emil Ghitta Date: Mon, 4 Mar 2024 20:35:19 +0200 Subject: [PATCH] Expanding playwright coverage over KB Dashboard and performing the following verifications: - Ensure that the Live status, Needs Update, Ready for L10N, Stale & Expiry Date are successfully displayed & updated according to the corresponding modifications performed at KB article level. - Ensure that changing the kb article title is also resembled inside the KB Dashboard. - Ensure that the kb article title link (displayed inside the KB dashboard) redirects the user to the correct kb article page. Updated the GH playwright workflow to include the new tests in our scheduled GH run. Also performed some code refactoring by creating 'flow functions' for some repetitive kb actions (revision creation & article deletion). --- .github/workflows/playwright.yml | 5 + playwright_tests/core/basepage.py | 4 + playwright_tests/core/testutilities.py | 15 +- .../article_flows/add_kb_article_flow.py | 11 +- .../article_flows/add_kb_revision_flow.py | 33 +- .../article_flows/delete_kb_article_flow.py | 21 + .../article_flows/edit_article_meta_flow.py | 35 + .../article_flows/post_new_thread_flow.py | 0 .../con_tools/kb_dashboard_messages.py | 7 + .../kb_dashboard_page.py | 71 ++ .../kb_article_review_revision_page.py | 24 + .../articles/kb_article_show_history_page.py | 11 + ...le_metadata.py => kb_edit_article_meta.py} | 6 +- .../articles/submit_kb_article_page.py | 4 + playwright_tests/pages/sumo_pages.py | 20 +- playwright_tests/pages/top_navbar.py | 6 + playwright_tests/pytest.ini | 1 + .../test_data/add_kb_article.json | 1 + playwright_tests/test_data/general_data.json | 3 +- playwright_tests/test_data/kb_revision.json | 3 + .../dashboards_tests/test_kb_dashboard.py | 649 ++++++++++++++++++ .../test_recent_revisions_dashboard.py | 12 +- .../articles/test_article_show_history.py | 156 ++--- .../articles/test_article_threads.py | 15 +- .../test_kb_article_creation_and_access.py | 68 +- 25 files changed, 993 insertions(+), 188 deletions(-) rename playwright_tests/flows/{explore_help_articles_flows => explore_articles_flows}/article_flows/add_kb_article_flow.py (93%) rename playwright_tests/flows/{explore_help_articles_flows => explore_articles_flows}/article_flows/add_kb_revision_flow.py (68%) create mode 100644 playwright_tests/flows/explore_articles_flows/article_flows/delete_kb_article_flow.py create mode 100644 playwright_tests/flows/explore_articles_flows/article_flows/edit_article_meta_flow.py rename playwright_tests/flows/{explore_help_articles_flows => explore_articles_flows}/article_flows/post_new_thread_flow.py (100%) create mode 100644 playwright_tests/messages/contribute_messages/con_tools/kb_dashboard_messages.py create mode 100644 playwright_tests/pages/contribute/contributor_tools_pages/kb_dashboard_page.py rename playwright_tests/pages/explore_help_articles/articles/{kb_edit_article_metadata.py => kb_edit_article_meta.py} (94%) create mode 100644 playwright_tests/test_data/kb_revision.json create mode 100644 playwright_tests/tests/contribute_tests/dashboards_tests/test_kb_dashboard.py diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 3bb7ebb0320..252efc79ce5 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -163,6 +163,11 @@ jobs: if: success() || failure() && steps.create-sessions.outcome == 'success' run: | poetry run pytest -m recentRevisionsDashboard --numprocesses 2 --browser ${{ env.BROWSER }} --reruns 1 --html=reports/${{ env.BROWSER }}_kb_article_recent_revisions.html --capture=tee-sys + - name: Run KB Dashboard Tests (${{ env.BROWSER }}) + working-directory: playwright_tests + if: success() || failure() && steps.create-sessions.outcome == 'success' + run: | + poetry run pytest -m kbDashboard --numprocesses 2 --browser ${{ env.BROWSER }} --reruns 1 --html=reports/${{ env.BROWSER }}_kb_dashboard.html --capture=tee-sys - name: Combine Reports working-directory: playwright_tests if: success() || failure() diff --git a/playwright_tests/core/basepage.py b/playwright_tests/core/basepage.py index dd03743da3f..efe481610ce 100644 --- a/playwright_tests/core/basepage.py +++ b/playwright_tests/core/basepage.py @@ -38,6 +38,10 @@ def _get_text_of_elements(self, xpath: str) -> list[str]: def _get_text_of_element(self, xpath: str) -> str: return self._get_element_locator(xpath).inner_text() + # Returning true if the inner text of an element is empty + def _is_element_empty(self, xpath: str) -> bool: + return not self._get_element_locator(xpath).inner_text() + # Elements count retrieval. def _get_elements_count(self, xpath: str) -> int: return self._get_element_locator(xpath).count() diff --git a/playwright_tests/core/testutilities.py b/playwright_tests/core/testutilities.py index 01a9cce56f0..31ef1ffed45 100644 --- a/playwright_tests/core/testutilities.py +++ b/playwright_tests/core/testutilities.py @@ -42,6 +42,10 @@ class TestUtilities: kb_new_thread_test_data = json.load(kb_new_thread_test_data_file) kb_article_test_data_file.close() + with open("test_data/kb_revision.json", "r") as kb_revision_test_data_file: + kb_revision_test_data = json.load(kb_revision_test_data_file) + kb_revision_test_data_file.close() + with open("test_data/user_message.json", "r") as user_message_test_data_file: user_message_test_data = json.load(user_message_test_data_file) user_message_test_data_file.close() @@ -142,9 +146,14 @@ def navigate_to_homepage(self): # Navigating to a specific given link and waiting for the load state to finish. def navigate_to_link(self, link: str): - self.page.goto(link) + with self.page.expect_navigation() as navigation_info: + self.page.goto(link) + response = navigation_info.value self.wait_for_dom_to_load() + if response.status >= 400: + self.refresh_page() + # Wait for a given timeout def wait_for_given_timeout(self, milliseconds: int): self.page.wait_for_timeout(milliseconds) @@ -220,6 +229,10 @@ def extract_month_day_year_from_string(self, timestamp_str: str) -> str: timestamp = datetime.strptime(timestamp_str, "%b %d, %Y, %I:%M:%S %p") return timestamp.strftime("%b %d, %Y") + def convert_string_to_datetime(self, timestamp_str: str) -> str: + date_object = datetime.strptime(timestamp_str, "%m.%d.%Y") + return date_object.strftime("%B {:d}, %Y").format(date_object.day) + def extract_date_to_digit_format(self, date_str: str) -> int: date = datetime.strptime(date_str, "%b %d, %Y") return int(date.strftime("%m%d%Y")) diff --git a/playwright_tests/flows/explore_help_articles_flows/article_flows/add_kb_article_flow.py b/playwright_tests/flows/explore_articles_flows/article_flows/add_kb_article_flow.py similarity index 93% rename from playwright_tests/flows/explore_help_articles_flows/article_flows/add_kb_article_flow.py rename to playwright_tests/flows/explore_articles_flows/article_flows/add_kb_article_flow.py index 7d00f1acd94..a367aa79d18 100644 --- a/playwright_tests/flows/explore_help_articles_flows/article_flows/add_kb_article_flow.py +++ b/playwright_tests/flows/explore_articles_flows/article_flows/add_kb_article_flow.py @@ -17,12 +17,14 @@ def submit_simple_kb_article(self, article_slug=None, article_category=None, allow_discussion=True, + allow_translations=True, selected_relevancy=True, selected_topics=True, search_summary=None, article_content=None, submit_article=True, - is_template=False) -> dict[str, Any]: + is_template=False, + expiry_date=None) -> dict[str, Any]: self._page.goto(KBArticlePageMessages.CREATE_NEW_KB_ARTICLE_STAGE_URL) kb_article_test_data = super().kb_article_test_data @@ -51,6 +53,9 @@ def submit_simple_kb_article(self, else: super()._select_category_option_by_text(article_category) + if not allow_translations: + super()._check_allow_translations_checkbox() + if selected_relevancy is True: super()._click_on_a_relevant_to_option_checkbox( kb_article_test_data["relevant_to_option"] @@ -90,7 +95,9 @@ def submit_simple_kb_article(self, if article_content is None: super()._add_text_to_content_textarea(kb_article_test_data["article_content"]) - super()._add_text_to_expiry_date_field(kb_article_test_data["expiry_date"]) + if expiry_date is not None: + super()._add_text_to_expiry_date_field(expiry_date) + # We need to evaluate in order to fetch the slug field value slug = self._page.evaluate( 'document.getElementById("id_slug").value' diff --git a/playwright_tests/flows/explore_help_articles_flows/article_flows/add_kb_revision_flow.py b/playwright_tests/flows/explore_articles_flows/article_flows/add_kb_revision_flow.py similarity index 68% rename from playwright_tests/flows/explore_help_articles_flows/article_flows/add_kb_revision_flow.py rename to playwright_tests/flows/explore_articles_flows/article_flows/add_kb_revision_flow.py index dfe554f9d6b..168eb7da452 100644 --- a/playwright_tests/flows/explore_help_articles_flows/article_flows/add_kb_revision_flow.py +++ b/playwright_tests/flows/explore_articles_flows/article_flows/add_kb_revision_flow.py @@ -1,6 +1,10 @@ +from typing import Any + from playwright_tests.core.testutilities import TestUtilities from playwright.sync_api import Page from playwright_tests.pages.explore_help_articles.articles.kb_article_page import KBArticlePage +from playwright_tests.pages.explore_help_articles.articles.kb_article_review_revision_page import \ + KBArticleReviewRevisionPage from playwright_tests.pages.explore_help_articles.articles.kb_article_show_history_page import \ KBArticleShowHistoryPage from playwright_tests.pages.explore_help_articles.articles.kb_edit_article_page import ( @@ -10,7 +14,8 @@ class AddKBArticleRevision(TestUtilities, KBArticlePage, EditKBArticlePage, - KBArticleShowHistoryPage): + KBArticleShowHistoryPage, + KBArticleReviewRevisionPage): def __init__(self, page: Page): super().__init__(page) @@ -21,7 +26,7 @@ def submit_new_kb_revision(self, expiry_date=None, changes_description=None, is_admin=False - ) -> str: + ) -> dict[str, Any]: super()._click_on_edit_article_option() @@ -71,4 +76,26 @@ def submit_new_kb_revision(self, super()._click_edit_article_changes_panel_submit_button() - return super()._get_last_revision_id() + return {"revision_id": super()._get_last_revision_id(), + "changes_description": self.kb_article_test_data['changes_description'] + } + + def approve_kb_revision(self, revision_id: str, + revision_needs_change=False, + ready_for_l10n=False): + super()._click_on_review_revision( + revision_id + ) + super()._click_on_approve_revision_button() + + if revision_needs_change: + if not super()._is_needs_change_checkbox_checked(): + super()._click_on_needs_change_checkbox() + super()._add_text_to_needs_change_comment( + super().kb_revision_test_data['needs_change_message'] + ) + + if ready_for_l10n: + super()._check_ready_for_localization_checkbox() + + super()._click_accept_revision_accept_button() diff --git a/playwright_tests/flows/explore_articles_flows/article_flows/delete_kb_article_flow.py b/playwright_tests/flows/explore_articles_flows/article_flows/delete_kb_article_flow.py new file mode 100644 index 00000000000..a9f47c6d5ae --- /dev/null +++ b/playwright_tests/flows/explore_articles_flows/article_flows/delete_kb_article_flow.py @@ -0,0 +1,21 @@ +from playwright_tests.core.testutilities import TestUtilities +from playwright.sync_api import Page + +from playwright_tests.pages.explore_help_articles.articles.kb_article_page import KBArticlePage +from playwright_tests.pages.explore_help_articles.articles.kb_article_show_history_page import \ + KBArticleShowHistoryPage +from playwright_tests.pages.top_navbar import TopNavbar + + +class DeleteKbArticleFlow(TestUtilities, KBArticleShowHistoryPage, KBArticlePage, TopNavbar): + + def __init__(self, page: Page): + super().__init__(page) + + def delete_kb_article(self): + # If the delete button is not displayed we presume that we are not on the show history page + # Clicking on the 'Show History' page. + if not super()._is_delete_button_displayed(): + super()._click_on_show_history_option() + super()._click_on_delete_this_document_button() + super()._click_on_confirmation_delete_button() diff --git a/playwright_tests/flows/explore_articles_flows/article_flows/edit_article_meta_flow.py b/playwright_tests/flows/explore_articles_flows/article_flows/edit_article_meta_flow.py new file mode 100644 index 00000000000..052becbdd8f --- /dev/null +++ b/playwright_tests/flows/explore_articles_flows/article_flows/edit_article_meta_flow.py @@ -0,0 +1,35 @@ +from playwright_tests.core.testutilities import TestUtilities +from playwright.sync_api import Page + +from playwright_tests.pages.explore_help_articles.articles.kb_edit_article_meta import ( + KBArticleEditMetadata) + + +class EditArticleMetaFlow(TestUtilities, KBArticleEditMetadata): + + def __init__(self, page: Page): + super().__init__(page) + + def edit_article_metadata(self, title=None, needs_change=False, needs_change_comment=False): + if title is not None: + super()._add_text_to_title_field(title) + + # If it needs change we are going to ensure that the needs change checkbox is checked. + if needs_change: + if not super()._is_needs_change_checkbox(): + super()._click_needs_change_checkbox() + # If it needs change with comment we are also adding the comment. + if needs_change_comment: + super()._fill_needs_change_textarea( + super().kb_revision_test_data['needs_change_message'] + ) + # If it doesn't need comment we are ensuring that the textarea field is empty. + else: + super()._fill_needs_change_textarea('') + + # If it doesn't need change we are ensuring that the checkbox is not checked. + else: + if super()._is_needs_change_checkbox(): + super()._click_needs_change_checkbox() + + super()._click_on_save_changes_button() diff --git a/playwright_tests/flows/explore_help_articles_flows/article_flows/post_new_thread_flow.py b/playwright_tests/flows/explore_articles_flows/article_flows/post_new_thread_flow.py similarity index 100% rename from playwright_tests/flows/explore_help_articles_flows/article_flows/post_new_thread_flow.py rename to playwright_tests/flows/explore_articles_flows/article_flows/post_new_thread_flow.py diff --git a/playwright_tests/messages/contribute_messages/con_tools/kb_dashboard_messages.py b/playwright_tests/messages/contribute_messages/con_tools/kb_dashboard_messages.py new file mode 100644 index 00000000000..43e42b779d9 --- /dev/null +++ b/playwright_tests/messages/contribute_messages/con_tools/kb_dashboard_messages.py @@ -0,0 +1,7 @@ +class KBDashboardPageMessages: + KB_LIVE_STATUS = "Live" + GENERAL_NEGATIVE_STATUS = "No" + GENERAL_POSITIVE_STATUS = "Yes" + + def get_kb_not_live_status(self, revision_note: str) -> str: + return f"Review Needed: {revision_note}" diff --git a/playwright_tests/pages/contribute/contributor_tools_pages/kb_dashboard_page.py b/playwright_tests/pages/contribute/contributor_tools_pages/kb_dashboard_page.py new file mode 100644 index 00000000000..7170b57ef20 --- /dev/null +++ b/playwright_tests/pages/contribute/contributor_tools_pages/kb_dashboard_page.py @@ -0,0 +1,71 @@ +from playwright_tests.core.basepage import BasePage +from playwright.sync_api import Page, Locator + + +class KBDashboard(BasePage): + # Top-level filter locators + __products_filter_button = ("//article[@id='localize']/div[@class='mzp-c-menu-list " + "featured-dropdown is-details']//button") + __products_filter_complete_overview = "//div[@id='product-selector']/select" + __filter_by_type = "//div[@class='table-filters']//select" + __filter_by_type_complete_overview = "//select[@name='category']" + __subscribe_button = "//div[@id='doc-watch']/button" + __complete_overview_link = "//div[@class='table-footer']/a" + + def __init__(self, page: Page): + super().__init__(page) + + # KB Dashboard actions + def _get_a_particular_article_title_locator(self, article_name: str) -> Locator: + xpath = f"//td/a[text()='{article_name}']" + return super()._get_element_locator(xpath) + + def _click_on_article_title(self, article_name: str): + xpath = f"//td/a[text()='{article_name}']" + super()._click(xpath) + + def _get_a_particular_article_status(self, article_name: str) -> str: + xpath = (f"//td/a[text()='{article_name}']/../following-sibling::td[contains(@class," + f"'status ')]") + return super()._get_text_of_element(xpath) + + def _get_needs_update_status(self, article_name: str) -> str: + xpath = (f"//td/a[text()='{article_name}']/../following-sibling::td[contains(@class," + f"'needs-update')]") + return super()._get_text_of_element(xpath) + + def _is_needs_change_empty(self, article_name: str) -> bool: + xpath = (f"//td/a[text()='{article_name}']/../following-sibling::td[contains(@class," + f"'needs-update')]") + return super()._is_element_empty(xpath) + + def _get_ready_for_l10n_status(self, article_name: str) -> str: + xpath = (f"//td/a[text()='{article_name}']/../following-sibling::td[contains(@class," + f"'ready-for-l10n')]") + return super()._get_text_of_element(xpath) + + def _get_stale_status(self, article_name: str) -> str: + xpath = (f"//td/a[text()='{article_name}']/../following-sibling::td[contains(@class," + f"'stale ')]") + return super()._get_text_of_element(xpath) + + def _is_stale_status_empty(self, article_name: str) -> bool: + xpath = (f"//td/a[text()='{article_name}']/../following-sibling::td[contains(@class," + f"'stale ')]") + return super()._is_element_empty(xpath) + + def _get_existing_expiry_date(self, article_name: str) -> str: + xpath = f"//td/a[text()='{article_name}']/../following-sibling::td/time" + return super()._get_text_of_element(xpath) + + def _get_expiry_date_locator(self, article_name: str) -> Locator: + xpath = f"//td/a[text()='{article_name}']/../following-sibling::td/time" + return super()._get_element_locator(xpath) + + def _click_on_show_translations_option(self, article_name: str): + xpath = (f"//td/a[text()='{article_name}']/../following-sibling::td/a[contains(text()," + f"'Show translations')]") + super()._click(xpath) + + def _click_on_the_complete_overview_link(self): + super()._click(self.__complete_overview_link) diff --git a/playwright_tests/pages/explore_help_articles/articles/kb_article_review_revision_page.py b/playwright_tests/pages/explore_help_articles/articles/kb_article_review_revision_page.py index 12fa73990eb..3daf48074d8 100644 --- a/playwright_tests/pages/explore_help_articles/articles/kb_article_review_revision_page.py +++ b/playwright_tests/pages/explore_help_articles/articles/kb_article_review_revision_page.py @@ -26,14 +26,20 @@ class KBArticleReviewRevisionPage(BasePage): __revision_rendered_html_header = "//h3[text()='Revision rendered html:']" __revision_rendered_html_content = "//div[@id='doc-content']/p" + __defer_revision_button = "//button[@id='btn-reject']" __approve_revision_button = "//button[@id='btn-approve']" + # Defer revision modal + __defer_button = "//form[@id='reject-modal']//button" + __cancel_defer = "//form[@id='reject-modal']//a" + # Approve revision modal __accept_revision_modal_header = "//div[@class='kbox-title']" # Need to add locators for approving own edit revision warning. __ready_for_localization_modal_checkbox = "//input[@id='id_is_ready_for_localization']" __needs_change_modal_checkbox = "//input[@id='id_needs_change']" + __needs_change_comment_textarea = "//textarea[@id='id_needs_change_comment']" __modal_accept_button = "//button[text()='Accept']" __modal_cancel_button = "//form[@id='approve-modal']//a[text()='Cancel']" @@ -87,6 +93,15 @@ def _is_revision_rendered_html_header_visible(self) -> bool: def _get_revision_rendered_html_content(self) -> str: return super()._get_text_of_element(self.__revision_rendered_html_content) + def _click_on_defer_revision_button(self): + super()._click(self.__defer_revision_button) + + def _click_on_defer_confirm_button(self): + super()._click(self.__defer_button) + + def _click_on_cancel_defer_button(self): + super()._click(self.__cancel_defer) + def _click_on_approve_revision_button(self): super()._click(self.__approve_revision_button) @@ -99,3 +114,12 @@ def _click_accept_revision_accept_button(self): def _check_ready_for_localization_checkbox(self): super()._click(self.__ready_for_localization_modal_checkbox) + + def _is_needs_change_checkbox_checked(self) -> bool: + return super()._is_checkbox_checked(self.__needs_change_modal_checkbox) + + def _click_on_needs_change_checkbox(self): + super()._click(self.__needs_change_modal_checkbox) + + def _add_text_to_needs_change_comment(self, text: str): + super()._fill(self.__needs_change_comment_textarea, text) diff --git a/playwright_tests/pages/explore_help_articles/articles/kb_article_show_history_page.py b/playwright_tests/pages/explore_help_articles/articles/kb_article_show_history_page.py index 6d21260763c..130d06d49cc 100644 --- a/playwright_tests/pages/explore_help_articles/articles/kb_article_show_history_page.py +++ b/playwright_tests/pages/explore_help_articles/articles/kb_article_show_history_page.py @@ -8,6 +8,7 @@ class KBArticleShowHistoryPage(BasePage): __show_history_category_link = "//dt[text()='Category:']/following-sibling::dd/a" __show_history_revision_history_for = ("//dt[text()='Revision history " "for:']/following-sibling::dd[1]") + __ready_for_l10_modal_submit_button = "//button[@id='submit-l10n']" # Document contributors locators __show_history_page_banner = "//li[@class='mzp-c-notification-bar mzp-t-success']/p" @@ -54,6 +55,13 @@ def _click_on_a_particular_revision_editor(self, revision_id: str, username: str xpath = f"//tr[@id='{revision_id}']//a[contains(text(),'{username}')]" super()._click(xpath) + def _click_on_ready_for_l10n_option(self, revision_id: str): + xpath = f"//tr[@id='{revision_id}']/td[@class='l10n']/a" + super()._click(xpath) + + def _click_on_submit_l10n_readiness_button(self): + super()._click(self.__ready_for_l10_modal_submit_button) + # Delete document actions. def _click_on_delete_this_document_button(self): super()._click(self.__delete_this_document_button) @@ -61,6 +69,9 @@ def _click_on_delete_this_document_button(self): def _get_delete_this_document_button_locator(self) -> Locator: return super()._get_element_locator(self.__delete_this_document_button) + def _is_delete_button_displayed(self) -> bool: + return super()._is_element_visible(self.__delete_this_document_button) + def _click_on_confirmation_delete_button(self): super()._click(self.__delete_this_document_confirmation_delete_button) diff --git a/playwright_tests/pages/explore_help_articles/articles/kb_edit_article_metadata.py b/playwright_tests/pages/explore_help_articles/articles/kb_edit_article_meta.py similarity index 94% rename from playwright_tests/pages/explore_help_articles/articles/kb_edit_article_metadata.py rename to playwright_tests/pages/explore_help_articles/articles/kb_edit_article_meta.py index a942d7ff6bd..d499ade3aca 100644 --- a/playwright_tests/pages/explore_help_articles/articles/kb_edit_article_metadata.py +++ b/playwright_tests/pages/explore_help_articles/articles/kb_edit_article_meta.py @@ -15,6 +15,7 @@ class KBArticleEditMetadata(BasePage): __obsolete_checkbox = "//input[@id='id_is_archived']" __allow_discussion_checkbox = "//input[@id='id_allow_discussion']" __needs_change_checkbox = "//input[@id='id_needs_change']" + __needs_change_textarea = "//textarea[@id='id_needs_change_comment']" __save_changes_button = "//button[text()='Save']" def __init__(self, page: Page): @@ -83,11 +84,14 @@ def _is_allow_discussion_checkbox_checked(self) -> bool: def _click_on_allow_discussion_on_article_checkbox(self): super()._click(self.__allow_discussion_checkbox) - def _is_needs_change_checkbox_checked(self) -> bool: + def _is_needs_change_checkbox(self) -> bool: return super()._is_checkbox_checked(self.__needs_change_checkbox) def _click_needs_change_checkbox(self): super()._click(self.__needs_change_checkbox) + def _fill_needs_change_textarea(self, text: str): + super()._fill(self.__needs_change_textarea, text) + def _click_on_save_changes_button(self): super()._click(self.__save_changes_button) diff --git a/playwright_tests/pages/explore_help_articles/articles/submit_kb_article_page.py b/playwright_tests/pages/explore_help_articles/articles/submit_kb_article_page.py index d2ed7a6e299..ef43607dad3 100644 --- a/playwright_tests/pages/explore_help_articles/articles/submit_kb_article_page.py +++ b/playwright_tests/pages/explore_help_articles/articles/submit_kb_article_page.py @@ -10,6 +10,7 @@ class SubmitKBArticlePage(BasePage): __kb_article_category_select = "//select[@id='id_category']" __kb_article_is_localizable_checkbox = "//input[@id='id_is_localizable']" __kb_article_allow_discussions_on_article = "//label[@for='id_allow_discussion']" + __kb_article_allow_translations = "//label[@for='id_is_localizable']" __kb_article_search_for_related_documents = "//input[@id='search-related']" __kb_article_keyword_input = "//input[@id='id_keywords']" __kb_article_search_result_summary_textarea = "//textarea[@id='id_summary']" @@ -147,3 +148,6 @@ def _check_allow_discussion_on_article_checkbox(self): def _is_allow_discussion_on_article_checkbox_checked(self) -> bool: return super()._is_checkbox_checked(self.__kb_article_allow_discussions_on_article) + + def _check_allow_translations_checkbox(self): + super()._click(self.__kb_article_allow_translations) diff --git a/playwright_tests/pages/sumo_pages.py b/playwright_tests/pages/sumo_pages.py index 84433663a08..001928bd003 100644 --- a/playwright_tests/pages/sumo_pages.py +++ b/playwright_tests/pages/sumo_pages.py @@ -1,17 +1,22 @@ from playwright.sync_api import Page from playwright_tests.flows.ask_a_question_flows.aaq_flows.aaq_flow import AAQFlow -from playwright_tests.flows.explore_help_articles_flows.article_flows.add_kb_article_flow import ( +from playwright_tests.flows.explore_articles_flows.article_flows.add_kb_article_flow import ( AddKbArticleFlow) from playwright_tests.flows.auth_flows.auth_flow import AuthFlowPage -from playwright_tests.flows.explore_help_articles_flows.article_flows.add_kb_revision_flow import \ +from playwright_tests.flows.explore_articles_flows.article_flows.add_kb_revision_flow import \ AddKBArticleRevision -from playwright_tests.flows.explore_help_articles_flows.article_flows.post_new_thread_flow import \ +from playwright_tests.flows.explore_articles_flows.article_flows.delete_kb_article_flow import \ + DeleteKbArticleFlow +from playwright_tests.flows.explore_articles_flows.article_flows.edit_article_meta_flow import \ + EditArticleMetaFlow +from playwright_tests.flows.explore_articles_flows.article_flows.post_new_thread_flow import \ PostNewDiscussionThreadFlow from playwright_tests.flows.messaging_system_flows.messaging_system_flow import ( MessagingSystemFlows) from playwright_tests.flows.user_profile_flows.edit_profile_data_flow import EditProfileDataFlow from playwright_tests.pages.ask_a_question.aaq_pages.aaq_form_page import AAQFormPage +from playwright_tests.pages.contribute.contributor_tools_pages.kb_dashboard_page import KBDashboard from playwright_tests.pages.contribute.contributor_tools_pages.moderate_forum_content import \ ModerateForumContent from playwright_tests.pages.contribute.contributor_tools_pages.recent_revisions_page import \ @@ -26,7 +31,7 @@ from playwright_tests.pages.explore_help_articles.articles.kb_article_show_history_page import ( KBArticleShowHistoryPage) from playwright_tests.pages.auth_page import AuthPage -from playwright_tests.pages.explore_help_articles.articles.kb_edit_article_metadata import \ +from playwright_tests.pages.explore_help_articles.articles.kb_edit_article_meta import \ KBArticleEditMetadata from playwright_tests.pages.explore_help_articles.articles.kb_edit_article_page import \ EditKBArticlePage @@ -142,6 +147,7 @@ def __init__(self, page: Page): self.product_support_forum = ProductSupportForum(page) # Dashboard pages. + self.kb_dashboard_page = KBDashboard(page) self.recent_revisions_page = RecentRevisions(page) # Moderate Forum Page @@ -165,5 +171,11 @@ def __init__(self, page: Page): # KB article revision Flow self.kb_article_revision_flow = AddKBArticleRevision(page) + # KB article deletion Flow + self.kb_article_deletion_flow = DeleteKbArticleFlow(page) + # KB article discussion Flow self.post_kb_discussion_thread_flow = PostNewDiscussionThreadFlow(page) + + # KB article edit metadata Flow + self.edit_article_metadata_flow = EditArticleMetaFlow(page) diff --git a/playwright_tests/pages/top_navbar.py b/playwright_tests/pages/top_navbar.py index 6bd5d411eb8..219071e1272 100644 --- a/playwright_tests/pages/top_navbar.py +++ b/playwright_tests/pages/top_navbar.py @@ -29,6 +29,8 @@ class TopNavbar(BasePage): "Forum Content']") __recent_revisions_option = ("//ul[@class='mzp-c-menu-item-list sumo-nav--sublist']//a[text(" ")='Recent Revisions']") + __dashboards_option = ("//ul[@class='mzp-c-menu-item-list sumo-nav--sublist']//a[text(" + ")='Dashboards']") # Sign in button __signin_signup_button = "//div[@id='profile-navigation']//a[@data-event-label='Sign In']" @@ -69,6 +71,10 @@ def _click_on_recent_revisions_option(self): super()._hover_over_element(self.__contributor_tools_option) super()._click(self.__recent_revisions_option) + def _click_on_dashboards_option(self): + super()._hover_over_element(self.__contributor_tools_option) + super()._click(self.__dashboards_option) + # Explore our Help Articles actions. def _click_on_explore_our_help_articles_option(self): super()._hover_over_element(self.__get_help_option) diff --git a/playwright_tests/pytest.ini b/playwright_tests/pytest.ini index 63e795bf67b..25b84f9cd93 100644 --- a/playwright_tests/pytest.ini +++ b/playwright_tests/pytest.ini @@ -24,3 +24,4 @@ markers = afterThreadTests: Article threads tests teardown. kbArticleShowHistory: Tests belonging to the kb article show history section. recentRevisionsDashboard: Tests belonging to the recent revisions dashboard. + kbDashboard: Tests belonging to the KB dashboard. diff --git a/playwright_tests/test_data/add_kb_article.json b/playwright_tests/test_data/add_kb_article.json index d847c755339..455606729e8 100644 --- a/playwright_tests/test_data/add_kb_article.json +++ b/playwright_tests/test_data/add_kb_article.json @@ -20,6 +20,7 @@ "article_heading_two": "==Heading two==", "article_heading_three": "===Heading three===", "expiry_date": "05.02.2050", + "old_expiry_date": "05.02.2002", "updated_expiry_date": "07.05.2051", "changes_description": "Automation description test" } diff --git a/playwright_tests/test_data/general_data.json b/playwright_tests/test_data/general_data.json index 23f67f5c764..ade4f723585 100644 --- a/playwright_tests/test_data/general_data.json +++ b/playwright_tests/test_data/general_data.json @@ -73,6 +73,7 @@ "Mozilla Account": "https://support.allizom.org/en-US/questions/new/mozilla-account" }, "dashboard_links": { - "recent_revisions": "https://support.allizom.org/en-US/kb/revisions" + "recent_revisions": "https://support.allizom.org/en-US/kb/revisions", + "kb_overview": "https://support.allizom.org/en-US/contributors/kb-overview" } } diff --git a/playwright_tests/test_data/kb_revision.json b/playwright_tests/test_data/kb_revision.json new file mode 100644 index 00000000000..5f4733c2ade --- /dev/null +++ b/playwright_tests/test_data/kb_revision.json @@ -0,0 +1,3 @@ +{ + "needs_change_message": "Automation needs change message" +} 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 new file mode 100644 index 00000000000..53d83aea854 --- /dev/null +++ b/playwright_tests/tests/contribute_tests/dashboards_tests/test_kb_dashboard.py @@ -0,0 +1,649 @@ +import pytest +import pytest_check as check +from playwright.sync_api import expect +from playwright_tests.core.testutilities import TestUtilities +from playwright_tests.messages.contribute_messages.con_tools.kb_dashboard_messages import ( + KBDashboardPageMessages) + + +class TestKBDashboard(TestUtilities, KBDashboardPageMessages): + + # C891357 + @pytest.mark.kbDashboard + def test_unreviewed_articles_visibility_in_kb_dashboard(self): + self.logger.info("Signing in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Create a new simple article") + article_details = self.sumo_pages.submit_kb_article_flow.submit_simple_kb_article() + + self.sumo_pages.kb_article_page._click_on_article_option() + article_url = self.get_page_url() + + self.logger.info("Navigating to the kb dashboards") + self.sumo_pages.top_navbar._click_on_dashboards_option() + + self.logger.info("Clicking on the 'Complete overview' option") + self.sumo_pages.kb_dashboard_page._click_on_the_complete_overview_link() + + self.logger.info("Verifying that we are redirected to the correct page") + expect( + self.page + ).to_have_url(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct live status is displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_status( + article_details['article_title'] + ).strip(), + self.get_kb_not_live_status( + revision_note=article_details['article_review_description'] + ) + ) + + self.logger.info("Signing out and verifying that the article is not displayed since it " + "is not live yet") + self.delete_cookies() + expect( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_title_locator( + article_details['article_title'] + ) + ).to_be_hidden() + + self.logger.info("Navigating to the homepage and performing the sign in step since the " + "kb overview takes quite a bit to refresh/load") + self.sumo_pages.top_navbar._click_on_sumo_nav_logo() + + self.logger.info("Signing in with a non-admin account and verifying that the article is " + "not displayed since it is not live yet") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_13"] + )) + + self.logger.info("Navigating to the kb overview") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + expect( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_title_locator( + article_details['article_title'] + ) + ).to_be_hidden() + + self.sumo_pages.top_navbar._click_on_sumo_nav_logo() + self.logger.info("Signing back in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Navigating to the kb overview") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Clicking on the article title") + self.sumo_pages.kb_dashboard_page._click_on_article_title( + article_details['article_title'] + ) + + self.logger.info("Verifying that the user is redirected to the correct kb page") + expect( + self.page + ).to_have_url(article_url) + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_page._click_on_show_history_option() + revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) + + self.logger.info("Navigating to the kb overview") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct status is displayed") + + self.logger.info("Verifying that the correct live status is displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_status( + article_details['article_title'] + ).strip(), + self.KB_LIVE_STATUS + ) + + self.logger.info("Signing out and verifying that the article is visible") + self.delete_cookies() + expect( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_title_locator( + article_details['article_title'] + ) + ).to_be_visible() + + self.sumo_pages.top_navbar._click_on_sumo_nav_logo() + self.logger.info("Signing in with a non-admin user and verifying that the article is " + "visible") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_13"] + )) + + self.logger.info("Navigating to the kb overview") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + expect( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_title_locator( + article_details['article_title'] + ) + ).to_be_visible() + + self.sumo_pages.top_navbar._click_on_sumo_nav_logo() + + self.logger.info("Signing back with an admin account and deleting the article") + self.logger.info("Signing back in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Navigating to the kb overview") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Clicking on the article title") + self.sumo_pages.kb_dashboard_page._click_on_article_title( + article_details['article_title'] + ) + + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() + + # C2266376 + @pytest.mark.kbDashboard + def test_kb_dashboard_articles_status(self): + self.logger.info("Signing in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Create a new simple article") + article_details = self.sumo_pages.submit_kb_article_flow.submit_simple_kb_article() + + article_url = self.get_page_url() + + revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) + + self.logger.info("Creating a new revision for the document") + second_revision_details = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision() + + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct status is displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_status( + article_details['article_title'] + ).strip(), + self.get_kb_not_live_status( + revision_note=second_revision_details['changes_description'] + ) + ) + + self.logger.info("Navigating back to the article history and deleting the revision") + self.navigate_to_link(article_url) + + self.sumo_pages.kb_article_show_history_page._click_on_delete_revision_button( + second_revision_details['revision_id'] + ) + + self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + + self.logger.info("Navigating back to the kb dashboard and verifying that the live status " + "is displayed") + + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + check.equal( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_status( + article_details['article_title'] + ).strip(), + self.KB_LIVE_STATUS + ) + + self.logger.info("Clicking on the article title") + self.sumo_pages.kb_dashboard_page._click_on_article_title( + article_details['article_title'] + ) + + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() + + @pytest.mark.kbDashboard + def test_kb_dashboard_revision_deferred_status(self): + self.logger.info("Signing in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Create a new simple article") + article_details = self.sumo_pages.submit_kb_article_flow.submit_simple_kb_article() + + article_url = self.get_page_url() + + revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) + + self.logger.info("Creating a new revision for the document") + second_revision_details = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision() + + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct status is displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_status( + article_details['article_title'] + ), + self.get_kb_not_live_status(second_revision_details['changes_description']) + ) + + self.logger.info("Navigating back to the article history page") + self.navigate_to_link(article_url) + + self.logger.info("Deferring the revision") + self.sumo_pages.kb_article_show_history_page._click_on_review_revision( + second_revision_details['revision_id'] + ) + + self.sumo_pages.kb_article_review_revision_page._click_on_defer_revision_button() + self.sumo_pages.kb_article_review_revision_page._click_on_defer_confirm_button() + + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + check.equal( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_status( + article_details['article_title'] + ), + self.KB_LIVE_STATUS + ) + + self.logger.info("Navigating back to the article page") + self.navigate_to_link(article_url) + + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() + + @pytest.mark.kbDashboard + def test_kb_dashboard_needs_update_when_reviewing_a_revision(self): + self.logger.info("Signing in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Create a new simple article") + article_details = self.sumo_pages.submit_kb_article_flow.submit_simple_kb_article() + + article_url = self.get_page_url() + + revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) + + self.logger.info("Creating a new revision for the document") + second_revision_details = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision( + ) + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision( + second_revision_details['revision_id'], revision_needs_change=True + ) + + self.logger.info("Navigating to the kb dashboard overview") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + check.equal( + self.sumo_pages.kb_dashboard_page._get_needs_update_status( + article_details['article_title'] + ).strip(), + super().kb_revision_test_data['needs_change_message'] + ) + + self.logger.info("Navigating back to the article page") + self.navigate_to_link(article_url) + + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() + + # C2266377 + @pytest.mark.kbDashboard + def test_kb_dashboard_needs_update_edit_metadata(self): + self.logger.info("Signing in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Create a new simple article") + article_details = self.sumo_pages.submit_kb_article_flow.submit_simple_kb_article() + + article_url = self.get_page_url() + + revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) + + self.logger.info("Clicking on the 'Edit Article Metadata' option") + self.sumo_pages.kb_article_page._click_on_edit_article_metadata() + + self.logger.info("Enabling Needs Change with comment") + self.sumo_pages.edit_article_metadata_flow.edit_article_metadata( + needs_change=True, needs_change_comment=True + ) + + self.logger.info("Navigating to the complete dashboard list") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct needs change status is displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_needs_update_status( + article_details['article_title'] + ).strip(), + super().kb_revision_test_data['needs_change_message'] + ) + + self.logger.info("Navigating back to the article") + self.navigate_to_link(article_url) + + self.logger.info("Clicking on the 'Edit Article Metadata' option") + self.sumo_pages.kb_article_page._click_on_edit_article_metadata() + + self.logger.info("Removing the comment from the needs change comment") + self.sumo_pages.edit_article_metadata_flow.edit_article_metadata(needs_change=True) + + self.logger.info("Navigating to the complete dashboard list") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct needs change status is displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_needs_update_status( + article_details['article_title'] + ).strip(), + KBDashboardPageMessages.GENERAL_POSITIVE_STATUS + ) + + self.logger.info("Navigating back to the article") + self.navigate_to_link(article_url) + + self.logger.info("Clicking on the 'Edit Article Metadata' option") + self.sumo_pages.kb_article_page._click_on_edit_article_metadata() + + self.logger.info("Editing the article metadata by removing the needs change updates") + self.sumo_pages.edit_article_metadata_flow.edit_article_metadata() + + self.logger.info("Navigating to the complete dashboard list") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + check.is_true( + self.sumo_pages.kb_dashboard_page._is_needs_change_empty( + article_details['article_title'] + ) + ) + + self.logger.info("Deleting the article") + self.navigate_to_link(article_url) + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() + + # C2266378 + @pytest.mark.kbDashboard + def test_ready_for_l10n_kb_dashboard_revision_approval(self): + self.logger.info("Signing in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Create a new simple article") + article_details = self.sumo_pages.submit_kb_article_flow.submit_simple_kb_article() + + article_url = self.get_page_url() + + revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() + + self.logger.info("Approving the revision and marking it as ready for l10n") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision( + revision_id=revision_id, ready_for_l10n=True) + + self.logger.info("Navigating to the kb dashboard overview page") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct l10n status is displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_ready_for_l10n_status( + article_details['article_title'] + ), + KBDashboardPageMessages.GENERAL_POSITIVE_STATUS + ) + + self.logger.info("Navigating back to the article") + self.navigate_to_link(article_url) + + self.logger.info("Deleting the article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() + + # C2266378 + @pytest.mark.kbDashboard + def test_ready_for_l10n_kb_dashboard_revision_l10n_status(self): + self.logger.info("Signing in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Create a new simple article") + article_details = self.sumo_pages.submit_kb_article_flow.submit_simple_kb_article() + + article_url = self.get_page_url() + + revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id=revision_id) + + self.logger.info("Navigating to the kb dashboard overview page") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct l10n status displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_ready_for_l10n_status( + article_details['article_title'] + ), + KBDashboardPageMessages.GENERAL_NEGATIVE_STATUS + ) + + self.logger.info("Navigating back to the article page") + self.navigate_to_link(article_url) + + self.logger.info("Mark the revision as ready for l10n") + self.sumo_pages.kb_article_show_history_page._click_on_ready_for_l10n_option(revision_id) + self.sumo_pages.kb_article_show_history_page._click_on_submit_l10n_readiness_button() + + self.logger.info("Navigating to the kb dashboard overview page") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct l10n status is displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_ready_for_l10n_status( + article_details['article_title'] + ), + KBDashboardPageMessages.GENERAL_POSITIVE_STATUS + ) + + self.logger.info("Navigating to the article") + self.navigate_to_link(article_url) + + self.logger.info("Deleting the article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() + + # C2266378 + @pytest.mark.kbDashboard + def test_article_translation_not_allowed_kb_dashboard(self): + self.logger.info("Signing in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Create a new simple article") + article_details = self.sumo_pages.submit_kb_article_flow.submit_simple_kb_article( + allow_translations=False + ) + + article_url = self.get_page_url() + + revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id=revision_id) + + self.logger.info("Navigating to the kb dashboard overview page") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct l10n status displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_ready_for_l10n_status( + article_details['article_title'] + ), + KBDashboardPageMessages.GENERAL_NEGATIVE_STATUS + ) + + self.logger.info("Navigating to the article") + self.navigate_to_link(article_url) + + self.logger.info("Deleting the article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() + + # C2266379, C2266380 + @pytest.mark.kbDashboard + def test_article_stale_kb_dashboard(self): + self.logger.info("Signing in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Create a new simple article by adding an old expiry date") + article_details = self.sumo_pages.submit_kb_article_flow.submit_simple_kb_article( + expiry_date=self.kb_article_test_data['old_expiry_date'] + ) + + article_url = self.get_page_url() + + revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) + + self.logger.info("Navigating to the kb dashboard overview page") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct stale status displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_stale_status( + article_details['article_title'] + ), + KBDashboardPageMessages.GENERAL_POSITIVE_STATUS + ) + + self.logger.info("Verifying that the correct date is displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_existing_expiry_date( + article_details['article_title'] + ), + self.convert_string_to_datetime( + self.kb_article_test_data['old_expiry_date'] + ) + ) + + self.logger.info("Navigating back to the article") + self.navigate_to_link(article_url) + + self.logger.info("Creating a new revision with non-stale expiry date") + second_revision_details = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision( + expiry_date=self.kb_article_test_data['expiry_date'] + ) + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision( + second_revision_details['revision_id'] + ) + + self.logger.info("Navigating to the complete dashboard list") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct stale status is displayed") + check.is_true( + self.sumo_pages.kb_dashboard_page._is_stale_status_empty( + article_details['article_title'] + ) + ) + + self.logger.info("Verifying that the correct date is displayed") + check.equal( + self.sumo_pages.kb_dashboard_page._get_existing_expiry_date( + article_details['article_title'] + ), + self.convert_string_to_datetime( + self.kb_article_test_data['expiry_date'] + ) + ) + + self.logger.info("Navigating to the article") + self.navigate_to_link(article_url) + + self.logger.info("Deleting the article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() + + @pytest.mark.kbDashboard + def test_article_title_update(self): + self.logger.info("Signing in with the admin account") + self.start_existing_session(super().username_extraction_from_email( + self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] + )) + + self.logger.info("Create a new simple article") + article_details = self.sumo_pages.submit_kb_article_flow.submit_simple_kb_article() + + article_url = self.get_page_url() + + revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() + + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id=revision_id) + + self.logger.info("Navigating to the kb dashboard overview page") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct title is displayed") + expect( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_title_locator( + article_details['article_title'] + ) + ).to_be_visible() + + self.logger.info("Navigating back to the article") + self.navigate_to_link(article_url) + + self.logger.info("Editing the article metadata by changing the title") + self.sumo_pages.kb_article_page._click_on_edit_article_metadata() + + new_article_title = "Updated " + article_details['article_title'] + self.sumo_pages.edit_article_metadata_flow.edit_article_metadata(title=new_article_title) + + self.logger.info("Navigating back to the kb dashboard") + self.navigate_to_link(super().general_test_data['dashboard_links']['kb_overview']) + + self.logger.info("Verifying that the correct title is displayed") + expect( + self.sumo_pages.kb_dashboard_page._get_a_particular_article_title_locator( + new_article_title + ) + ).to_be_visible() + + self.logger.info("Navigating to the article") + self.navigate_to_link(article_url) + + self.logger.info("Deleting the article") + self.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 d050d42433d..dde4990d174 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 @@ -142,7 +142,7 @@ def test_second_revisions_availability(self): username = self.sumo_pages.top_navbar._get_text_of_logged_in_username() self.logger.info("Creating a new revision for the article") - second_revision_id = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision() + second_revision_details = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision() self.logger.info("Navigating to the Recent Revisions dashboard and verifying that own " "revision is visible") @@ -194,7 +194,7 @@ def test_second_revisions_availability(self): self.logger.info("Clicking on the 'Review' option") self.sumo_pages.kb_article_show_history_page._click_on_review_revision( - second_revision_id + second_revision_details['revision_id'] ) self.logger.info("Click on 'Approve Revision' button") @@ -320,7 +320,7 @@ def test_recent_revisions_dashboard_links(self): username = self.sumo_pages.top_navbar._get_text_of_logged_in_username() self.logger.info("Creating a new revision for the article") - second_revision_id = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision() + second_revision_details = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision() self.logger.info("Navigating to the Recent Revisions dashboard") self.sumo_pages.top_navbar._click_on_recent_revisions_option() @@ -342,13 +342,15 @@ def test_recent_revisions_dashboard_links(self): self.page ).to_have_url( article_url + KBArticleRevision. - KB_REVISION_PREVIEW + str(self.number_extraction_from_string(second_revision_id)) + KB_REVISION_PREVIEW + str(self.number_extraction_from_string( + second_revision_details['revision_id'] + )) ) self.logger.info("Verifying that the revision id is the correct one") check.equal( self.sumo_pages.kb_article_preview_revision_page._get_preview_revision_id_text(), - str(self.number_extraction_from_string(second_revision_id)) + str(self.number_extraction_from_string(second_revision_details['revision_id'])) ) self.logger.info("Navigating back") 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 fe8d18be01b..52919899f4c 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 @@ -165,11 +165,8 @@ def test_kb_article_removal(self): ['article_slug'] + KBArticlePageMessages.KB_ARTICLE_HISTORY_URL_ENDPOINT ) - self.logger.info("Clicking on the 'Delete article' button") - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - - self.logger.info("Clicking on the 'Delete' button") - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + self.logger.info("Deleting the article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() self.logger.info("Verifying that the article was successfully deleted by navigating to " "the article") @@ -237,14 +234,8 @@ def test_kb_article_category_link_and_header(self): self.logger.info("Navigating back") self.navigate_back() - self.logger.info("Clicking on the 'Show History' option") - self.sumo_pages.kb_article_page._click_on_show_history_option() - - self.logger.info("Clicking on the 'Delete article' button") - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - - self.logger.info("Clicking on the 'Delete' button") - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + self.logger.info("Deleting the article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() # C2101637, C2489543, C2102169 @pytest.mark.kbArticleShowHistory @@ -278,16 +269,9 @@ def test_kb_article_contributor_removal(self): self.sumo_pages.kb_article_page._click_on_show_history_option() revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() - self.logger.info("Clicking on the 'Review' option") - self.sumo_pages.kb_article_show_history_page._click_on_review_revision( - revision_id - ) - self.logger.info("Click on 'Approve Revision' button") - self.sumo_pages.kb_article_review_revision_page._click_on_approve_revision_button() - - self.logger.info("Clicking on the 'Accept' button") - self.sumo_pages.kb_article_review_revision_page._click_accept_revision_accept_button() + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) self.logger.info("Verifying that the username which created the revision is added inside " "the 'Contributors' list") @@ -327,7 +311,8 @@ def test_kb_article_contributor_removal(self): username_two = self.sumo_pages.top_navbar._get_text_of_logged_in_username() self.logger.info("Creating a new revision for the document") - self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision() + second_revision_details = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision( + ) self.logger.info("Verifying that the 'Edit Contributors' option is not displayed for " "users which don't have the necessary permissions") @@ -396,19 +381,11 @@ def test_kb_article_contributor_removal(self): self.sumo_pages.kb_article_show_history_page._get_list_of_all_contributors() ) - revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() - - self.logger.info("Clicking on the 'Review' option") - self.sumo_pages.kb_article_show_history_page._click_on_review_revision( - revision_id + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision( + second_revision_details['revision_id'] ) - self.logger.info("Click on 'Approve Revision' button") - self.sumo_pages.kb_article_review_revision_page._click_on_approve_revision_button() - - self.logger.info("Clicking on the 'Accept' button") - self.sumo_pages.kb_article_review_revision_page._click_accept_revision_accept_button() - self.logger.info("Verifying that second username is displayed inside the 'Contributors' " "list") check.is_in( @@ -501,14 +478,8 @@ def test_kb_article_contributor_removal(self): self.sumo_pages.kb_article_page._get_list_of_kb_article_contributors() ) - self.logger.info("Navigating back to the 'Show History page'") - self.sumo_pages.kb_article_page._click_on_show_history_option() - - self.logger.info("Clicking on the 'Delete article' button") - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - - self.logger.info("Clicking on the 'Delete' button") - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + self.logger.info("Deleting the article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() # C2101638 @pytest.mark.kbArticleShowHistory @@ -563,14 +534,8 @@ def test_contributors_can_be_manually_added(self): self.sumo_pages.kb_article_page._get_list_of_kb_article_contributors() ) - self.logger.info("Navigating back to the 'Show History page'") - self.sumo_pages.kb_article_page._click_on_show_history_option() - - self.logger.info("Clicking on the 'Delete article' button") - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - - self.logger.info("Clicking on the 'Delete' button") - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() # C2101634, C2489553 @pytest.mark.kbArticleShowHistory @@ -592,16 +557,9 @@ def test_kb_article_contributor_profile_access(self): self.sumo_pages.kb_article_page._click_on_show_history_option() revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() - self.logger.info("Clicking on the 'Review' option") - self.sumo_pages.kb_article_show_history_page._click_on_review_revision( - revision_id - ) - - self.logger.info("Click on 'Approve Revision' button") - self.sumo_pages.kb_article_review_revision_page._click_on_approve_revision_button() - self.logger.info("Clicking on the 'Accept' button") - self.sumo_pages.kb_article_review_revision_page._click_accept_revision_accept_button() + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) self.logger.info("Signing in with a non-Admin account") self.start_existing_session(super().username_extraction_from_email( @@ -611,26 +569,19 @@ def test_kb_article_contributor_profile_access(self): username_two = self.sumo_pages.top_navbar._get_text_of_logged_in_username() self.logger.info("Creating a new revision for the document") - self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision() + second_revision_details = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision( + ) self.logger.info("Signing in with a normal account") self.start_existing_session(super().username_extraction_from_email( self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] )) - revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() - - self.logger.info("Clicking on the 'Review' option") - self.sumo_pages.kb_article_show_history_page._click_on_review_revision( - revision_id + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision( + second_revision_details['revision_id'] ) - self.logger.info("Click on 'Approve Revision' button") - self.sumo_pages.kb_article_review_revision_page._click_on_approve_revision_button() - - self.logger.info("Clicking on the 'Accept' button") - self.sumo_pages.kb_article_review_revision_page._click_accept_revision_accept_button() - self.logger.info("Deleting user session") self.delete_cookies() @@ -649,7 +600,7 @@ def test_kb_article_contributor_profile_access(self): self.logger.info("Clicking on the revision editor") self.sumo_pages.kb_article_show_history_page._click_on_a_particular_revision_editor( - revision_id, username_two + second_revision_details['revision_id'], username_two ) self.logger.info("Verifying that we are redirected to the editor homepage") @@ -713,7 +664,7 @@ def test_kb_article_contributor_profile_access(self): self.logger.info("Clicking on the revision editor") self.sumo_pages.kb_article_show_history_page._click_on_a_particular_revision_editor( - revision_id, username_two + second_revision_details['revision_id'], username_two ) self.logger.info("Verifying that we are redirected to the editor homepage") @@ -724,11 +675,8 @@ def test_kb_article_contributor_profile_access(self): self.logger.info("Navigating back") self.navigate_back() - self.logger.info("Clicking on the 'Delete article' button") - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - - self.logger.info("Clicking on the 'Delete' button") - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() # C2499415 @pytest.mark.kbArticleShowHistory @@ -751,16 +699,9 @@ def test_kb_article_revision_date_functionality(self): self.sumo_pages.kb_article_page._click_on_show_history_option() revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() - self.logger.info("Clicking on the 'Review' option") - self.sumo_pages.kb_article_show_history_page._click_on_review_revision( - revision_id - ) - - self.logger.info("Click on 'Approve Revision' button") - self.sumo_pages.kb_article_review_revision_page._click_on_approve_revision_button() - self.logger.info("Clicking on the 'Accept' button") - self.sumo_pages.kb_article_review_revision_page._click_accept_revision_accept_button() + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) self.logger.info("Signing in with a non-admin account") creator_username = self.start_existing_session(super().username_extraction_from_email( @@ -768,12 +709,12 @@ def test_kb_article_revision_date_functionality(self): )) self.logger.info("Submitting a new revision") - second_revision_id = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision() + second_revision_details = self.sumo_pages.kb_article_revision_flow.submit_new_kb_revision() self.logger.info("Deleting user session") self.delete_cookies() revision_time = self.sumo_pages.kb_article_show_history_page._get_revision_time( - second_revision_id + second_revision_details['revision_id'] ) self.logger.info("Clicking on the first revision") @@ -789,7 +730,9 @@ def test_kb_article_revision_date_functionality(self): self.navigate_back() self.logger.info("Clicking on the revision time") - self.sumo_pages.kb_article_show_history_page._click_on_a_revision_date(second_revision_id) + self.sumo_pages.kb_article_show_history_page._click_on_a_revision_date( + second_revision_details['revision_id'] + ) self.logger.info("Verifying that the revision information content is expanded by default") expect( @@ -824,7 +767,7 @@ def test_kb_article_revision_date_functionality(self): self.logger.info("Verifying that the revision id is the correct one") check.equal( self.sumo_pages.kb_article_preview_revision_page._get_preview_revision_id_text(), - str(self.number_extraction_from_string(second_revision_id)) + str(self.number_extraction_from_string(second_revision_details['revision_id'])) ) self.logger.info("Verifying that the correct revision time is displayed") @@ -936,25 +879,16 @@ def test_kb_article_revision_date_functionality(self): self.sumo_pages.kb_article_page._click_on_show_history_option() - self.logger.info("Clicking on the 'Review' option") - self.sumo_pages.kb_article_show_history_page._click_on_review_revision( - second_revision_id - ) - - self.logger.info("Click on 'Approve Revision' button") - self.sumo_pages.kb_article_review_revision_page._click_on_approve_revision_button() - - self.logger.info("Clicking on the 'Ready for Localization' checkbox") - self.sumo_pages.kb_article_review_revision_page._check_ready_for_localization_checkbox() - - self.logger.info("Clicking on the 'Accept' button") - self.sumo_pages.kb_article_review_revision_page._click_accept_revision_accept_button() + self.sumo_pages.kb_article_revision_flow.approve_kb_revision( + second_revision_details['revision_id'], ready_for_l10n=True) self.logger.info("Deleting user session") self.delete_cookies() self.logger.info("Clicking on the revision time") - self.sumo_pages.kb_article_show_history_page._click_on_a_revision_date(second_revision_id) + self.sumo_pages.kb_article_show_history_page._click_on_a_revision_date( + second_revision_details['revision_id'] + ) self.logger.info("Verifying that the correct reviewed status is displayed") check.equal( @@ -1018,14 +952,8 @@ def test_kb_article_revision_date_functionality(self): self.page ).to_have_url( article_url + QuestionPageMessages.EDIT_QUESTION_URL_ENDPOINT + "/" + str( - self.number_extraction_from_string(second_revision_id)) + self.number_extraction_from_string(second_revision_details['revision_id'])) ) - self.logger.info("Clicking on the 'Show History' option") - self.sumo_pages.kb_article_page._click_on_show_history_option() - - self.logger.info("Clicking on the 'Delete article' button") - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - - self.logger.info("Clicking on the 'Delete' button") - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + self.logger.info("Deleting the created article") + self.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 64de33cc66d..87f1343a8b6 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 @@ -1251,13 +1251,8 @@ def test_posting_a_new_kb_test_article(self, request, only_approve_it=False): self.sumo_pages.kb_article_page._click_on_show_history_option() revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() - self.sumo_pages.kb_article_show_history_page._click_on_review_revision( - revision_id - ) - - self.sumo_pages.kb_article_review_revision_page._click_on_approve_revision_button() - - self.sumo_pages.kb_article_review_revision_page._click_accept_revision_accept_button() + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) # Will perform a cleanup by deleting the test article at the end. # Need be executed after all other methods from this test class in th GH workflow file. @@ -1267,9 +1262,9 @@ def test_delete_kb_test_article(self): self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] )) self.navigate_to_link(TestArticleThreads.article_url) - self.sumo_pages.kb_article_page._click_on_show_history_option() - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() with open("test_data/test_article", 'w'): pass diff --git a/playwright_tests/tests/explore_help_articles_tests/articles/test_kb_article_creation_and_access.py b/playwright_tests/tests/explore_help_articles_tests/articles/test_kb_article_creation_and_access.py index 05df311de27..5a391484bbc 100644 --- a/playwright_tests/tests/explore_help_articles_tests/articles/test_kb_article_creation_and_access.py +++ b/playwright_tests/tests/explore_help_articles_tests/articles/test_kb_article_creation_and_access.py @@ -78,8 +78,7 @@ def test_non_admin_users_kb_article_submission(self): ) self.logger.info("Deleting the created article") - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() # C2081446, # C2081447 @pytest.mark.kbArticleCreationAndAccess @@ -228,9 +227,8 @@ def test_articles_revision_page_and_revision_approval(self): self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] )) - self.sumo_pages.kb_article_page._click_on_show_history_option() - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() # C2091580, C954321 @pytest.mark.kbArticleCreationAndAccess @@ -284,16 +282,9 @@ def test_articles_discussions_allowed(self): self.logger.info("Clicking on the 'Show History' option") self.sumo_pages.kb_article_page._click_on_show_history_option() revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() - self.logger.info("Clicking on the 'Review' option") - self.sumo_pages.kb_article_show_history_page._click_on_review_revision( - revision_id - ) - self.logger.info("Click on 'Approve Revision' button") - self.sumo_pages.kb_article_review_revision_page._click_on_approve_revision_button() - - self.logger.info("Clicking on the 'Accept' button") - self.sumo_pages.kb_article_review_revision_page._click_accept_revision_accept_button() + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) self.logger.info("Navigating to the article page") self.navigate_to_link(article_url) @@ -364,9 +355,9 @@ def test_articles_discussions_allowed(self): self.logger.info("Navigating to the article and deleting it") self.navigate_to_link(article_url) - self.sumo_pages.kb_article_page._click_on_show_history_option() - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() # C2091581 @pytest.mark.kbArticleCreationAndAccess @@ -414,16 +405,9 @@ def test_articles_discussions_not_allowed(self): self.logger.info("Clicking on the 'Show History' option") self.sumo_pages.kb_article_page._click_on_show_history_option() revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() - self.logger.info("Clicking on the 'Review' option") - self.sumo_pages.kb_article_show_history_page._click_on_review_revision( - revision_id - ) - - self.logger.info("Click on 'Approve Revision' button") - self.sumo_pages.kb_article_review_revision_page._click_on_approve_revision_button() - self.logger.info("Clicking on the 'Accept' button") - self.sumo_pages.kb_article_review_revision_page._click_accept_revision_accept_button() + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) self.logger.info("Navigating back to the article page") self.navigate_to_link(article_url) @@ -482,9 +466,8 @@ def test_articles_discussions_not_allowed(self): self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] )) - self.sumo_pages.kb_article_page._click_on_show_history_option() - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() # C2091665 @pytest.mark.kbArticleCreationAndAccess @@ -566,7 +549,7 @@ def test_kb_article_title_and_slug_validations(self): # KBArticlePageMessages.KB_ARTICLE_SUBMISSION_TITLE_ERRORS[1] # ) - self.logger.info("Submitting the question") + self.logger.info("Submitting the form") self.sumo_pages.kb_submit_kb_article_form_page._click_on_submit_for_review_button() self.sumo_pages.kb_submit_kb_article_form_page._add_text_to_changes_description_field( self.kb_article_test_data["changes_description"] @@ -602,7 +585,7 @@ def test_kb_article_title_and_slug_validations(self): # self.sumo_pages.kb_submit_kb_article_form_page.get_kb_slug_error() # ).to_be_hidden() - self.logger.info("Submitting the question") + self.logger.info("Submitting the form") self.sumo_pages.kb_submit_kb_article_form_page._click_on_submit_for_review_button() self.sumo_pages.kb_submit_kb_article_form_page._add_text_to_changes_description_field( self.kb_article_test_data["changes_description"] @@ -634,7 +617,7 @@ def test_kb_article_title_and_slug_validations(self): # self.sumo_pages.kb_submit_kb_article_form_page.get_kb_slug_error() # ).to_be_visible() - self.logger.info("Submitting the question") + self.logger.info("Submitting the form") self.sumo_pages.kb_submit_kb_article_form_page._click_on_submit_for_review_button() self.sumo_pages.kb_submit_kb_article_form_page._add_text_to_changes_description_field( self.kb_article_test_data["changes_description"] @@ -651,9 +634,8 @@ def test_kb_article_title_and_slug_validations(self): KBArticlePageMessages.KB_ARTICLE_PAGE_URL + article_details ['article_slug'] + KBArticlePageMessages.KB_ARTICLE_HISTORY_URL_ENDPOINT) - self.sumo_pages.kb_article_page._click_on_show_history_option() - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article() # C2091665 @pytest.mark.kbArticleCreationAndAccess @@ -741,16 +723,9 @@ def test_kb_article_keywords_and_summary(self, username): self.logger.info("Clicking on the 'Show History' option") self.sumo_pages.kb_article_page._click_on_show_history_option() revision_id = self.sumo_pages.kb_article_show_history_page._get_last_revision_id() - self.logger.info("Clicking on the 'Review' option") - self.sumo_pages.kb_article_show_history_page._click_on_review_revision( - revision_id - ) - self.logger.info("Click on 'Approve Revision' button") - self.sumo_pages.kb_article_review_revision_page._click_on_approve_revision_button() - - self.logger.info("Clicking on the 'Accept' button") - self.sumo_pages.kb_article_review_revision_page._click_accept_revision_accept_button() + self.logger.info("Approving the revision") + self.sumo_pages.kb_article_revision_flow.approve_kb_revision(revision_id) self.logger.info("Clicking on the top navbar sumo nav logo") self.sumo_pages.top_navbar._click_on_sumo_nav_logo() @@ -823,6 +798,5 @@ def test_kb_article_keywords_and_summary(self, username): self.user_secrets_accounts["TEST_ACCOUNT_MODERATOR"] )) - self.sumo_pages.kb_article_page._click_on_show_history_option() - self.sumo_pages.kb_article_show_history_page._click_on_delete_this_document_button() - self.sumo_pages.kb_article_show_history_page._click_on_confirmation_delete_button() + self.logger.info("Deleting the created article") + self.sumo_pages.kb_article_deletion_flow.delete_kb_article()