-
-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
58 additions
and
42 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 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 |
---|---|---|
|
@@ -32,22 +32,31 @@ test.describe.serial(() => { | |
}); | ||
|
||
test.describe("new user", () => { | ||
test("user registration", async ({ page }) => { | ||
test("shows that user doesn't exist yet", async ({ page }) => { | ||
await page.goto("/login"); | ||
|
||
await page.getByText("Login or sign up in seconds").waitFor(); | ||
|
||
// your login page test logic | ||
await page | ||
.getByPlaceholder("[email protected]") | ||
.fill(testUserEmail); | ||
|
||
await page | ||
.getByRole("button", { name: "Continue with Email", exact: true }) | ||
.click(); | ||
await page.getByRole("button", { name: "Continue with Email" }).click(); | ||
|
||
// Make sure the user doesn't exist yet and that logging in is not possible | ||
await expect( | ||
page.getByText("A user with that email doesn't exist"), | ||
).toBeVisible(); | ||
}); | ||
|
||
test("user registration", async ({ page }) => { | ||
await page.goto("/register"); | ||
|
||
await page.getByText("Create your account").waitFor(); | ||
await page.getByText("Create Your Account").waitFor(); | ||
|
||
await page.getByPlaceholder("Jessie Smith").fill("Test User"); | ||
await page | ||
.getByPlaceholder("[email protected]") | ||
.fill(testUserEmail); | ||
|
||
await page.getByRole("button", { name: "Continue", exact: true }).click(); | ||
|
||
|
@@ -57,12 +66,29 @@ test.describe.serial(() => { | |
|
||
await codeInput.fill(code); | ||
|
||
await page.waitForURL("/"); | ||
await expect(page.getByText("Test User")).toBeVisible(); | ||
}); | ||
}); | ||
|
||
test.describe("existing user", () => { | ||
test("can login with magic link", async ({ browser, page }) => { | ||
test("can't register with the same email", async ({ page }) => { | ||
await page.goto("/register"); | ||
|
||
await page.getByText("Create Your Account").waitFor(); | ||
|
||
await page.getByPlaceholder("Jessie Smith").fill("Test User"); | ||
await page | ||
.getByPlaceholder("[email protected]") | ||
.fill(testUserEmail); | ||
|
||
await page.getByRole("button", { name: "Continue", exact: true }).click(); | ||
|
||
await expect( | ||
page.getByText("A user with that email already exists"), | ||
).toBeVisible(); | ||
}); | ||
|
||
test("can login with magic link", async ({ page }) => { | ||
await page.goto("/login"); | ||
|
||
await page | ||
|
@@ -81,17 +107,11 @@ test.describe.serial(() => { | |
throw new Error("Magic link not found"); | ||
} | ||
|
||
const newPage = await browser.newPage(); | ||
|
||
await newPage.goto(magicLink); | ||
|
||
await newPage | ||
.getByRole("button", { name: "Continue", exact: true }) | ||
.click(); | ||
await page.goto(magicLink); | ||
|
||
await newPage.waitForURL("/"); | ||
await page.getByRole("button", { name: "Login", exact: true }).click(); | ||
|
||
await expect(newPage.getByText("Test User")).toBeVisible(); | ||
await expect(page.getByText("Test User")).toBeVisible(); | ||
}); | ||
|
||
test("can login with verification code", async ({ page }) => { | ||
|
@@ -107,8 +127,6 @@ test.describe.serial(() => { | |
|
||
await page.getByPlaceholder("Enter your 6-digit code").fill(code); | ||
|
||
await page.waitForURL("/"); | ||
|
||
await expect(page.getByText("Test User")).toBeVisible(); | ||
}); | ||
|
||
|
@@ -125,8 +143,6 @@ test.describe.serial(() => { | |
|
||
await page.getByPlaceholder("Enter your 6-digit code").fill(code); | ||
|
||
await page.waitForURL("/"); | ||
|
||
await expect(page.getByText("Test User")).toBeVisible(); | ||
}); | ||
}); | ||
|