🔧 Update Playwright config and tests to use env variables (#1266)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { type Page, expect, test } from "@playwright/test"
|
||||
import { firstSuperuser, firstSuperuserPassword } from "./config.ts"
|
||||
|
||||
test.use({ storageState: { cookies: [], origins: [] } })
|
||||
|
||||
@@ -46,7 +47,7 @@ test("Forgot Password link is visible", async ({ page }) => {
|
||||
test("Log in with valid email and password ", async ({ page }) => {
|
||||
await page.goto("/login")
|
||||
|
||||
await fillForm(page, "admin@example.com", "changethis")
|
||||
await fillForm(page, firstSuperuser, firstSuperuserPassword)
|
||||
await page.getByRole("button", { name: "Log In" }).click()
|
||||
|
||||
await page.waitForURL("/")
|
||||
@@ -59,7 +60,7 @@ test("Log in with valid email and password ", async ({ page }) => {
|
||||
test("Log in with invalid email", async ({ page }) => {
|
||||
await page.goto("/login")
|
||||
|
||||
await fillForm(page, "invalidemail", "changethis")
|
||||
await fillForm(page, "invalidemail", firstSuperuserPassword)
|
||||
await page.getByRole("button", { name: "Log In" }).click()
|
||||
|
||||
await expect(page.getByText("Invalid email address")).toBeVisible()
|
||||
@@ -67,8 +68,8 @@ test("Log in with invalid email", async ({ page }) => {
|
||||
|
||||
test("Log in with invalid password", async ({ page }) => {
|
||||
await page.goto("/login")
|
||||
|
||||
await fillForm(page, "admin@example.com", "changethat")
|
||||
// TODO: Add a random password utility
|
||||
await fillForm(page, firstSuperuser, "changethat")
|
||||
await page.getByRole("button", { name: "Log In" }).click()
|
||||
|
||||
await expect(page.getByText("Incorrect email or password")).toBeVisible()
|
||||
@@ -79,7 +80,7 @@ test("Log in with invalid password", async ({ page }) => {
|
||||
test("Successful log out", async ({ page }) => {
|
||||
await page.goto("/login")
|
||||
|
||||
await fillForm(page, "admin@example.com", "changethis")
|
||||
await fillForm(page, firstSuperuser, firstSuperuserPassword)
|
||||
await page.getByRole("button", { name: "Log In" }).click()
|
||||
|
||||
await page.waitForURL("/")
|
||||
@@ -96,7 +97,7 @@ test("Successful log out", async ({ page }) => {
|
||||
test("Logged-out user cannot access protected routes", async ({ page }) => {
|
||||
await page.goto("/login")
|
||||
|
||||
await fillForm(page, "admin@example.com", "changethis")
|
||||
await fillForm(page, firstSuperuser, firstSuperuserPassword)
|
||||
await page.getByRole("button", { name: "Log In" }).click()
|
||||
|
||||
await page.waitForURL("/")
|
||||
|
Reference in New Issue
Block a user