- Using composition instead of inheritance inside the kb_localization_flow.py class.

- Using self. instead of super() and making the functions public inside the kb_translate_article_page.py class.
- Updating the modified function calls in tests.
This commit is contained in:
Emil Ghitta 2024-10-01 15:46:27 +03:00
Родитель 33e0f6f6af
Коммит 0e57633a49
3 изменённых файлов: 69 добавлений и 69 удалений

Просмотреть файл

@ -9,14 +9,14 @@ from playwright_tests.pages.explore_help_articles.articles.kb_article_show_histo
KBArticleShowHistoryPage
from playwright_tests.pages.explore_help_articles.articles.kb_translate_article_page import \
TranslateArticlePage
from playwright_tests.pages.explore_help_articles.articles.submit_kb_article_page import \
SubmitKBArticlePage
class KbArticleTranslationFlow(TranslateArticlePage, Utilities, SubmitKBArticlePage,
KBArticleShowHistoryPage, KBArticleReviewRevisionPage):
class KbArticleTranslationFlow:
def __init__(self, page: Page):
super().__init__(page)
self.utilities = Utilities(page)
self.translate_article_page = TranslateArticlePage(page)
self.kb_article_show_history_page = KBArticleShowHistoryPage(page)
self.kb_article_review_revision_page = KBArticleReviewRevisionPage(page)
def _add_article_translation(self, approve_translation_revision: bool, title='', slug='',
allow_discussions=True, keyword='', summary='', body='',
@ -24,56 +24,56 @@ class KbArticleTranslationFlow(TranslateArticlePage, Utilities, SubmitKBArticleP
if title != '':
translation_title = title
super()._fill_translation_title_field(translation_title)
self.translate_article_page.fill_translation_title_field(translation_title)
else:
translation_title = super().kb_article_test_data['translated_title'] + super(
).generate_random_number(1, 1000)
super()._fill_translation_title_field(translation_title)
translation_title = (self.utilities.kb_article_test_data['translated_title'] + self.
utilities.generate_random_number(1, 1000))
self.translate_article_page.fill_translation_title_field(translation_title)
if slug != '':
translation_slug = slug
super()._fill_translation_slug_field(translation_slug)
self.translate_article_page.fill_translation_slug_field(translation_slug)
else:
translation_slug = super().kb_article_test_data['translated_slug'] + super(
).generate_random_number(1, 1000)
super()._fill_translation_slug_field(translation_slug)
translation_slug = (self.utilities.kb_article_test_data['translated_slug'] + self.
utilities.generate_random_number(1, 1000))
self.translate_article_page.fill_translation_slug_field(translation_slug)
if not allow_discussions:
super()._click_on_allow_translated_article_comments_checkbox()
self.translate_article_page.click_on_allow_translated_article_comments_checkbox()
if keyword != '':
translation_keyword = keyword
super()._fill_translated_article_keyword(translation_keyword)
self.translate_article_page.fill_translated_article_keyword(translation_keyword)
else:
translation_keyword = super().kb_article_test_data['translated_keyword']
super()._fill_translated_article_keyword(translation_keyword)
translation_keyword = self.utilities.kb_article_test_data['translated_keyword']
self.translate_article_page.fill_translated_article_keyword(translation_keyword)
if summary != '':
translation_summary = summary
super()._fill_translated_article_summary(translation_summary)
self.translate_article_page.fill_translated_article_summary(translation_summary)
else:
translation_summary = super().kb_article_test_data['translated_search_summary']
super()._fill_translated_article_summary(translation_summary)
translation_summary = self.utilities.kb_article_test_data['translated_search_summary']
self.translate_article_page.fill_translated_article_summary(translation_summary)
if body != '':
translation_body = body
super()._fill_body_translation_field(translation_body)
self.translate_article_page.fill_body_translation_field(translation_body)
else:
translation_body = super().kb_article_test_data['translated_body']
super()._fill_body_translation_field(translation_body)
translation_body = self.utilities.kb_article_test_data['translated_body']
self.translate_article_page.fill_body_translation_field(translation_body)
if save_as_draft:
super()._click_on_save_translation_as_draft_button()
self.translate_article_page.click_on_save_translation_as_draft_button()
if submit:
super()._click_on_submit_translation_for_approval_button()
super()._fill_translation_changes_description_field(
super().kb_article_test_data['translated_review_description']
self.translate_article_page.click_on_submit_translation_for_approval_button()
self.translate_article_page.fill_translation_changes_description_field(
self.utilities.kb_article_test_data['translated_review_description']
)
super()._click_on_description_submit_button()
self.translate_article_page.click_on_description_submit_button()
first_revision_id = super().get_last_revision_id()
first_revision_id = self.kb_article_show_history_page.get_last_revision_id()
if approve_translation_revision:
self.approve_kb_translation(first_revision_id)
@ -87,8 +87,8 @@ class KbArticleTranslationFlow(TranslateArticlePage, Utilities, SubmitKBArticleP
}
def approve_kb_translation(self, revision_id: str):
super().click_on_review_revision(
self.kb_article_show_history_page.click_on_review_revision(
revision_id
)
super().click_on_approve_revision_button()
super().click_accept_revision_accept_button()
self.kb_article_review_revision_page.click_on_approve_revision_button()
self.kb_article_review_revision_page.click_accept_revision_accept_button()

Просмотреть файл

@ -23,52 +23,52 @@ class TranslateArticlePage(BasePage):
def __init__(self, page: Page):
super().__init__(page)
def _click_on_romanian_locale_from_list(self):
super()._click(self.__list_romanian_locale)
def click_on_romanian_locale_from_list(self):
self._click(self.__list_romanian_locale)
def _get_text_of_article_unready_for_translation_banner(self) -> str:
return super()._get_text_of_element(self.__translating_an_unready_article_banner)
def get_text_of_article_unready_for_translation_banner(self) -> str:
return self._get_text_of_element(self.__translating_an_unready_article_banner)
def _get_unready_for_translation_banner(self) -> Locator:
return super()._get_element_locator(self.__translating_an_unready_article_banner)
def get_unready_for_translation_banner(self) -> Locator:
return self._get_element_locator(self.__translating_an_unready_article_banner)
def _get_translate_page_title(self) -> str:
return super()._get_text_of_element(self.__article_translation_page_title)
def get_translate_page_title(self) -> str:
return self._get_text_of_element(self.__article_translation_page_title)
def _fill_translation_title_field(self, text: str):
super()._fill(self.__translation_title_field, text)
def fill_translation_title_field(self, text: str):
self._fill(self.__translation_title_field, text)
def _fill_translation_slug_field(self, text: str):
super()._fill(self.__translation_slug_field, text)
def fill_translation_slug_field(self, text: str):
self._fill(self.__translation_slug_field, text)
def _click_on_allow_translated_article_comments_checkbox(self):
super()._click(self.__allow_article_comments_label)
def click_on_allow_translated_article_comments_checkbox(self):
self._click(self.__allow_article_comments_label)
def _fill_translated_article_keyword(self, text: str):
super()._fill(self.__translation_keyword_field, text)
def fill_translated_article_keyword(self, text: str):
self._fill(self.__translation_keyword_field, text)
def _fill_translated_article_summary(self, text: str):
super()._fill(self.__translation_summary_field, text)
def fill_translated_article_summary(self, text: str):
self._fill(self.__translation_summary_field, text)
def _get_text_of_english_version(self) -> str:
return super()._get_text_of_element(self.__translation_english_readonly_field)
def get_text_of_english_version(self) -> str:
return self._get_text_of_element(self.__translation_english_readonly_field)
def _fill_body_translation_field(self, text: str):
super()._click(self.__change_body_view)
super()._clear_field(self.__translation_ro_text)
super()._fill(self.__translation_ro_text, text)
def fill_body_translation_field(self, text: str):
self._click(self.__change_body_view)
self._clear_field(self.__translation_ro_text)
self._fill(self.__translation_ro_text, text)
def _click_on_submit_translation_for_approval_button(self):
super()._get_element_locator(self.__send_translation_for_approval_button).first.click()
def click_on_submit_translation_for_approval_button(self):
self._get_element_locator(self.__send_translation_for_approval_button).first.click()
def _fill_translation_changes_description_field(self, text: str):
super()._fill(self.__translation_changes_description_input_field, text)
def fill_translation_changes_description_field(self, text: str):
self._fill(self.__translation_changes_description_input_field, text)
def _click_on_description_submit_button(self):
super()._click(self.__translation_changes_description_submit_button)
def click_on_description_submit_button(self):
self._click(self.__translation_changes_description_submit_button)
def _click_on_save_translation_as_draft_button(self):
super()._get_element_locator(self.__save_translation_as_draft_button).first.click()
def click_on_save_translation_as_draft_button(self):
self._get_element_locator(self.__save_translation_as_draft_button).first.click()
def _get_draft_success_message_locator(self) -> Locator:
return super()._get_element_locator(self.__draft_saved_successfully_message)
def get_draft_success_message_locator(self) -> Locator:
return self._get_element_locator(self.__draft_saved_successfully_message)

Просмотреть файл

@ -34,12 +34,12 @@ def test_not_ready_for_localization_articles_dashboard_status(page: Page):
with allure.step("Clicking on the Translate Article Editing Tools option and selecting "
"the ro locale"):
sumo_pages.kb_article_page.click_on_translate_article_option()
sumo_pages.translate_article_page._click_on_romanian_locale_from_list()
sumo_pages.translate_article_page.click_on_romanian_locale_from_list()
translation_url = utilities.get_page_url()
with check, allure.step("Verifying that the correct banner is displayed"):
check.equal(
sumo_pages.translate_article_page._get_text_of_article_unready_for_translation_banner(
sumo_pages.translate_article_page.get_text_of_article_unready_for_translation_banner(
), KBArticlePageMessages.KB_ARTICLE_NOT_READY_FOR_TRANSLATION_BANNER
)
@ -171,7 +171,7 @@ def test_ready_for_localization_articles_dashboard_status(page: Page):
sumo_pages.most_visited_translations_page._click_on_a_particular_article_status(
article_details['article_title'])
translation_url = utilities.get_page_url()
expect(sumo_pages.translate_article_page._get_unready_for_translation_banner()
expect(sumo_pages.translate_article_page.get_unready_for_translation_banner()
).to_be_hidden()
with allure.step("Performing an article translation"):