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

Care 767 create automation tests for menu button on mobile #44

Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions src/e2e/CareLeavers.E2ETests/src/helpers/urls-to-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ export const helplineLinksToTest = [
'/home',
'/all-support',
];

// List of Pages that will have the share and print buttons
export const shareAndPrintLinksToTest = [
'/home',
// '/all-support',- commenting this for now as the buttons aren't visible on this page
];

40 changes: 40 additions & 0 deletions src/e2e/CareLeavers.E2ETests/src/pages/BasePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ export class BasePage {
public readonly mobileMenuContainer: Locator;
public readonly closeMenuButton: Locator;

// Locators for social media share buttons
public readonly shareButtonsContainer: Locator;
public readonly facebookShareButton: Locator;
public readonly twitterShareButton: Locator;
public readonly emailShareButton: Locator;
public readonly printShareButton: Locator;

// Locators for Metadata column
public readonly metadataDefinitions: Locator;

//Locators for helplines-If you need Help at the bottom of the page
public readonly helplineLink: Locator;
public readonly ifYouNeedHelpSection: Locator;
Expand Down Expand Up @@ -58,6 +68,16 @@ export class BasePage {
this.mobileMenuLinks = page.locator('.dfe-header__navigation-list a');
this.closeMenuButton = page.locator('#close-menu');

// Locators for social media share buttons
this.shareButtonsContainer = page.locator('.sharethis-inline-share-buttons');
this.facebookShareButton = page.locator('[data-network="facebook"]');
this.twitterShareButton = page.locator('[data-network="twitter"]');
this.emailShareButton = page.locator('[data-network="email"]');
this.printShareButton = page.locator('[data-network="print"]');

// Locators for Metadata definitions
this.metadataDefinitions = page.locator('.gem-c-metadata__definition');

//Locators for helplines-If you need Help at the bottom of the page
this.helplineLink = page.locator('p.govuk-body a.govuk-hyperlink');
this.ifYouNeedHelpSection = page.locator('#If-you-need-help-now');
Expand Down Expand Up @@ -197,6 +217,26 @@ export class BasePage {
}
}

//Verify that the Social Media and Share buttons are visible
async verifyShareButtonsVisibility() {
await Promise.all([
expect(this.shareButtonsContainer).toBeVisible(),
expect(this.facebookShareButton).toBeVisible(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As these are configurable, did we want to only expect the shareButtonsContainer, and leave the others?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed all the social buttons validations, I have kept the print icon as you mentioned that this should always be there

expect(this.twitterShareButton).toBeVisible(),
expect(this.emailShareButton).toBeVisible(),
expect(this.printShareButton).toBeVisible()
]);
}

//Verify Metadata(Page Published and Last Updated) are visible
async verifyMetadataIsPopulated() {
const count = await this.metadataDefinitions.count();
for (let i = 0; i < count; i++) {
await expect(this.metadataDefinitions.nth(i)).not.toBeEmpty();
}
}

//verify footer Links are visible
async verifyFooterLinks() {
//Ensure the footer is visible
await expect(this.footer).toBeVisible();
Expand Down
28 changes: 27 additions & 1 deletion src/e2e/CareLeavers.E2ETests/src/tests/SharedLinks.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test';
import { BasePage } from '../pages/BasePage';
import { commonPagesToTest, helplineLinksToTest } from '../helpers/urls-to-check';
import {commonPagesToTest, helplineLinksToTest, shareAndPrintLinksToTest} from '../helpers/urls-to-check';

// Defining a hook that runs before each test to create the basePage
test.describe('Shared Website Functionalities', () => {
Expand Down Expand Up @@ -36,6 +36,32 @@ test.describe('Shared Website Functionalities', () => {
});
});

// Test to validate Social Media Share and Print Buttons
test.describe('Social Media Share and Print Buttons Visibility', () => {
shareAndPrintLinksToTest.forEach((path) => {
test(`Verify share and print buttons are visible on ${path}`, async ({ page }) => {
const basePage = new BasePage(page);

// Navigate to the page and Verify all share and print buttons are visible
await basePage.navigateTo(path);
await basePage.verifyShareButtonsVisibility();
});
});
});

// Test to validate Metadata of page is visible
test.describe('Metadata Visibility Across Multiple Pages', () => {
commonPagesToTest.forEach((path) => {
test(`Verify metadata is populated on ${path}`, async ({ page }) => {
const basePage = new BasePage(page);

// Navigate to the page and Verify all share and print buttons are visible
await basePage.navigateTo(path);
await basePage.verifyMetadataIsPopulated();
});
});
});

// Test to validate footer links
test.describe('Footer Links Functionality', () => {
commonPagesToTest.forEach((path) => {
Expand Down