Files
NextEdu/tests/e2e/auth-business-flow.spec.ts
SpecialX 99f116cb64
Some checks failed
CI / build-deploy (push) Has been cancelled
=test_update_homework_tests_and_work_log
2026-03-19 13:16:49 +08:00

28 lines
1.1 KiB
TypeScript

import { expect, test } from "@playwright/test"
test.describe("auth business flow", () => {
test("register then login and reach protected area", async ({ page }) => {
test.skip(!process.env.DATABASE_URL, "requires DATABASE_URL for write-flow verification")
const id = Date.now()
const email = `e2e.user.${id}@example.com`
const password = "e2e-pass-123456"
await page.goto("/register")
await page.getByLabel("Full Name").fill("E2E User")
await page.getByLabel("Email").fill(email)
await page.getByLabel("Password").fill(password)
await page.getByRole("button", { name: "Create Account" }).click()
await expect(page).toHaveURL(/\/login(?:$|[/?#])/)
await page.getByLabel("Email").fill(email)
await page.getByLabel("Password").fill(password)
await page.getByRole("button", { name: "Sign In with Email" }).click()
await expect(page).toHaveURL(/\/(dashboard|student\/dashboard)(?:$|[/?#])/)
const profileResponse = await page.goto("/profile")
expect(profileResponse?.status() ?? 200).toBeLessThan(500)
await expect(page).not.toHaveURL(/\/login(?:$|[/?#])/)
})
})