forked from nextjs/saas-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
dc17951
commit cb4b938
Showing
3 changed files
with
200 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,59 +10,182 @@ test.describe("User Journey Tests", () => { | |
name: "Your Ultimate Prep Tool for the Ontario Bar Exam", | ||
}) | ||
).toBeVisible(); | ||
await page.getByRole("button", { name: "Get Started" }).first().click(); | ||
await page | ||
.getByRole("button", { name: "Start My 7 Days Free Trial" }) | ||
.first() | ||
.click(); | ||
}); | ||
|
||
test("should fill in Payment details", async ({ page }) => { | ||
test("check website links", async ({ page }) => { | ||
await page.goto("http://localhost:3000/sign-in"); | ||
await page.getByPlaceholder("Enter your email").click(); | ||
await page | ||
.getByPlaceholder("Enter your email") | ||
.fill("[email protected]"); | ||
await page.getByPlaceholder("Enter your email").press("Tab"); | ||
await page.getByPlaceholder("Enter your password").fill("12345678"); | ||
await page.getByRole("button", { name: "Sign in" }).click(); | ||
|
||
// Increase timeout for visibility checks | ||
await expect( | ||
page.getByRole("heading", { name: "Bar Exam Practice Dashboard" }) | ||
).toBeVisible({ timeout: 10000 }); | ||
await expect(page.getByRole("link", { name: "BarQuest" })).toBeVisible({ | ||
timeout: 10000, | ||
}); | ||
await expect(page.getByRole("button", { name: "Dashboard" })).toBeVisible({ | ||
timeout: 10000, | ||
}); | ||
await expect( | ||
page | ||
.getByRole("navigation") | ||
.getByRole("button", { name: "Create a New Test" }) | ||
).toBeVisible({ timeout: 10000 }); | ||
await expect(page.getByRole("button", { name: "User Guide" })).toBeVisible({ | ||
timeout: 10000, | ||
}); | ||
await expect( | ||
page.getByRole("button", { name: "My Subscription" }) | ||
).toBeVisible({ timeout: 10000 }); | ||
await expect(page.getByRole("button", { name: "Settings" })).toBeVisible({ | ||
timeout: 10000, | ||
}); | ||
await page | ||
.getByRole("main") | ||
.getByRole("button", { name: "Create a New Test" }) | ||
.click(); | ||
await expect(page.getByRole("heading", { name: "Test Mode" })).toBeVisible({ | ||
timeout: 10000, | ||
}); | ||
await expect(page.getByRole("heading", { name: "Subjects" })).toBeVisible({ | ||
timeout: 10000, | ||
}); | ||
await expect( | ||
page.getByRole("heading", { name: "Max Number of Questions" }) | ||
).toBeVisible({ timeout: 10000 }); | ||
await expect(page.getByRole("button", { name: "Create Test" })).toBeVisible( | ||
{ timeout: 10000 } | ||
); | ||
await expect(page.getByLabel("Tutor")).toBeVisible({ timeout: 10000 }); | ||
await expect(page.getByLabel("Timed")).toBeVisible({ timeout: 10000 }); | ||
await page.getByRole("button", { name: "User Guide" }).click(); | ||
await expect( | ||
page.getByRole("heading", { name: "User Guide and Study" }) | ||
).toBeVisible({ timeout: 10000 }); | ||
await page.getByRole("button", { name: "My Subscription" }).click(); | ||
await expect( | ||
page.getByRole("heading", { name: "Subscription" }) | ||
).toBeVisible({ timeout: 10000 }); | ||
await expect( | ||
page.getByRole("button", { name: "Manage Subscription" }) | ||
).toBeVisible({ timeout: 10000 }); | ||
await page.getByRole("button", { name: "Settings" }).click(); | ||
await expect( | ||
page.getByRole("heading", { name: "General Settings" }) | ||
).toBeVisible({ timeout: 10000 }); | ||
await expect( | ||
page.getByRole("button", { name: "Save Changes" }) | ||
).toBeVisible({ timeout: 10000 }); | ||
await expect( | ||
page.getByRole("heading", { name: "Security Settings" }) | ||
).toBeVisible({ timeout: 10000 }); | ||
await expect( | ||
page.getByRole("heading", { name: "Delete Account" }) | ||
).toBeVisible({ timeout: 10000 }); | ||
}); | ||
|
||
test("should fill in Payment details and delete account", async ({ | ||
page, | ||
}) => { | ||
await page.goto("http://localhost:3000/"); | ||
await page.getByRole("button", { name: "Get Started" }).first().click(); | ||
await page | ||
.getByRole("button", { name: "Start My 7 Days Free Trial" }) | ||
.first() | ||
.click(); | ||
await page.getByPlaceholder("Enter your email").fill("[email protected]"); | ||
await page.getByPlaceholder("Enter your password").fill("12345678"); | ||
await page.getByRole("button", { name: "Sign up" }).click(); | ||
await page.getByLabel("Email").click(); | ||
await expect( | ||
page.getByText("Enter payment details", { exact: true }) | ||
).toBeVisible({ timeout: 10000 }); | ||
|
||
await page.getByPlaceholder("1234 1234 1234").fill("4242 4242 4242 42424"); | ||
await page.getByPlaceholder("1234 1234 1234").press("Tab"); | ||
await page.getByPlaceholder("MM / YY").fill("09 / 29"); | ||
await page.getByPlaceholder("MM / YY").press("Tab"); | ||
await page.getByPlaceholder("CVC").fill("454"); | ||
await page.getByPlaceholder("CVC").press("Tab"); | ||
await page.getByPlaceholder("Full name on card").fill("teste "); | ||
await page.getByPlaceholder("Full name on card").press("Tab"); | ||
await page.getByLabel("Country or region").selectOption("KH"); | ||
await page.getByLabel("Country or region").selectOption("CA"); | ||
await page.locator("body").press("Tab"); | ||
await page.getByPlaceholder("Postal code").click(); | ||
await page.getByPlaceholder("Postal code").fill("M2P 2P2"); | ||
await page.getByPlaceholder("Postal code").press("Tab"); | ||
await page.getByTestId("hosted-payment-submit-button").click(); | ||
await page.getByLabel("Email").fill("[email protected]"); | ||
await page.getByTestId("hosted-payment-submit-button").click(); | ||
//wait for a redirection to the dashboard | ||
// Check for the error message | ||
const errorMessage = page.locator( | ||
"text=Failed to create user. Please try again." | ||
); | ||
if (await errorMessage.isVisible()) { | ||
// Navigate to the login page and log in | ||
await page.goto("http://localhost:3000/sign-in"); | ||
await page.getByPlaceholder("Enter your email").fill("[email protected]"); | ||
await page.getByPlaceholder("Enter your password").fill("12345678"); | ||
await page.getByRole("button", { name: "Sign in" }).click(); | ||
} else { | ||
// Continue with the sign-up process | ||
await page.waitForSelector("text=Enter payment details", { | ||
timeout: 20000, | ||
}); | ||
await page.getByPlaceholder("1234 1234 1234").fill("4242 4242 4242 4242"); | ||
await page.getByPlaceholder("1234 1234 1234").press("Tab"); | ||
await page.getByPlaceholder("MM / YY").fill("09 / 29"); | ||
await page.getByPlaceholder("MM / YY").press("Tab"); | ||
await page.getByPlaceholder("CVC").fill("454"); | ||
await page.getByPlaceholder("CVC").press("Tab"); | ||
await page.getByPlaceholder("Full name on card").fill("teste "); | ||
await page.getByPlaceholder("Full name on card").press("Tab"); | ||
await page.getByLabel("Country or region").selectOption("KH"); | ||
await page.getByLabel("Country or region").selectOption("CA"); | ||
await page.locator("body").press("Tab"); | ||
await page.getByPlaceholder("Postal code").click(); | ||
await page.getByPlaceholder("Postal code").fill("M2P 2P2"); | ||
await page.getByPlaceholder("Postal code").press("Tab"); | ||
await page.getByTestId("hosted-payment-submit-button").click(); | ||
await page.getByLabel("Email").fill("[email protected]"); | ||
await page.getByTestId("hosted-payment-submit-button").click(); | ||
} | ||
|
||
// Wait for a redirection to the dashboard | ||
await page.waitForURL("http://localhost:3000/dashboard"); | ||
await expect( | ||
page.getByRole("heading", { name: "Bar Exam Practice Dashboard" }) | ||
).toBeVisible({ timeout: 15000 }); | ||
await expect( | ||
page.getByRole("main").getByRole("button", { name: "Create a New Test" }) | ||
).toBeVisible(); | ||
}); | ||
).toBeVisible({ timeout: 15000 }); | ||
|
||
test("should delete account", async ({ page }) => { | ||
// Proceed to delete the account | ||
await page.goto("http://localhost:3000/sign-in"); | ||
await page.getByPlaceholder("Enter your email").fill("[email protected]"); | ||
await page.getByPlaceholder("Enter your email").press("Tab"); | ||
await page.getByPlaceholder("Enter your password").fill("12345678"); | ||
await page.getByRole("button", { name: "Sign in" }).click(); | ||
|
||
// Check if login was successful | ||
const loginError = page.locator("text=Invalid email or password."); | ||
if (await loginError.isVisible()) { | ||
// Navigate to the sign-up page and sign up | ||
await page.goto("http://localhost:3000/sign-up"); | ||
await page.getByPlaceholder("Enter your email").fill("[email protected]"); | ||
await page.getByPlaceholder("Enter your password").fill("12345678"); | ||
await page.getByRole("button", { name: "Sign up" }).click(); | ||
|
||
// Continue with the sign-up process | ||
// Wait for a redirection to the dashboard | ||
await page.waitForURL("http://localhost:3000/dashboard"); | ||
await expect( | ||
page.getByRole("heading", { name: "Bar Exam Practice Dashboard" }) | ||
).toBeVisible({ timeout: 25000 }); | ||
await expect( | ||
page | ||
.getByRole("main") | ||
.getByRole("button", { name: "Create a New Test" }) | ||
).toBeVisible({ timeout: 25000 }); | ||
} | ||
|
||
// Proceed to delete the account | ||
await page.waitForURL("http://localhost:3000/dashboard"); | ||
await page.getByRole("button", { name: "Settings" }).click(); | ||
await page.getByLabel("Confirm Password").click(); | ||
await page.getByLabel("Confirm Password").fill("12345678"); | ||
await page.getByRole("button", { name: "Delete Account" }).click(); | ||
await expect( | ||
page.getByRole("heading", { name: "Sign in to your account" }) | ||
).toBeVisible(); | ||
).toBeVisible({ timeout: 15000 }); | ||
}); | ||
}); |