-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #456 from Open-Earth-Foundation/feat/playwright
feat(ci): install Playwright for e2e tests and create e2e test for signup
- Loading branch information
Showing
12 changed files
with
733 additions
and
78 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
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 was deleted.
Oops, something went wrong.
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,90 @@ | ||
import { test, expect, type Page } from "@playwright/test"; | ||
import { randomUUID } from "node:crypto"; | ||
|
||
async function expectText(page: Page, text: string) { | ||
await expect(page.getByText(text).first()).toBeVisible(); | ||
} | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("/en/auth/signup"); | ||
}); | ||
|
||
test.describe("Signup", () => { | ||
test("should navigate to signup from login", async ({ page }) => { | ||
await page.goto("/"); | ||
const link = page.getByText("Sign up"); | ||
await expect(link).toBeVisible(); | ||
await link.click(); | ||
await expect( | ||
page.getByRole("heading", { name: "Sign Up to City Catalyst" }), | ||
).toBeVisible(); | ||
}); | ||
|
||
test("should redirect to dashboard after entering correct data", async ({ | ||
page, | ||
}) => { | ||
await expect( | ||
page.getByRole("heading", { name: "Sign Up to City Catalyst" }), | ||
).toBeVisible(); | ||
|
||
const email = `e2e-test+${randomUUID()}@example.com`; | ||
|
||
await page.getByPlaceholder("Your full name").fill("Test User"); | ||
await page.getByPlaceholder("e.g. youremail@domain.com").fill(email); | ||
await page.getByLabel("Password", { exact: true }).fill("Test123"); | ||
await page.getByLabel("Confirm Password").fill("Test123"); | ||
await page.getByPlaceholder("Enter the code you received").fill("123456"); | ||
await page | ||
.locator('input[name="acceptTerms"] + .chakra-checkbox__control') | ||
.click(); | ||
await page.getByRole("button", { name: "Create Account" }).click(); | ||
|
||
await expect(page).toHaveURL( | ||
`/en/auth/check-email?email=${email.replace("@", "%40")}`, | ||
); | ||
}); | ||
|
||
test("should show errors when entering invalid data", async ({ page }) => { | ||
await expect( | ||
page.getByRole("heading", { name: "Sign Up to City Catalyst" }), | ||
).toBeVisible(); | ||
|
||
await page.getByPlaceholder("Your full name").fill("asd"); | ||
await page | ||
.getByPlaceholder("e.g. youremail@domain.com") | ||
.fill("testopenearthorg"); | ||
await page.getByLabel("Password", { exact: true }).fill("Pas"); | ||
await page.getByLabel("Confirm Password").fill("Pa1"); | ||
await page.getByPlaceholder("Enter the code you received").fill("12345"); | ||
await page.getByRole("button", { name: "Create Account" }).click(); | ||
|
||
await expect(page).toHaveURL(`/en/auth/signup`); | ||
await expectText(page, "valid email address"); | ||
await expectText(page, "Minimum length"); | ||
await expectText(page, "Invalid invite code"); | ||
await expectText(page, "Please accept the terms"); | ||
}); | ||
|
||
test("should require matching passwords", async ({ page }) => { | ||
await expect( | ||
page.getByRole("heading", { name: "Sign Up to City Catalyst" }), | ||
).toBeVisible(); | ||
|
||
await page.getByPlaceholder("Your full name").fill("Test Account"); | ||
await page | ||
.getByPlaceholder("e.g. youremail@domain.com") | ||
.fill("e2e-test-fail@example.com"); | ||
await page.getByLabel("Password", { exact: true }).fill("Password1"); | ||
await page.getByLabel("Confirm Password").fill("Password2"); | ||
await page.getByPlaceholder("Enter the code you received").fill("123456"); | ||
await page | ||
.locator('input[name="acceptTerms"] + .chakra-checkbox__control') // sibling | ||
.click(); | ||
await page.getByRole("button", { name: "Create Account" }).click(); | ||
|
||
await expect(page).toHaveURL(`/en/auth/signup`); | ||
await expectText(page, "Passwords don't match"); | ||
}); | ||
|
||
test.skip("should correctly handle and pass callbackUrl", () => {}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.