-
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.
feat(508-e2e): add auth setup and init 508 axe tests (#332)
* add auth setup step to e2e tests and axe package * fix homepage axe issues * add loginpage and reviewer auth to e2e setup * fix dashboard a11y issues * add webform a11y tests and resolve issues * fix typo
- Loading branch information
1 parent
0917852
commit b4ac3f4
Showing
20 changed files
with
179 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ build_run | |
.build | ||
.turbo | ||
coverage | ||
lambda_layer.zip | ||
lambda_layer.zip | ||
**/.auth/*.json |
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 @@ | ||
export * from "./loginPage"; |
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,21 @@ | ||
import { Page, expect } from "@playwright/test"; | ||
|
||
export class LoginPage { | ||
constructor(private readonly page: Page) {} | ||
|
||
async goto() { | ||
await this.page.goto("/"); | ||
await this.page.getByRole("button", { name: "Sign In" }).click(); | ||
} | ||
|
||
async login(email: string, password: string) { | ||
await this.goto(); | ||
await this.page.getByRole("textbox", { name: "[email protected]" }).fill(email); | ||
await this.page.getByRole("textbox", { name: "Password" }).fill(password); | ||
await this.page.getByRole("button", { name: "submit" }).click(); | ||
await this.page.waitForLoadState("networkidle"); | ||
expect( | ||
await this.page.getByRole("link", { name: "Dashboard" }) | ||
).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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import AxeBuilder from "@axe-core/playwright"; | ||
|
||
const staticRoutes = ["/", "/dashboard", "/faq", "/profile"]; | ||
|
||
test.describe("test a11y on static routes", () => { | ||
for (const route of staticRoutes) { | ||
test(`${route} should not have any automatically detectable accessibility issues`, async ({ | ||
page, | ||
}) => { | ||
await page.goto(route); | ||
await page.waitForLoadState("networkidle"); // playwright is so fast this is sometimes helpful to slow it down to view results | ||
const accessibilityScanResults = await new AxeBuilder({ page }).analyze(); | ||
console.log( | ||
`${route} violations: `, | ||
accessibilityScanResults.violations.length | ||
); | ||
expect(accessibilityScanResults.violations).toEqual([]); | ||
}); | ||
} | ||
}); | ||
|
||
const webformRoutes = [ | ||
"/guides/abp", | ||
"/webform/abp10/1", | ||
"/webform/abp3_1/1", | ||
"/webform/abp3/1", | ||
"/webform/abp1/1", | ||
]; | ||
|
||
test.describe("test a11y on webform routes", () => { | ||
for (const route of webformRoutes) { | ||
test(`${route} should not have any automatically detectable accessibility issues`, async ({ | ||
page, | ||
}) => { | ||
await page.goto(route); | ||
await page.waitForLoadState("networkidle"); | ||
const accessibilityScanResults = await new AxeBuilder({ page }).analyze(); | ||
console.log( | ||
`${route} violations: `, | ||
accessibilityScanResults.violations.length | ||
); | ||
expect(accessibilityScanResults.violations).toEqual([]); | ||
}); | ||
} | ||
}); |
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,16 +1,4 @@ | ||
import * as Libs from "../../../../../libs/secrets-manager-lib"; | ||
import { test, expect } from "@playwright/test"; | ||
import { testUsers } from "e2e/utils/users"; | ||
const stage = | ||
process.env.STAGE_NAME === "production" || process.env.STAGE_NAME === "val" | ||
? process.env.STAGE_NAME | ||
: "default"; | ||
const secretId = `${process.env.PROJECT}/${stage}/bootstrapUsersPassword`; | ||
|
||
const password = (await Libs.getSecretsValue( | ||
process.env.REGION_A as string, | ||
secretId | ||
)) as string; | ||
|
||
test("has title", async ({ page }) => { | ||
await page.goto("/"); | ||
|
@@ -32,25 +20,10 @@ test("see frequently asked questions header when in faq page", async ({ | |
|
||
test("see dashboard link when log in", async ({ page }) => { | ||
await page.goto("/"); | ||
await page.getByRole("button", { name: "Sign In" }).click(); | ||
await page | ||
.getByRole("textbox", { name: "[email protected]" }) | ||
.fill(testUsers.state); | ||
await page.getByRole("textbox", { name: "Password" }).fill(password); | ||
await page.getByRole("button", { name: "submit" }).click(); | ||
await page.getByRole("link", { name: "Dashboard" }).click(); | ||
|
||
const dashboardLinkVisible = await page | ||
.getByRole("link", { name: "Dashboard" }) | ||
.isVisible(); | ||
expect(dashboardLinkVisible).toBeTruthy(); | ||
}); | ||
|
||
test("failed incorrect login username", async ({ page }) => { | ||
await page.goto("/"); | ||
await page.getByRole("button", { name: "Sign In" }).click(); | ||
await page.getByRole("textbox", { name: "[email protected]" }).fill("."); | ||
await page.getByRole("textbox", { name: "Password" }).fill(password); | ||
await page.getByRole("button", { name: "submit" }).click(); | ||
await page.locator("#loginErrorMessage").first().isVisible(); | ||
}); |
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,35 @@ | ||
import { test as setup } from "@playwright/test"; | ||
import * as Libs from "../../../../libs/secrets-manager-lib"; | ||
import { testUsers } from "./users"; | ||
import { LoginPage } from "../pages"; | ||
|
||
const stage = | ||
process.env.STAGE_NAME === "production" || process.env.STAGE_NAME === "val" | ||
? process.env.STAGE_NAME | ||
: "default"; | ||
const secretId = `${process.env.PROJECT}/${stage}/bootstrapUsersPassword`; | ||
|
||
const password = (await Libs.getSecretsValue( | ||
process.env.REGION_A as string, | ||
secretId | ||
)) as string; | ||
|
||
const stateSubmitterAuthFile = "playwright/.auth/state-user.json"; | ||
|
||
setup("authenticate state submitter", async ({ page, context }) => { | ||
const loginPage = new LoginPage(page); | ||
await loginPage.goto(); | ||
|
||
await loginPage.login(testUsers.state, password); | ||
await context.storageState({ path: stateSubmitterAuthFile }); | ||
}); | ||
|
||
const reviewerAuthFile = "playwright/.auth/reviewer-user.json"; | ||
|
||
setup("authenticate cms reviewer", async ({ page, context }) => { | ||
const loginPage = new LoginPage(page); | ||
await loginPage.goto(); | ||
|
||
await loginPage.login(testUsers.reviewer, password); | ||
await context.storageState({ path: reviewerAuthFile }); | ||
}); |
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,4 +1,4 @@ | ||
export const testUsers = { | ||
state: "[email protected]", | ||
cmsAdmin: "cmsadmin@example.com" | ||
}; | ||
state: "[email protected]", | ||
reviewer: "reviewer@example.com", | ||
}; |
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
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
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
Oops, something went wrong.