Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/dashboard/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Dashboard test package."""
47 changes: 47 additions & 0 deletions apps/dashboard/tests/test_dashboard_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Integration tests for the dashboard views."""

from __future__ import annotations

import pytest
from django.urls import reverse

from apps.roles.factories import RoleFactory
from apps.users.factories import CustomUserFactory


@pytest.mark.django_db
def test_dashboard_redirects_anonymous_users(client):
"""Anonymous users are redirected to login before viewing the dashboard."""
response = client.get(reverse("dashboard:index"))

assert response.status_code == 302
assert response["Location"].startswith(f"{reverse('users:login')}?next=")


@pytest.mark.django_db
def test_dashboard_renders_for_authenticated_user(client):
"""Authenticated users can view the dashboard shell and empty state."""
user = CustomUserFactory()
client.force_login(user)

response = client.get(reverse("dashboard:index"))

assert response.status_code == 200
assert b"Your study dashboard" in response.content
assert b"No study sessions yet" in response.content
assert b"No product roles have been assigned yet." in response.content


@pytest.mark.django_db
def test_dashboard_displays_roles_from_view_context(client):
"""Dashboard role display is presentation-only context from the view."""
user = CustomUserFactory()
role = RoleFactory(slug="learner", display_name="Learner")
user.studybuddy_roles.add(role)
client.force_login(user)

response = client.get(reverse("dashboard:index"))

assert response.status_code == 200
assert list(response.context["roles"]) == [role]
assert b"Learner" in response.content
6 changes: 3 additions & 3 deletions docs/sprint-runbook/sprint-1/sprint-1-day-4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
# - Docker Desktop or a compatible Docker daemon must be running.
# - This project copies source into the Docker image, so the script rebuilds
# the web service before verification.
# - Current expected isolated pytest baseline: 40 tests collected/passing.
# - Current expected isolated pytest baseline: 48 tests collected/passing.

set -euo pipefail

PROJECT_ROOT="$(git rev-parse --show-toplevel)"
EXPECTED_ROOT_NAME="StudyBuddy-Study-Planner-Project"
SIGNUP_EMAIL="thursday.user@example.com"
LOGIN_EMAIL="thursday.login@example.com"
EXPECTED_TEST_COUNT=40
EXPECTED_TEST_COUNT=48

section() {
printf '\n==> %s\n' "$1"
Expand Down Expand Up @@ -342,6 +342,6 @@ Verified:
- Dashboard is the post-login product surface.
- Migrations remain clean and applied.
- Black and Ruff pass.
- The isolated pytest suite passes with 40 tests.
- The isolated pytest suite passes with 48 tests.

RECEIPT
Loading
Loading