From a16c7962a09bab24822efff16bb3ac21f33abe82 Mon Sep 17 00:00:00 2001 From: Alex Gibson Date: Wed, 11 Sep 2024 09:25:27 +0100 Subject: [PATCH] Fix home/about page test failures --- bedrock/newsletter/forms.py | 3 ++- tests/functional/newsletter/test_newsletter_embed.py | 8 -------- tests/functional/test_about.py | 2 +- tests/playwright/specs/home.spec.js | 6 +++++- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/bedrock/newsletter/forms.py b/bedrock/newsletter/forms.py index e5ebad8ccd2..e1413e91f58 100644 --- a/bedrock/newsletter/forms.py +++ b/bedrock/newsletter/forms.py @@ -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) diff --git a/tests/functional/newsletter/test_newsletter_embed.py b/tests/functional/newsletter/test_newsletter_embed.py index ba6b68c7551..59ee38732fb 100644 --- a/tests/functional/newsletter/test_newsletter_embed.py +++ b/tests/functional/newsletter/test_newsletter_embed.py @@ -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 @@ @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), diff --git a/tests/functional/test_about.py b/tests/functional/test_about.py index 468be8de37e..16fb5b583b8 100644 --- a/tests/functional/test_about.py +++ b/tests/functional/test_about.py @@ -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 diff --git a/tests/playwright/specs/home.spec.js b/tests/playwright/specs/home.spec.js index 616695f4a8f..133c6e9fd6c 100644 --- a/tests/playwright/specs/home.spec.js +++ b/tests/playwright/specs/home.spec.js @@ -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();