Skip to content

Commit 8dae17b

Browse files
authored
Merge pull request #6285 from emilghittasv/playwright-search-tests
Playwright add second batch of search tests
2 parents 06294f8 + 774510c commit 8dae17b

File tree

6 files changed

+386
-16
lines changed

6 files changed

+386
-16
lines changed

playwright_tests/flows/explore_articles_flows/article_flows/add_kb_article_flow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ def submit_simple_kb_article(self,
151151
if article_content is None:
152152
self.submit_kb_article_page.add_text_to_content_textarea(
153153
kb_article_test_data["article_content"])
154+
else:
155+
self.submit_kb_article_page.add_text_to_content_textarea(article_content)
154156

155157
if article_content_image != '':
156158
self.submit_kb_article_page.click_on_insert_media_button()

playwright_tests/flows/explore_articles_flows/article_flows/kb_localization_flow.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from playwright.sync_api import Page
44

55
from playwright_tests.core.utilities import Utilities
6+
from playwright_tests.pages.explore_help_articles.articles.kb_article_page import KBArticlePage
67
from playwright_tests.pages.explore_help_articles.articles.kb_article_review_revision_page import \
78
KBArticleReviewRevisionPage
89
from playwright_tests.pages.explore_help_articles.articles.kb_article_show_history_page import \
@@ -14,13 +15,18 @@
1415
class KbArticleTranslationFlow:
1516
def __init__(self, page: Page):
1617
self.utilities = Utilities(page)
18+
self.kb_article_page = KBArticlePage(page)
1719
self.translate_article_page = TranslateArticlePage(page)
1820
self.kb_article_show_history_page = KBArticleShowHistoryPage(page)
1921
self.kb_article_review_revision_page = KBArticleReviewRevisionPage(page)
2022

2123
def _add_article_translation(self, approve_translation_revision: bool, title='', slug='',
2224
allow_discussions=True, keyword='', summary='', body='',
23-
save_as_draft=False, submit=True) -> dict[str, Any]:
25+
save_as_draft=False, submit=True, locale=None) -> dict[str, Any]:
26+
27+
if locale:
28+
self.kb_article_page.click_on_translate_article_option()
29+
self.translate_article_page.click_on_locale_from_list(locale)
2430

2531
if title != '':
2632
translation_title = title

playwright_tests/pages/explore_help_articles/articles/kb_translate_article_page.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,26 @@
44

55
class TranslateArticlePage(BasePage):
66
__translating_an_unready_article_banner = "//ul[@class='user-messages']/li"
7-
__list_romanian_locale = "//li/a[normalize-space(text())='română (ro)']"
87
__article_translation_page_title = "//h1[@class='sumo-page-heading']"
98
__translation_title_field = "//input[@id='id_title']"
109
__translation_slug_field = "//input[@id='id_slug']"
1110
__allow_article_comments_label = "//label[@for='id_allow_discussion']"
1211
__translation_keyword_field = "//input[@id='id_keywords']"
1312
__translation_summary_field = "//textarea[@id='id_summary']"
1413
__translation_english_readonly_field = "//div[@id='content-or-diff']/textarea"
15-
__translation_ro_text = "//textarea[@id='id_content']"
16-
__change_body_view = "//a[text()='Comută evidențierea sintaxei']"
17-
__send_translation_for_approval_button = "//button[text()='Trimite pentru aprobare']"
18-
__save_translation_as_draft_button = "//button[text()='Salvează ca ciornă']"
14+
__translation_text = "//textarea[@id='id_content']"
15+
__change_body_view = "//div[@id='editor_wrapper']/following-sibling::a"
16+
__send_translation_for_approval_button = "//button[contains(@class, 'btn-submit')][1]"
17+
__save_translation_as_draft_button = "//button[contains(@class, 'btn-draft')][1]"
1918
__draft_saved_successfully_message = "//div[@id='draft-message']"
2019
__translation_changes_description_input_field = "//input[@id='id_comment']"
2120
__translation_changes_description_submit_button = "//button[@id='submit-document-form']"
2221

2322
def __init__(self, page: Page):
2423
super().__init__(page)
2524

26-
def click_on_romanian_locale_from_list(self):
27-
self._click(self.__list_romanian_locale)
25+
def click_on_locale_from_list(self, locale: str):
26+
self._click(f"//article[@id='select-locale']//a[contains(text(), '({locale})')]")
2827

2928
def get_text_of_article_unready_for_translation_banner(self) -> str:
3029
return self._get_text_of_element(self.__translating_an_unready_article_banner)
@@ -55,8 +54,8 @@ def get_text_of_english_version(self) -> str:
5554

5655
def fill_body_translation_field(self, text: str):
5756
self._click(self.__change_body_view)
58-
self._clear_field(self.__translation_ro_text)
59-
self._fill(self.__translation_ro_text, text)
57+
self._clear_field(self.__translation_text)
58+
self._fill(self.__translation_text, text)
6059

6160
def click_on_submit_translation_for_approval_button(self):
6261
self._get_element_locator(self.__send_translation_for_approval_button).first.click()

playwright_tests/pages/search/search_page.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def get_text_of_searchbar_field(self) -> str:
103103
return self._get_element_input_value(self.__searchbar)
104104

105105
def fill_into_searchbar(self, text: str):
106+
self.clear_the_searchbar()
106107
self._fill(self.__searchbar, text)
107108

108109
def clear_the_searchbar(self):

playwright_tests/tests/explore_help_articles_tests/articles/test_article_translation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_not_ready_for_localization_articles_dashboard_status(page: Page):
3434
with allure.step("Clicking on the Translate Article Editing Tools option and selecting "
3535
"the ro locale"):
3636
sumo_pages.kb_article_page.click_on_translate_article_option()
37-
sumo_pages.translate_article_page.click_on_romanian_locale_from_list()
37+
sumo_pages.translate_article_page.click_on_locale_from_list("ro")
3838
translation_url = utilities.get_page_url()
3939

4040
with check, allure.step("Verifying that the correct banner is displayed"):

0 commit comments

Comments
 (0)