Skip to content

Commit

Permalink
feat(e2e): add more tests for signup page
Browse files Browse the repository at this point in the history
  • Loading branch information
lemilonkh committed Apr 24, 2024
1 parent 92558f2 commit 72438d4
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion app/e2e/signup.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
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)).toBeVisible();
}

test.beforeEach(async ({ page }) => {
await page.goto("/en/auth/signup");
});
Expand All @@ -19,7 +23,6 @@ test.describe("Signup", () => {
test("should redirect to dashboard after entering correct data", async ({
page,
}) => {
// await page.goto("http://localhost:3000/en/auth/signup");
await expect(
page.getByRole("heading", { name: "Sign Up to City Catalyst" }),
).toBeVisible();
Expand All @@ -41,5 +44,45 @@ test.describe("Signup", () => {
);
});

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");
await expectText(page, "Passwords don't match");
});

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("testopenearthorg");
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.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", () => {});
});

0 comments on commit 72438d4

Please sign in to comment.