Skip to content

Commit

Permalink
Fix home/about page test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson committed Sep 11, 2024
1 parent a1a0ba7 commit a16c796
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
3 changes: 2 additions & 1 deletion bedrock/newsletter/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ def __init__(self, newsletters, locale, data=None, *args, **kwargs):
"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)
Expand Down
8 changes: 0 additions & 8 deletions tests/functional/newsletter/test_newsletter_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,8 +20,6 @@
@pytest.mark.parametrize(
"page_class",
[
HomePage,
AboutPage,
MissionPage,
pytest.mark.skip_if_not_firefox(FirefoxWhatsNewDeveloper70Page),
NewsletterPage,
Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

@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
6 changes: 5 additions & 1 deletion tests/playwright/specs/home.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand All @@ -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'
);
Expand All @@ -34,6 +35,7 @@ test.describe(

await expect(thanksMessage).not.toBeVisible();
await emailField.fill('[email protected]');
await countryField.selectOption('us');
await privacyCheckbox.click();
await submitButton.click();
await expect(form).not.toBeVisible();
Expand All @@ -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'
);
Expand All @@ -54,6 +57,7 @@ test.describe(

await expect(errorMessage).not.toBeVisible();
await emailField.fill('[email protected]');
await countryField.selectOption('us');
await privacyCheckbox.click();
await submitButton.click();
await expect(errorMessage).toBeVisible();
Expand Down

0 comments on commit a16c796

Please sign in to comment.