Fix home/about page test failures

This commit is contained in:
Alex Gibson 2024-09-11 09:25:27 +01:00
Родитель a1a0ba7bc4
Коммит a16c7962a0
4 изменённых файлов: 8 добавлений и 11 удалений

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

@ -223,7 +223,8 @@ class NewsletterFooterForm(forms.Form):
"required": "required",
"aria-required": "true",
}
country_widget = widgets.Select(attrs=required_args)
country_select_args = {"data-testid": "newsletter-country-select"}
country_widget = widgets.Select(attrs=required_args | country_select_args)
country_label = ftl_lazy("newsletter-form-select-country-or-region", fallback="newsletter-form-select-country")
self.fields["country"] = forms.ChoiceField(widget=country_widget, choices=regions, initial=country, required=False, label=country_label)
lang_widget = widgets.Select(attrs=required_args)

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

@ -4,10 +4,8 @@
import pytest
from pages.about import AboutPage
from pages.contribute.contribute import ContributePage
from pages.firefox.whatsnew.whatsnew_developer_70 import FirefoxWhatsNewDeveloper70Page
from pages.home import HomePage
from pages.mission import MissionPage
from pages.newsletter.developer import DeveloperNewsletterPage
from pages.newsletter.firefox import FirefoxNewsletterPage
@ -22,8 +20,6 @@ from pages.newsletter.security_privacy_news import SecurityPrivacyNewsletterPage
@pytest.mark.parametrize(
"page_class",
[
HomePage,
AboutPage,
MissionPage,
pytest.mark.skip_if_not_firefox(FirefoxWhatsNewDeveloper70Page),
NewsletterPage,
@ -48,8 +44,6 @@ def test_newsletter_default_values(page_class, base_url, selenium):
@pytest.mark.parametrize(
"page_class",
[
HomePage,
AboutPage,
MissionPage,
ContributePage,
pytest.mark.skip_if_not_firefox(FirefoxWhatsNewDeveloper70Page),
@ -77,8 +71,6 @@ def test_newsletter_sign_up_success(page_class, base_url, selenium):
@pytest.mark.parametrize(
"page_class",
[
HomePage,
AboutPage,
MissionPage,
ContributePage,
pytest.mark.skip_if_not_firefox(FirefoxWhatsNewDeveloper70Page),

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

@ -9,5 +9,5 @@ from pages.about import AboutPage
@pytest.mark.nondestructive
def test_read_mission_button_displayed(base_url, selenium):
page = AboutPage(selenium, base_url).open()
page = AboutPage(selenium, base_url, locale="de").open()
assert page.is_read_mission_button_displayed

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

@ -8,7 +8,7 @@
const { test, expect } = require('@playwright/test');
const openPage = require('../scripts/open-page');
const url = '/en-US/';
const url = '/de/';
test.describe(
`${url} page`,
@ -23,6 +23,7 @@ test.describe(
test('Newsletter submit success', async ({ page }) => {
const form = page.getByTestId('newsletter-form');
const emailField = page.getByTestId('newsletter-email-input');
const countryField = page.getByTestId('newsletter-country-select');
const privacyCheckbox = page.getByTestId(
'newsletter-privacy-checkbox'
);
@ -34,6 +35,7 @@ test.describe(
await expect(thanksMessage).not.toBeVisible();
await emailField.fill('success@example.com');
await countryField.selectOption('us');
await privacyCheckbox.click();
await submitButton.click();
await expect(form).not.toBeVisible();
@ -42,6 +44,7 @@ test.describe(
test('Newsletter submit failure', async ({ page }) => {
const emailField = page.getByTestId('newsletter-email-input');
const countryField = page.getByTestId('newsletter-country-select');
const privacyCheckbox = page.getByTestId(
'newsletter-privacy-checkbox'
);
@ -54,6 +57,7 @@ test.describe(
await expect(errorMessage).not.toBeVisible();
await emailField.fill('failure@example.com');
await countryField.selectOption('us');
await privacyCheckbox.click();
await submitButton.click();
await expect(errorMessage).toBeVisible();