mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 08:51:09 -05:00
remove backend
This commit is contained in:
91
tests/e2e/test_auth.py
Normal file
91
tests/e2e/test_auth.py
Normal file
@@ -0,0 +1,91 @@
|
||||
from playwright.sync_api import expect, Page
|
||||
|
||||
|
||||
def test_login_page(page: Page):
|
||||
# Navigate to login page
|
||||
page.goto("http://localhost:8000/accounts/login/")
|
||||
|
||||
# Check login form elements
|
||||
expect(page.get_by_label("Username")).to_be_visible()
|
||||
expect(page.get_by_label("Password")).to_be_visible()
|
||||
expect(page.get_by_role("button", name="Sign In")).to_be_visible()
|
||||
|
||||
# Check social login buttons
|
||||
expect(page.get_by_role("link", name="Sign in with Google")).to_be_visible()
|
||||
expect(page.get_by_role("link", name="Sign in with Discord")).to_be_visible()
|
||||
|
||||
|
||||
def test_successful_login(page: Page):
|
||||
# Navigate to login page
|
||||
page.goto("http://localhost:8000/accounts/login/")
|
||||
|
||||
# Fill in login form
|
||||
page.get_by_label("Username").fill("testuser")
|
||||
page.get_by_label("Password").fill("testpass123")
|
||||
|
||||
# Click login button
|
||||
page.get_by_role("button", name="Sign In").click()
|
||||
|
||||
# Verify redirect to home page
|
||||
expect(page).to_have_url("http://localhost:8000/")
|
||||
expect(page.get_by_role("link", name="Profile")).to_be_visible()
|
||||
|
||||
|
||||
def test_failed_login(page: Page):
|
||||
# Navigate to login page
|
||||
page.goto("http://localhost:8000/accounts/login/")
|
||||
|
||||
# Fill in incorrect credentials
|
||||
page.get_by_label("Username").fill("wronguser")
|
||||
page.get_by_label("Password").fill("wrongpass")
|
||||
|
||||
# Click login button
|
||||
page.get_by_role("button", name="Sign In").click()
|
||||
|
||||
# Verify error message
|
||||
expect(page.get_by_text("Invalid username or password")).to_be_visible()
|
||||
|
||||
|
||||
def test_signup_page(page: Page):
|
||||
# Navigate to signup page
|
||||
page.goto("http://localhost:8000/accounts/signup/")
|
||||
|
||||
# Check signup form elements
|
||||
expect(page.get_by_label("Username")).to_be_visible()
|
||||
expect(page.get_by_label("Email")).to_be_visible()
|
||||
expect(page.get_by_label("Password")).to_be_visible()
|
||||
expect(page.get_by_label("Password (again)")).to_be_visible()
|
||||
expect(page.get_by_role("button", name="Sign Up")).to_be_visible()
|
||||
|
||||
|
||||
def test_successful_signup(page: Page):
|
||||
# Navigate to signup page
|
||||
page.goto("http://localhost:8000/accounts/signup/")
|
||||
|
||||
# Fill in signup form
|
||||
page.get_by_label("Username").fill("newuser")
|
||||
page.get_by_label("Email").fill("newuser@example.com")
|
||||
page.get_by_label("Password").fill("newpass123")
|
||||
page.get_by_label("Password (again)").fill("newpass123")
|
||||
|
||||
# Click signup button
|
||||
page.get_by_role("button", name="Sign Up").click()
|
||||
|
||||
# Verify redirect to home page
|
||||
expect(page).to_have_url("http://localhost:8000/")
|
||||
expect(page.get_by_role("link", name="Profile")).to_be_visible()
|
||||
|
||||
|
||||
def test_logout(page: Page):
|
||||
# First login
|
||||
page.goto("http://localhost:8000/accounts/login/")
|
||||
page.get_by_label("Username").fill("testuser")
|
||||
page.get_by_label("Password").fill("testpass123")
|
||||
page.get_by_role("button", name="Sign In").click()
|
||||
|
||||
# Click logout
|
||||
page.get_by_role("link", name="Logout").click()
|
||||
|
||||
# Verify redirect to home page and logged out state
|
||||
expect(page).to_have_url("http://localhost:8000/")
|
||||
expect(page.get_by_role("link", name="Login")).to_be_visible()
|
||||
Reference in New Issue
Block a user