-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to validate banner Fix broken test Update tests - change reporter to dot, more CI friendly Resolve comments Resolve issues - remove used variable - updated selector to reduce flakiness
- Loading branch information
1 parent
bf9455f
commit 0156790
Showing
10 changed files
with
171 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { type Locator, type Page } from '@playwright/test'; | ||
|
||
export class HomePage { | ||
readonly page: Page; | ||
readonly desktop: object; | ||
readonly officialUsage: Locator; | ||
readonly secureUsage: Locator; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
|
||
// the desktop object is used to group like selectors | ||
this.desktop = { | ||
usaBanner: page.getByTestId('usa-statement-d'), | ||
usaBannerBtn: page.getByTestId('usa-expand-btn-d'), | ||
homeLink: page.getByTestId('Home-d'), | ||
faqLink: page.getByTestId('FAQ-d'), | ||
signInBtn: page.getByTestId('sign-in-button-d'), | ||
registerBtn: page.getByTestId('register-button-d'), | ||
newBetterBtn: page.getByTestId('new-better-btn') | ||
}; | ||
|
||
this.officialUsage = page.getByTestId('official-usage'); | ||
this.secureUsage = page.getByTestId('secure-usage'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./loginPage"; | ||
export * from "./home.page"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('FAQ page', {tag: ['@e2e', '@smoke']}, () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/faq'); | ||
}); | ||
|
||
// this test validates the expansion of a FAQ question, this would be a good case to move to a component test | ||
test('should display crosswalk system FAQ', async ({ page }) => { | ||
// this is the css selector for an ID attribute | ||
await expect(page.locator('#crosswalk-system')).toBeVisible(); | ||
|
||
// this is the css selector for a HREF path ending in "state-plan-macpro.pdf" | ||
await expect(page.locator('a[href*="state-plan-macpro"]')).not.toBeVisible(); | ||
|
||
await page.locator('#crosswalk-system').click(); | ||
await expect(page.locator('a[href*="state-plan-macpro"]')).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test("has title", async ({ page }) => { | ||
await page.goto("/"); | ||
await expect(page).toHaveTitle(/OneMAC/); | ||
}); | ||
|
||
test("see frequently asked questions header when in faq page", async ({ | ||
page, | ||
}) => { | ||
await page.goto("/"); | ||
const popup = page.waitForEvent("popup"); | ||
await page.getByRole("link", { name: "FAQ", exact: true }).click(); | ||
const foundFaqHeading = await popup; | ||
await foundFaqHeading | ||
.getByRole("heading", { name: "Frequently Asked Questions" }) | ||
.isVisible(); | ||
expect(foundFaqHeading).toBeTruthy(); | ||
}); | ||
test.describe('home page', {tag: '@e2e'}, () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto("/"); | ||
}); | ||
|
||
test("see dashboard link when log in", async ({ page }) => { | ||
await page.goto("/"); | ||
await page.getByRole("link", { name: "Dashboard" }).click(); | ||
test("has title", async ({ page }) => { | ||
await expect(page).toHaveTitle("OneMAC"); | ||
}); | ||
|
||
const dashboardLinkVisible = await page | ||
.getByRole("link", { name: "Dashboard" }) | ||
.isVisible(); | ||
expect(dashboardLinkVisible).toBeTruthy(); | ||
test('should display a menu', async({ page }) => { | ||
await expect(page.getByTestId('sign-in-button-d')).not.toBeVisible(); | ||
}); | ||
|
||
test("see frequently asked questions header when in faq page", async ({ page }) => { | ||
const popup = page.waitForEvent("popup"); | ||
await page.getByRole("link", { name: "FAQ", exact: true }).click(); | ||
const foundFaqHeading = await popup; | ||
await foundFaqHeading | ||
.getByRole("heading", { name: "Frequently Asked Questions" }) | ||
.isVisible(); | ||
expect(foundFaqHeading).toBeTruthy(); | ||
}); | ||
|
||
test("see dashboard link when log in", async ({ page }) => { | ||
await page.getByRole("link", { name: "Dashboard" }).click(); | ||
|
||
const dashboardLinkVisible = await page | ||
.getByRole("link", { name: "Dashboard" }) | ||
.isVisible(); | ||
expect(dashboardLinkVisible).toBeTruthy(); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
import { HomePage } from 'pages/home.page'; | ||
let homePage; | ||
|
||
test.describe('home page - no auth', {tag: ['@e2e', '@smoke']}, () => { | ||
test.use({ storageState: { cookies: [], origins: [] } }); | ||
|
||
test.beforeEach(async ({ page }) => { | ||
homePage = new HomePage(page); | ||
await page.goto('/'); | ||
}); | ||
|
||
test.describe('UI validations', () => { | ||
test('should have a USA banner', async () => { | ||
await expect(homePage.desktop.usaBanner).toBeVisible(); | ||
await expect(homePage.desktop.usaBanner).toHaveText('An official website of the United States government'); | ||
|
||
await expect(homePage.desktop.usaBannerBtn).toBeVisible(); | ||
await expect(homePage.desktop.usaBannerBtn).toHaveText("Here's how you know"); | ||
|
||
await expect(homePage.officialUsage).not.toBeVisible(); | ||
await expect(homePage.secureUsage).not.toBeVisible(); | ||
}); | ||
|
||
test('should have a navigation banner', async () => { | ||
await expect(homePage.desktop.homeLink).toBeVisible(); | ||
await expect(homePage.desktop.homeLink).toHaveText('Home'); | ||
|
||
await expect(homePage.desktop.faqLink).toBeVisible(); | ||
await expect(homePage.desktop.faqLink).toHaveText('FAQ'); | ||
|
||
await expect(homePage.desktop.signInBtn).toBeVisible(); | ||
await expect(homePage.desktop.signInBtn).toHaveText('Sign In'); | ||
|
||
await expect(homePage.desktop.registerBtn).toBeVisible(); | ||
await expect(homePage.desktop.registerBtn).toHaveText('Register'); | ||
}); | ||
}); | ||
|
||
test.describe('Workflow validations', () => { | ||
test.describe('USA Banner Interactions', () => { | ||
test.beforeEach(async () => { | ||
await homePage.desktop.usaBannerBtn.click(); | ||
}); | ||
|
||
test('should display USA statement', async() => { | ||
await expect(homePage.officialUsage).toBeVisible(); | ||
await expect(homePage.officialUsage).toHaveText('Official websites use .govA.gov website belongs to an official government organization in the United States.'); | ||
|
||
await expect(homePage.secureUsage).toBeVisible(); | ||
await expect(homePage.secureUsage).toHaveText("Secure .gov websites use HTTPSA lock (LockA locked padlock) or https:// means you've safely connected to the .gov website. Share sensitive information only on official, secure websites."); | ||
}); | ||
|
||
test('should collapse the USA statement', async() => { | ||
await homePage.desktop.usaBannerBtn.click(); | ||
|
||
await expect(homePage.officialUsage).not.toBeVisible(); | ||
await expect(homePage.secureUsage).not.toBeVisible(); | ||
}); | ||
}); | ||
|
||
test.describe('FAQs', () => { | ||
test('navigastes to the FAQ page', async({ page }) => { | ||
await homePage.desktop.faqLink.click(); | ||
|
||
const pagePromise = page.waitForEvent('popup'); | ||
const newTab = await pagePromise; | ||
await newTab.waitForLoadState(); | ||
|
||
await expect(newTab.locator('#crosswalk-system')).toBeVisible(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters