Files
fast_api_template/frontend/tests/utils/user.ts
T

36 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-09-09 14:45:10 +02:00
import { expect, type Page } from "@playwright/test"
2024-07-30 09:09:57 -05:00
export async function signUpNewUser(
page: Page,
name: string,
email: string,
password: string,
) {
await page.goto("/signup")
2025-12-07 13:21:13 +01:00
await page.getByTestId("full-name-input").fill(name)
await page.getByTestId("email-input").fill(email)
await page.getByTestId("password-input").fill(password)
await page.getByTestId("confirm-password-input").fill(password)
2024-07-30 09:09:57 -05:00
await page.getByRole("button", { name: "Sign Up" }).click()
await page.goto("/login")
}
export async function logInUser(page: Page, email: string, password: string) {
await page.goto("/login")
2025-12-07 13:21:13 +01:00
await page.getByTestId("email-input").fill(email)
await page.getByTestId("password-input").fill(password)
2024-07-30 09:09:57 -05:00
await page.getByRole("button", { name: "Log In" }).click()
await page.waitForURL("/")
await expect(
page.getByText("Welcome back, nice to see you again!"),
).toBeVisible()
}
2024-07-30 12:48:36 -05:00
export async function logOutUser(page: Page) {
await page.getByTestId("user-menu").click()
2024-07-30 09:09:57 -05:00
await page.getByRole("menuitem", { name: "Log out" }).click()
await page.goto("/login")
}