Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update m24 component functional tests (Fixes #15625) #15685

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions tests/functional/test_about.py

This file was deleted.

43 changes: 0 additions & 43 deletions tests/functional/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from pages.home import HomePage


@pytest.mark.skip(reason="Skipped for m24 website refresh launch")
@pytest.mark.smoke
@pytest.mark.nondestructive
def test_navigation(base_url, selenium):
Expand All @@ -22,45 +21,3 @@ def test_navigation(base_url, selenium):
page.navigation.open_about_menu()
assert page.navigation.is_about_menu_displayed
assert not page.navigation.is_products_menu_displayed

page.navigation.open_innovation_menu()
assert page.navigation.is_innovation_menu_displayed
assert not page.navigation.is_about_menu_displayed


@pytest.mark.skip(reason="Skipped for m24 website refresh launch")
@pytest.mark.smoke
@pytest.mark.nondestructive
def test_mobile_navigation(base_url, selenium_mobile):
page = HomePage(selenium_mobile, base_url, locale="de").open()
page.navigation.show()
page.navigation.open_firefox_menu()
assert page.navigation.is_firefox_menu_displayed

page.navigation.open_products_menu()
assert page.navigation.is_products_menu_displayed

page.navigation.open_about_menu()
assert page.navigation.is_about_menu_displayed

page.navigation.open_innovation_menu()
assert page.navigation.is_innovation_menu_displayed


@pytest.mark.skip(reason="Skipped for m24 website refresh launch")
@pytest.mark.smoke
@pytest.mark.nondestructive
@pytest.mark.skip_if_firefox(reason="Firefox download button is shown only to non-Firefox users.")
def test_navigation_download_firefox_button(base_url, selenium):
page = HomePage(selenium, base_url, locale="de").open()
assert not page.navigation.is_mozilla_vpn_button_displayed
assert page.navigation.is_firefox_download_button_displayed


@pytest.mark.skip(reason="Skipped for m24 website refresh launch")
@pytest.mark.nondestructive
@pytest.mark.skip_if_not_firefox(reason="Mozilla VPN button is shown only to Firefox users.")
def test_navigation_mozilla_vpn_button(base_url, selenium):
page = HomePage(selenium, base_url, locale="de").open()
assert not page.navigation.is_firefox_download_button_displayed
assert page.navigation.is_mozilla_vpn_button_displayed
17 changes: 0 additions & 17 deletions tests/pages/about.py

This file was deleted.

44 changes: 9 additions & 35 deletions tests/pages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,15 @@ def newsletter(self):
return NewsletterEmbedForm(self)

class Navigation(BaseRegion):
_root_locator = (By.CLASS_NAME, "c-navigation")
_toggle_locator = (By.CLASS_NAME, "c-navigation-menu-button")
_menu_locator = (By.CLASS_NAME, "c-navigation-items")
_firefox_menu_link_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-firefox"]')
_firefox_menu_locator = (By.ID, "c-menu-panel-firefox")
_products_menu_link_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-products"]')
_products_menu_locator = (By.ID, "c-menu-panel-products")
_about_menu_link_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-about"]')
_about_menu_locator = (By.ID, "c-menu-panel-about")
_innovation_menu_link_locator = (By.CSS_SELECTOR, '.c-menu-title[aria-controls="c-menu-panel-innovation"]')
_innovation_menu_locator = (By.ID, "c-menu-panel-innovation")
_firefox_download_button_locator = (By.CSS_SELECTOR, "#protocol-nav-download-firefox > .download-link")
_mozilla_vpn_button_locator = (By.CSS_SELECTOR, '.c-navigation-vpn-cta-container > [data-cta-text="Get Mozilla VPN"]')

@property
def is_firefox_download_button_displayed(self):
return self.is_element_displayed(*self._firefox_download_button_locator)

@property
def is_mozilla_vpn_button_displayed(self):
return self.is_element_displayed(*self._mozilla_vpn_button_locator)

def show(self):
assert not self.is_displayed, "Menu is already displayed"
self.find_element(*self._toggle_locator).click()
self.wait.until(lambda s: self.is_displayed)
return self
_root_locator = (By.CLASS_NAME, "m24-navigation-refresh")
_toggle_locator = (By.CLASS_NAME, "m24-c-navigation-menu-button")
_menu_locator = (By.CLASS_NAME, "m24-c-navigation-items")
_firefox_menu_link_locator = (By.CSS_SELECTOR, '.m24-c-menu-title[aria-controls="m24-c-menu-panel-firefox"]')
_firefox_menu_locator = (By.ID, "m24-c-menu-panel-firefox")
_products_menu_link_locator = (By.CSS_SELECTOR, '.m24-c-menu-title[aria-controls="m24-c-menu-panel-products"]')
_products_menu_locator = (By.ID, "m24-c-menu-panel-products")
_about_menu_link_locator = (By.CSS_SELECTOR, '.m24-c-menu-title[aria-controls="m24-c-menu-panel-about"]')
_about_menu_locator = (By.ID, "m24-c-menu-panel-about")

@property
def is_displayed(self):
Expand All @@ -94,10 +76,6 @@ def is_products_menu_displayed(self):
def is_about_menu_displayed(self):
return self.is_element_displayed(*self._about_menu_locator)

@property
def is_innovation_menu_displayed(self):
return self.is_element_displayed(*self._innovation_menu_locator)

def open_firefox_menu(self):
self.open_navigation_menu(self._firefox_menu_link_locator)
self.wait.until(lambda s: self.is_firefox_menu_displayed)
Expand All @@ -109,7 +87,3 @@ def open_products_menu(self):
def open_about_menu(self):
self.open_navigation_menu(self._about_menu_link_locator)
self.wait.until(lambda s: self.is_about_menu_displayed)

def open_innovation_menu(self):
self.open_navigation_menu(self._innovation_menu_link_locator)
self.wait.until(lambda s: self.is_innovation_menu_displayed)
10 changes: 0 additions & 10 deletions tests/playwright/specs/a11y/components/footer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ test.describe(
});

