✨ Add private, local only, API for usage in E2E tests (#1429)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { expect, test } from "@playwright/test"
|
||||
import { firstSuperuser, firstSuperuserPassword } from "./config.ts"
|
||||
import { randomEmail, randomPassword } from "./utils/random"
|
||||
import { logInUser, logOutUser, signUpNewUser } from "./utils/user"
|
||||
import { logInUser, logOutUser } from "./utils/user"
|
||||
import { createUser } from "./utils/privateApi.ts"
|
||||
|
||||
const tabs = ["My profile", "Password", "Appearance"]
|
||||
|
||||
@@ -26,13 +27,11 @@ test.describe("Edit user full name and email successfully", () => {
|
||||
test.use({ storageState: { cookies: [], origins: [] } })
|
||||
|
||||
test("Edit user name with a valid name", async ({ page }) => {
|
||||
const fullName = "Test User"
|
||||
const email = randomEmail()
|
||||
const updatedName = "Test User 2"
|
||||
const password = randomPassword()
|
||||
|
||||
// Sign up a new user
|
||||
await signUpNewUser(page, fullName, email, password)
|
||||
await createUser({ email, password })
|
||||
|
||||
// Log in the user
|
||||
await logInUser(page, email, password)
|
||||
@@ -50,13 +49,11 @@ test.describe("Edit user full name and email successfully", () => {
|
||||
})
|
||||
|
||||
test("Edit user email with a valid email", async ({ page }) => {
|
||||
const fullName = "Test User"
|
||||
const email = randomEmail()
|
||||
const updatedEmail = randomEmail()
|
||||
const password = randomPassword()
|
||||
|
||||
// Sign up a new user
|
||||
await signUpNewUser(page, fullName, email, password)
|
||||
await createUser({ email, password })
|
||||
|
||||
// Log in the user
|
||||
await logInUser(page, email, password)
|
||||
@@ -77,13 +74,11 @@ test.describe("Edit user with invalid data", () => {
|
||||
test.use({ storageState: { cookies: [], origins: [] } })
|
||||
|
||||
test("Edit user email with an invalid email", async ({ page }) => {
|
||||
const fullName = "Test User"
|
||||
const email = randomEmail()
|
||||
const password = randomPassword()
|
||||
const invalidEmail = ""
|
||||
|
||||
// Sign up a new user
|
||||
await signUpNewUser(page, fullName, email, password)
|
||||
await createUser({ email, password })
|
||||
|
||||
// Log in the user
|
||||
await logInUser(page, email, password)
|
||||
@@ -97,13 +92,11 @@ test.describe("Edit user with invalid data", () => {
|
||||
})
|
||||
|
||||
test("Cancel edit action restores original name", async ({ page }) => {
|
||||
const fullName = "Test User"
|
||||
const email = randomEmail()
|
||||
const password = randomPassword()
|
||||
const updatedName = "Test User"
|
||||
|
||||
// Sign up a new user
|
||||
await signUpNewUser(page, fullName, email, password)
|
||||
const user = await createUser({ email, password })
|
||||
|
||||
// Log in the user
|
||||
await logInUser(page, email, password)
|
||||
@@ -114,18 +107,18 @@ test.describe("Edit user with invalid data", () => {
|
||||
await page.getByLabel("Full name").fill(updatedName)
|
||||
await page.getByRole("button", { name: "Cancel" }).first().click()
|
||||
await expect(
|
||||
page.getByLabel("My profile").getByText(fullName, { exact: true }),
|
||||
page
|
||||
.getByLabel("My profile")
|
||||
.getByText(user.full_name as string, { exact: true }),
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test("Cancel edit action restores original email", async ({ page }) => {
|
||||
const fullName = "Test User"
|
||||
const email = randomEmail()
|
||||
const password = randomPassword()
|
||||
const updatedEmail = randomEmail()
|
||||
|
||||
// Sign up a new user
|
||||
await signUpNewUser(page, fullName, email, password)
|
||||
await createUser({ email, password })
|
||||
|
||||
// Log in the user
|
||||
await logInUser(page, email, password)
|
||||
@@ -147,13 +140,11 @@ test.describe("Change password successfully", () => {
|
||||
test.use({ storageState: { cookies: [], origins: [] } })
|
||||
|
||||
test("Update password successfully", async ({ page }) => {
|
||||
const fullName = "Test User"
|
||||
const email = randomEmail()
|
||||
const password = randomPassword()
|
||||
const NewPassword = randomPassword()
|
||||
|
||||
// Sign up a new user
|
||||
await signUpNewUser(page, fullName, email, password)
|
||||
await createUser({ email, password })
|
||||
|
||||
// Log in the user
|
||||
await logInUser(page, email, password)
|
||||
@@ -177,13 +168,11 @@ test.describe("Change password with invalid data", () => {
|
||||
test.use({ storageState: { cookies: [], origins: [] } })
|
||||
|
||||
test("Update password with weak passwords", async ({ page }) => {
|
||||
const fullName = "Test User"
|
||||
const email = randomEmail()
|
||||
const password = randomPassword()
|
||||
const weakPassword = "weak"
|
||||
|
||||
// Sign up a new user
|
||||
await signUpNewUser(page, fullName, email, password)
|
||||
await createUser({ email, password })
|
||||
|
||||
// Log in the user
|
||||
await logInUser(page, email, password)
|
||||
@@ -201,14 +190,12 @@ test.describe("Change password with invalid data", () => {
|
||||
test("New password and confirmation password do not match", async ({
|
||||
page,
|
||||
}) => {
|
||||
const fullName = "Test User"
|
||||
const email = randomEmail()
|
||||
const password = randomPassword()
|
||||
const newPassword = randomPassword()
|
||||
const confirmPassword = randomPassword()
|
||||
|
||||
// Sign up a new user
|
||||
await signUpNewUser(page, fullName, email, password)
|
||||
await createUser({ email, password })
|
||||
|
||||
// Log in the user
|
||||
await logInUser(page, email, password)
|
||||
@@ -223,12 +210,10 @@ test.describe("Change password with invalid data", () => {
|
||||
})
|
||||
|
||||
test("Current password and new password are the same", async ({ page }) => {
|
||||
const fullName = "Test User"
|
||||
const email = randomEmail()
|
||||
const password = randomPassword()
|
||||
|
||||
// Sign up a new user
|
||||
await signUpNewUser(page, fullName, email, password)
|
||||
await createUser({ email, password })
|
||||
|
||||
// Log in the user
|
||||
await logInUser(page, email, password)
|
||||
|
Reference in New Issue
Block a user