зеркало из https://github.com/mozilla/kitsune.git
Merge pull request #6070 from emilghittasv/playwright-expanding-article-translations-coverage-v2
Expanding playwright localization coverage
This commit is contained in:
Коммит
a8401c7e22
|
@ -49,6 +49,10 @@ env:
|
|||
TEST_ACCOUNTS_PS: ${{secrets.AUTOMATION_ACCOUNTS_PASSWORD}}
|
||||
TEST_ACCOUNT_MODERATOR: ${{secrets.AUTOMATION_MODERATOR_ACCOUNT}}
|
||||
BROWSER: ${{secrets.BROWSER}}
|
||||
DATABASE_URL: postgres://kitsune:kitsune@postgres:5432/kitsune
|
||||
SECRET_KEY: secret
|
||||
REDIS_DEFAULT_URL=: edis://redis:6379/1
|
||||
REDIS_HELPFULVOTES_URL: redis://redis:6379/2
|
||||
|
||||
|
||||
jobs:
|
||||
|
|
|
@ -58,6 +58,14 @@ class BasePage:
|
|||
self.__wait_for_dom_load_to_finnish()
|
||||
return locator.get_attribute(attribute)
|
||||
|
||||
def _get_attribute_values_of_elements(self, locator: list[Locator],
|
||||
attribute: str) -> list[str]:
|
||||
self.__wait_for_dom_load_to_finnish()
|
||||
values = []
|
||||
for element in locator:
|
||||
values.append(element.get_attribute(attribute))
|
||||
return values
|
||||
|
||||
def _wait_for_given_timeout(self, timeout: float):
|
||||
self._page.wait_for_timeout(timeout)
|
||||
|
||||
|
|
|
@ -154,6 +154,9 @@ class TestUtilities:
|
|||
if response.status >= 400:
|
||||
self.refresh_page()
|
||||
|
||||
def set_extra_http_headers(self, headers):
|
||||
self.page.set_extra_http_headers(headers)
|
||||
|
||||
# Wait for a given timeout
|
||||
def wait_for_given_timeout(self, milliseconds: int):
|
||||
self.page.wait_for_timeout(milliseconds)
|
||||
|
|
|
@ -6,7 +6,8 @@ class FooterSection(BasePage):
|
|||
|
||||
# Footer section locators.
|
||||
__all_footer_links = "//footer//a"
|
||||
__language_selector = "mzp-c-language-switcher-select"
|
||||
__language_selector = "//select[@id='mzp-c-language-switcher-select']"
|
||||
__language_selector_options = "//select[@id='mzp-c-language-switcher-select']/option"
|
||||
|
||||
def __init__(self, page: Page):
|
||||
super().__init__(page)
|
||||
|
@ -15,5 +16,9 @@ class FooterSection(BasePage):
|
|||
def _get_all_footer_links(self) -> list[ElementHandle]:
|
||||
return super()._get_element_handles(self.__all_footer_links)
|
||||
|
||||
def _switch_to_ro_locale(self):
|
||||
super()._select_option_by_value(self.__language_selector, 'ro')
|
||||
def _get_all_footer_locales(self) -> list[str]:
|
||||
return super()._get_attribute_values_of_elements(super()._get_elements_locators(
|
||||
self.__language_selector_options), "value")
|
||||
|
||||
def _switch_to_a_locale(self, locale: str):
|
||||
super()._select_option_by_value(self.__language_selector, locale)
|
||||
|
|
|
@ -28,7 +28,9 @@ class TestRecentRevisionsDashboard(TestUtilities):
|
|||
|
||||
with allure.step("Navigating to the recent revisions dashboard and verifying that the "
|
||||
"posted article is displayed for admin accounts"):
|
||||
self.sumo_pages.top_navbar._click_on_recent_revisions_option()
|
||||
self.navigate_to_link(
|
||||
self.general_test_data['dashboard_links']['recent_revisions']
|
||||
)
|
||||
expect(
|
||||
self.sumo_pages.recent_revisions_page._get_recent_revision_based_on_article(
|
||||
article_details['article_title']
|
||||
|
@ -92,7 +94,9 @@ class TestRecentRevisionsDashboard(TestUtilities):
|
|||
|
||||
with allure.step("Navigating back to the recent revisions page and verifying that the "
|
||||
"article is no longer displayed"):
|
||||
self.sumo_pages.top_navbar._click_on_recent_revisions_option()
|
||||
self.navigate_to_link(
|
||||
self.general_test_data['dashboard_links']['recent_revisions']
|
||||
)
|
||||
expect(
|
||||
self.sumo_pages.recent_revisions_page._get_recent_revision_based_on_article(
|
||||
article_details['article_title']
|
||||
|
@ -127,7 +131,9 @@ class TestRecentRevisionsDashboard(TestUtilities):
|
|||
|
||||
with allure.step("Navigating to the Recent Revisions dashboard and verifying that own "
|
||||
"revision is visible"):
|
||||
self.sumo_pages.top_navbar._click_on_recent_revisions_option()
|
||||
self.navigate_to_link(
|
||||
self.general_test_data['dashboard_links']['recent_revisions']
|
||||
)
|
||||
expect(
|
||||
self.sumo_pages.recent_revisions_page.
|
||||
_get_recent_revision_based_on_article_title_and_user(
|
||||
|
@ -210,7 +216,9 @@ class TestRecentRevisionsDashboard(TestUtilities):
|
|||
with allure.step("Navigating back to the recent revision dashboard, signing out and "
|
||||
"verifying that the revision is no longer displayed for the deleted kb "
|
||||
"article"):
|
||||
self.sumo_pages.top_navbar._click_on_recent_revisions_option()
|
||||
self.navigate_to_link(
|
||||
self.general_test_data['dashboard_links']['recent_revisions']
|
||||
)
|
||||
self.wait_for_given_timeout(1000)
|
||||
self.delete_cookies()
|
||||
expect(
|
||||
|
|
|
@ -8,11 +8,13 @@ from playwright_tests.messages.explore_help_articles.kb_article_page_messages im
|
|||
KBArticlePageMessages)
|
||||
from playwright_tests.messages.explore_help_articles.kb_translation_messages import (
|
||||
KbTranslationMessages)
|
||||
from playwright_tests.messages.homepage_messages import HomepageMessages
|
||||
from kitsune.settings import SUMO_LANGUAGES, FALLBACK_LANGUAGES, NON_SUPPORTED_LOCALES
|
||||
|
||||
|
||||
class TestArticleTranslation(TestUtilities, KbTranslationMessages):
|
||||
|
||||
# C2489548, C2490043
|
||||
# C2489548, C2490043, C946153
|
||||
@pytest.mark.kbArticleTranslation
|
||||
def test_not_ready_for_localization_articles_dashboard_status(self):
|
||||
with allure.step("Signing in with an Admin account"):
|
||||
|
@ -310,3 +312,115 @@ class TestArticleTranslation(TestUtilities, KbTranslationMessages):
|
|||
|
||||
self.navigate_to_link(article_url)
|
||||
self.sumo_pages.kb_article_deletion_flow.delete_kb_article()
|
||||
|
||||
# C2316346, C2316347
|
||||
@pytest.mark.kbArticleTranslation
|
||||
def test_unsupported_locales_fallback(self):
|
||||
with allure.step("Verifying the unsupported locales fallback"):
|
||||
for key, value in NON_SUPPORTED_LOCALES.items():
|
||||
self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL + f"/{key}/")
|
||||
if value is None:
|
||||
expect(
|
||||
self.page
|
||||
).to_have_url(HomepageMessages.STAGE_HOMEPAGE_URL_EN_US)
|
||||
else:
|
||||
expect(
|
||||
self.page
|
||||
).to_have_url(HomepageMessages.STAGE_HOMEPAGE_URL + f"/{value}/")
|
||||
|
||||
# C2625000
|
||||
# Skipping this test for now due to the https://github.com/mozilla/sumo/issues/1820 failure
|
||||
@pytest.mark.skip
|
||||
def test_fallback_languages(self):
|
||||
with allure.step("Verifying the language fallback"):
|
||||
for key, value in FALLBACK_LANGUAGES.items():
|
||||
self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL + f"/{value}/")
|
||||
expect(
|
||||
self.page
|
||||
).to_have_url(HomepageMessages.STAGE_HOMEPAGE_URL + f"/{key}/")
|
||||
|
||||
# C2316347
|
||||
@pytest.mark.kbArticleTranslation
|
||||
def test_supported_languages(self):
|
||||
with allure.step("Verifying that the users are redirected to the supported locales "
|
||||
"successfully"):
|
||||
for locale in SUMO_LANGUAGES:
|
||||
if locale == 'xx':
|
||||
continue
|
||||
else:
|
||||
with self.page.expect_navigation() as navigation_info:
|
||||
self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL + f"/{locale}/")
|
||||
response = navigation_info.value
|
||||
assert response.status == 200
|
||||
assert locale in self.get_page_url()
|
||||
|
||||
# C2316350, C2316349
|
||||
@pytest.mark.kbArticleTranslation
|
||||
def test_sumo_locale_priority(self):
|
||||
with allure.step("Signing in with a non-admin account and changing the preferred profile "
|
||||
"language"):
|
||||
self.start_existing_session(super().username_extraction_from_email(
|
||||
self.user_secrets_accounts["TEST_ACCOUNT_MESSAGE_5"]
|
||||
))
|
||||
|
||||
with allure.step("Accessing the edit profile page and changing the language to ro"):
|
||||
self.sumo_pages.top_navbar._click_on_edit_profile_option()
|
||||
(self.sumo_pages.edit_my_profile_page
|
||||
._select_preferred_language_dropdown_option_by_value("ro"))
|
||||
self.sumo_pages.edit_my_profile_page._click_update_my_profile_button()
|
||||
|
||||
with allure.step("Navigating to the SUMO homepage without specifying the path in the "
|
||||
"locale and verifying that the preferred locale is set"):
|
||||
self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL)
|
||||
expect(
|
||||
self.page
|
||||
).to_have_url(HomepageMessages.STAGE_HOMEPAGE_URL + "/ro/")
|
||||
|
||||
with allure.step("Navigating to the SUMO homepage while using a lang query parameter and "
|
||||
"verifying that the user is redirected to the specified locale inside "
|
||||
"the param"):
|
||||
self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL + "/?lang=de")
|
||||
expect(
|
||||
self.page
|
||||
).to_have_url(HomepageMessages.STAGE_HOMEPAGE_URL + "/de/")
|
||||
|
||||
with allure.step("Navigating back to the ro locale"):
|
||||
self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL)
|
||||
|
||||
with allure.step("Sending a request by modifying the 'Accept-Language' header to a "
|
||||
"different locale"):
|
||||
headers = {
|
||||
'Accept-Language': 'it'
|
||||
}
|
||||
self.set_extra_http_headers(headers)
|
||||
self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL)
|
||||
expect(
|
||||
self.page
|
||||
).to_have_url(HomepageMessages.STAGE_HOMEPAGE_URL + "/ro/")
|
||||
|
||||
with allure.step("Changing the preferred language back to english and signing out"):
|
||||
self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL + '/en-US/')
|
||||
self.sumo_pages.top_navbar._click_on_edit_profile_option()
|
||||
(self.sumo_pages.edit_my_profile_page
|
||||
._select_preferred_language_dropdown_option_by_value("en-US"))
|
||||
self.sumo_pages.edit_my_profile_page._click_update_my_profile_button()
|
||||
self.delete_cookies()
|
||||
|
||||
with allure.step("Sending the request with the modified 'Accept-Language' header set to "
|
||||
"a different locale and verifying that the correct locale is displayed"):
|
||||
self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL)
|
||||
expect(
|
||||
self.page
|
||||
).to_have_url(HomepageMessages.STAGE_HOMEPAGE_URL + "/it/")
|
||||
|
||||
with allure.step("Sending the request with the modified 'Accept-Language' to point out "
|
||||
"to an invalid locale and a fallback and verifying that the user is "
|
||||
"redirected to the correct first fallback locale"):
|
||||
headers = {
|
||||
'Accept-Language': 'test, de, it'
|
||||
}
|
||||
self.set_extra_http_headers(headers)
|
||||
self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL)
|
||||
expect(
|
||||
self.page
|
||||
).to_have_url(HomepageMessages.STAGE_HOMEPAGE_URL + "/de/")
|
||||
|
|
|
@ -920,7 +920,7 @@ class TestKbArticleRestrictedVisibility(TestUtilities):
|
|||
)
|
||||
).to_be_visible()
|
||||
|
||||
# C2539174
|
||||
# C2539174 C2101640
|
||||
@pytest.mark.kbRestrictedVisibilitySingleGroup
|
||||
@pytest.mark.parametrize("article_title", [
|
||||
(restricted_kb_articles['restricted_kb_article_title']),
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import re
|
||||
import allure
|
||||
import pytest
|
||||
import requests
|
||||
from pytest_check import check
|
||||
|
||||
from playwright.sync_api import expect
|
||||
from playwright_tests.core.testutilities import TestUtilities
|
||||
from urllib.parse import urljoin
|
||||
|
||||
|
@ -42,3 +43,14 @@ class TestFooter(TestUtilities):
|
|||
# We are currently treating them as pass cases.
|
||||
with check, allure.step(f"Verifying that {url} is not broken are not broken"):
|
||||
assert response.status_code in set(range(400)) | {403, 429}
|
||||
|
||||
# C2316348
|
||||
@pytest.mark.footerSectionTests
|
||||
def test_locale_selector(self):
|
||||
with allure.step("Verifying that all footer select options are redirecting the user to "
|
||||
"the correct page locale"):
|
||||
for locale in self.sumo_pages.footer_section._get_all_footer_locales():
|
||||
self.sumo_pages.footer_section._switch_to_a_locale(locale)
|
||||
expect(
|
||||
self.page
|
||||
).to_have_url(re.compile(f".*{locale}"))
|
||||
|
|
Загрузка…
Ссылка в новой задаче