test('should not have any detectable a11y issues', async ({ page }) => {
const footerHeadingCompany = page.getByTestId(
'footer-heading-company'
);
const footerListCompany = page.getByTestId('footer-list-company');

// Open Company section
await expect(footerListCompany).not.toBeVisible();
await footerHeadingCompany.click();
await expect(footerListCompany).toBeVisible();

const results = await scanPageElement(page, footerLocator);
createReport('component', 'footer-mobile', results);
expect(results.violations.length).toEqual(0);
Expand Down
20 changes: 8 additions & 12 deletions tests/playwright/specs/a11y/components/navigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ test.describe(
await openPage(testURL, page, browserName);
});

test.skip('should not have any detectable a11y issues', async ({
page
}) => {
const firefoxLink = page.getByTestId('navigation-link-firefox');
const firefoxMenu = page.getByTestId('navigation-menu-firefox');
test('should not have any detectable a11y issues', async ({ page }) => {
const firefoxLink = page.getByTestId('m24-navigation-link-firefox');
const firefoxMenu = page.getByTestId('m24-navigation-menu-firefox');

// Hover over Firefox link to open menu
await expect(firefoxMenu).not.toBeVisible();
Expand All @@ -52,17 +50,15 @@ test.describe(
await openPage(testURL, page, browserName);
});

test.skip('should not have any detectable a11y issues', async ({
page
}) => {
test('should not have any detectable a11y issues', async ({ page }) => {
const navigationMenuButton = page.getByTestId(
'navigation-menu-button'
'm24-navigation-menu-button'
);
const navigationMenuItems = page.getByTestId(
'navigation-menu-items'
'm24-navigation-menu-items'
);
const firefoxLink = page.getByTestId('navigation-link-firefox');
const firefoxMenu = page.getByTestId('navigation-menu-firefox');
const firefoxLink = page.getByTestId('m24-navigation-link-firefox');
const firefoxMenu = page.getByTestId('m24-navigation-menu-firefox');

// Open navigation menu
await expect(navigationMenuItems).not.toBeVisible();
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/specs/a11y/includes/locators.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* inclusion / exclusion in a11y scans.
*/
const footerLocator = '#colophon';
const navigationLocator = '.c-navigation';
const navigationLocator = '.m24-navigation-refresh';
const subNavigationLocator = '.c-sub-navigation';
const sideMenuLocator = '.mzp-c-sidemenu';

Expand Down
81 changes: 37 additions & 44 deletions tests/playwright/specs/footer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,48 @@ test.describe(
await openPage(url, page, browserName);
});

test.skip('Footer open / close click', async ({ page }) => {
const footerHeadingCompany = page.getByTestId(
'footer-heading-company'
);
const footerListCompany = page.getByTestId('footer-list-company');
const footerHeadingResources = page.getByTestId(
'footer-heading-resources'
);
const footerListResources = page.getByTestId(
'footer-list-resources'
);
const footerHeadingSupport = page.getByTestId(
'footer-heading-support'
);
const footerListSupport = page.getByTestId('footer-list-support');
const footerHeadingDevelopers = page.getByTestId(
'footer-heading-developers'
);
const footerListDevelopers = page.getByTestId(
'footer-list-developers'
test('Footer 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'
);
const submitButton = page.getByTestId('newsletter-submit-button');
const thanksMessage = page.getByTestId('newsletter-thanks-message');

// expand form before running test
await submitButton.click();

// Open and close Company section
await expect(footerListCompany).not.toBeVisible();
await footerHeadingCompany.click();
await expect(footerListCompany).toBeVisible();
await footerHeadingCompany.click();
await expect(footerListCompany).not.toBeVisible();
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();
await expect(thanksMessage).toBeVisible();
});

// Open and close Resources section
await expect(footerListResources).not.toBeVisible();
await footerHeadingResources.click();
await expect(footerListResources).toBeVisible();
await footerHeadingResources.click();
await expect(footerListResources).not.toBeVisible();
test('Footer 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'
);
const submitButton = page.getByTestId('newsletter-submit-button');
const thanksMessage = page.getByTestId('newsletter-thanks-message');
const errorMessage = page.getByTestId('newsletter-error-message');

// Open and close Support section
await expect(footerListSupport).not.toBeVisible();
await footerHeadingSupport.click();
await expect(footerListSupport).toBeVisible();
await footerHeadingSupport.click();
await expect(footerListSupport).not.toBeVisible();
// expand form before running test
await page.getByTestId('newsletter-submit-button').click();

// Open and close Developers section
await expect(footerListDevelopers).not.toBeVisible();
await footerHeadingDevelopers.click();
await expect(footerListDevelopers).toBeVisible();
await footerHeadingDevelopers.click();
await expect(footerListDevelopers).not.toBeVisible();
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();
await expect(thanksMessage).not.toBeVisible();
});

test('Footer language change', async ({ page }) => {
Expand Down
67 changes: 0 additions & 67 deletions tests/playwright/specs/home.spec.js

This file was deleted.

Loading
Loading