-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/improving existing e2e tests (#1125)
* chore: improved current E2E tests and enhanced labels * chore: added more tests around article page and unauth/auth views
- Loading branch information
1 parent
f929677
commit 9803fd1
Showing
5 changed files
with
174 additions
and
46 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test.describe("Accessibility Tests", () => { | ||
test.describe("Confirm all images on homepage have alt text", () => { | ||
test("Shared content", async ({ page }) => { | ||
const imagesWithoutAltText = await page.$$eval( | ||
"img:not([alt])", | ||
(images) => images.length, | ||
); | ||
expect(imagesWithoutAltText).toBe(0); // All images should have alt text | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,59 @@ | ||
import { test, expect } from "playwright/test"; | ||
import "dotenv/config"; | ||
|
||
test.describe("Login Page", () => { | ||
test("should display the welcome message", async ({ page }) => { | ||
await page.goto("http://localhost:3000/get-started"); | ||
const welcomeMessage = page.getByText("Sign in or create your accounttton"); | ||
expect(welcomeMessage).toBeTruthy(); | ||
}); | ||
test("should display the Github login button", async ({ page }) => { | ||
test.describe("Unauthenticated Login Page", () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.context().clearCookies(); | ||
await page.goto("http://localhost:3000/get-started"); | ||
await page.waitForTimeout(3000); | ||
}); | ||
test("Sign up page contains sign up links", async ({ page, isMobile }) => { | ||
await expect(page.getByText("CodúBetaSign in or create")).toBeVisible(); | ||
await expect( | ||
page.getByRole("heading", { name: "Sign in or create your account" }), | ||
).toBeVisible(); | ||
await expect(page.getByRole("link", { name: "return home" })).toBeVisible(); | ||
if (!isMobile) { | ||
await expect( | ||
page.getByRole("button", { name: "Sign up for free" }), | ||
).toBeVisible(); | ||
await expect( | ||
page.getByRole("button", { name: "Sign in", exact: true }), | ||
).toBeVisible(); | ||
} | ||
}); | ||
test("Login page contains GitHub button", async ({ page }) => { | ||
await expect(page.getByTestId("github-login-button")).toBeVisible(); | ||
}); | ||
|
||
test("should display the Gitlab login button", async ({ page }) => { | ||
await page.context().clearCookies(); | ||
await page.goto("http://localhost:3000/get-started"); | ||
await page.waitForLoadState(); | ||
test("Login page contains GitLab button", async ({ page }) => { | ||
await expect(page.getByTestId("gitlab-login-button")).toBeVisible(); | ||
}); | ||
}); | ||
|
||
test.describe("Authenticated Login Page", () => { | ||
test("Sign up page contains sign up links", async ({ page, isMobile }) => { | ||
// authenticated users are kicked back to the homepage if they try to go to /get-started | ||
await page.goto("http://localhost:3000/get-started"); | ||
expect(page.url()).toEqual("http://localhost:3000/"); | ||
await expect(page.getByText("CodúBetaSign in or create")).toBeHidden(); | ||
await expect( | ||
page.getByRole("heading", { name: "Sign in or create your account" }), | ||
).toBeHidden(); | ||
await expect(page.getByRole("link", { name: "return home" })).toBeHidden(); | ||
if (!isMobile) { | ||
await expect( | ||
page.getByRole("button", { name: "Sign up for free" }), | ||
).toBeHidden(); | ||
await expect( | ||
page.getByRole("button", { name: "Sign in", exact: true }), | ||
).toBeHidden(); | ||
} | ||
}); | ||
test("Login page contains GitHub button", async ({ page }) => { | ||
await expect(page.getByTestId("github-login-button")).toBeHidden(); | ||
}); | ||
|
||
test("Login page contains GitLab button", async ({ page }) => { | ||
await expect(page.getByTestId("gitlab-login-button")).toBeHidden(); | ||
}); | ||
}); |