feat: Implement initial schema and add various API, service, and management command enhancements across the application.

This commit is contained in:
pacnpal
2026-01-01 15:13:01 -05:00
parent c95f99ca10
commit b243b17af7
413 changed files with 11164 additions and 17433 deletions

View File

@@ -44,9 +44,7 @@ class TestUserRegistration:
# Should redirect to success page or login
page.wait_for_url("**/*", timeout=5000)
def test__registration__duplicate_username__shows_error(
self, page: Page, live_server, regular_user
):
def test__registration__duplicate_username__shows_error(self, page: Page, live_server, regular_user):
"""Test registration with duplicate username shows error."""
page.goto(f"{live_server.url}/accounts/signup/")
@@ -100,9 +98,7 @@ class TestUserLogin:
expect(page.get_by_label("Password")).to_be_visible()
expect(page.get_by_role("button", name="Sign In")).to_be_visible()
def test__login__valid_credentials__authenticates(
self, page: Page, live_server, regular_user
):
def test__login__valid_credentials__authenticates(self, page: Page, live_server, regular_user):
"""Test login with valid credentials authenticates user."""
page.goto(f"{live_server.url}/accounts/login/")
@@ -130,9 +126,7 @@ class TestUserLogin:
"""Test login page has remember me checkbox."""
page.goto(f"{live_server.url}/accounts/login/")
remember_me = page.locator(
"input[name='remember'], input[type='checkbox'][id*='remember']"
)
remember_me = page.locator("input[name='remember'], input[type='checkbox'][id*='remember']")
if remember_me.count() > 0:
expect(remember_me.first).to_be_visible()
@@ -147,9 +141,7 @@ class TestUserLogout:
# User is already logged in via auth_page fixture
# Find and click logout button/link
logout = auth_page.locator(
"a[href*='logout'], button:has-text('Log Out'), button:has-text('Sign Out')"
)
logout = auth_page.locator("a[href*='logout'], button:has-text('Log Out'), button:has-text('Sign Out')")
if logout.count() > 0:
logout.first.click()
@@ -172,14 +164,10 @@ class TestPasswordReset:
"""Test password reset page displays the form."""
page.goto(f"{live_server.url}/accounts/password/reset/")
email_input = page.locator(
"input[type='email'], input[name='email']"
)
email_input = page.locator("input[type='email'], input[name='email']")
expect(email_input.first).to_be_visible()
def test__password_reset__valid_email__shows_confirmation(
self, page: Page, live_server, regular_user
):
def test__password_reset__valid_email__shows_confirmation(self, page: Page, live_server, regular_user):
"""Test password reset with valid email shows confirmation."""
page.goto(f"{live_server.url}/accounts/password/reset/")
@@ -192,9 +180,7 @@ class TestPasswordReset:
page.wait_for_timeout(500)
# Look for success message or confirmation page
success = page.locator(
".success, .alert-success, [role='alert']"
)
success = page.locator(".success, .alert-success, [role='alert']")
# Or check URL changed to done page
if success.count() == 0:
@@ -216,9 +202,7 @@ class TestUserProfile:
"""Test profile page has edit profile link/button."""
auth_page.goto(f"{live_server.url}/accounts/profile/")
edit_link = auth_page.locator(
"a[href*='edit'], button:has-text('Edit')"
)
edit_link = auth_page.locator("a[href*='edit'], button:has-text('Edit')")
if edit_link.count() > 0:
expect(edit_link.first).to_be_visible()
@@ -228,9 +212,7 @@ class TestUserProfile:
auth_page.goto(f"{live_server.url}/accounts/profile/edit/")
# Find bio/about field if present
bio_field = auth_page.locator(
"textarea[name='bio'], textarea[name='about']"
)
bio_field = auth_page.locator("textarea[name='bio'], textarea[name='about']")
if bio_field.count() > 0:
bio_field.first.fill("Updated bio from E2E test")
@@ -245,18 +227,14 @@ class TestUserProfile:
class TestProtectedRoutes:
"""E2E tests for protected route access."""
def test__protected_route__unauthenticated__redirects_to_login(
self, page: Page, live_server
):
def test__protected_route__unauthenticated__redirects_to_login(self, page: Page, live_server):
"""Test accessing protected route redirects to login."""
page.goto(f"{live_server.url}/accounts/profile/")
# Should redirect to login
expect(page).to_have_url("**/login/**")
def test__protected_route__authenticated__allows_access(
self, auth_page: Page, live_server
):
def test__protected_route__authenticated__allows_access(self, auth_page: Page, live_server):
"""Test authenticated user can access protected routes."""
auth_page.goto(f"{live_server.url}/accounts/profile/")
@@ -270,9 +248,7 @@ class TestProtectedRoutes:
# Should show login or forbidden
# Admin login page or 403
def test__moderator_route__moderator__allows_access(
self, mod_page: Page, live_server
):
def test__moderator_route__moderator__allows_access(self, mod_page: Page, live_server):
"""Test moderator can access moderation routes."""
mod_page.goto(f"{live_server.url}/moderation/")