Private
Public Access
The previous UI was plain unstyled lists. Rebuilt around what FreshRSS actually looks like (per reference screenshots): a persistent left sidebar (folders/feeds with unread counts, favourites, tags) and a single main column with a date-grouped article list, where clicking a title expands the full article inline in place rather than navigating to a separate page. - apps/core/context_processors.py: feeds the sidebar's folder/feed tree, tags, and starred count to every authenticated page in one shared query set, so base.html can render it without each view wiring it up. - apps/reader/views.py: date-grouped stream (itertools.groupby over the already-ordered queryset), ?feed=/?folder= scoping alongside the existing ?tag=, a bulk mark-all-read endpoint (bulk_create/update, not one UserArticleState per article), and article_inline — the htmx endpoint behind the inline expand, sharing its mark-read logic with the full article_detail view via _load_article_and_mark_read. - templates/reader/_article_inline.html returns the article content plus an out-of-band swap of _article_actions.html, so the row's read/star icons update immediately when an article is expanded and marked read. - static/js/stream.js: the accordion toggle (one article open at a time), calling htmx.ajax() directly rather than hx-* attributes so a second click on an already-open row can collapse it without re-fetching. - static/css/base.css: full FreshRSS-like dark theme (with a light variant under prefers-color-scheme) replacing the previous unstyled pass — sidebar, topbar search, row/icon states, inline-expand styling. Verified end to end against a running dev server: folder/feed/tag scoping, mark-all-read, the inline-expand mark-read side effect and its icon update, and — against config.settings.prod specifically — that no inline <script> crept back in anywhere (would silently break under the CSP added in the previous commit) and the CSP header is still present on every page. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
64 lines
2.4 KiB
Python
64 lines
2.4 KiB
Python
from unittest.mock import patch
|
|
|
|
import pytest
|
|
from django.urls import reverse
|
|
|
|
from apps.feeds.models import Feed, Subscription
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_dashboard_requires_staff(client, django_user_model):
|
|
django_user_model.objects.create_user("regular", password="pw-regular-123")
|
|
client.login(username="regular", password="pw-regular-123")
|
|
|
|
response = client.get(reverse("core:dashboard"))
|
|
assert response.status_code == 302
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_dashboard_lists_erroring_feeds(client, django_user_model):
|
|
admin = django_user_model.objects.create_user("admin", password="pw-admin-123", is_staff=True)
|
|
client.login(username="admin", password="pw-admin-123")
|
|
|
|
ok_feed = Feed.objects.create(feed_url="https://ok.example.com/feed", title="OK Feed")
|
|
broken_feed = Feed.objects.create(
|
|
feed_url="https://broken.example.com/feed",
|
|
title="Broken Feed",
|
|
last_fetch_status=Feed.STATUS_ERROR,
|
|
fetch_error_count=3,
|
|
last_error_message="Connection timed out",
|
|
)
|
|
Subscription.objects.create(user=admin, feed=ok_feed)
|
|
Subscription.objects.create(user=admin, feed=broken_feed)
|
|
|
|
response = client.get(reverse("core:dashboard"))
|
|
assert response.status_code == 200
|
|
assert b"Broken Feed" in response.content
|
|
assert b"Connection timed out" in response.content
|
|
# "OK Feed" legitimately appears elsewhere on the page (the sidebar
|
|
# lists every subscription), so check the dashboard's own error table
|
|
# scope via context rather than raw page content.
|
|
assert list(response.context["erroring_feeds"]) == [broken_feed]
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_retry_feed_resets_backoff_and_requeues(client, django_user_model):
|
|
django_user_model.objects.create_user("admin", password="pw-admin-123", is_staff=True)
|
|
client.login(username="admin", password="pw-admin-123")
|
|
|
|
feed = Feed.objects.create(
|
|
feed_url="https://broken.example.com/feed",
|
|
fetch_error_count=5,
|
|
last_fetch_status=Feed.STATUS_ERROR,
|
|
)
|
|
|
|
with (
|
|
patch("apps.core.views.reset_feed_backoff.delay") as mock_reset,
|
|
patch("apps.core.views.fetch_feed.delay") as mock_fetch,
|
|
):
|
|
response = client.post(reverse("core:retry_feed", args=[feed.id]))
|
|
|
|
assert response.status_code == 302
|
|
mock_reset.assert_called_once_with(feed.id)
|
|
mock_fetch.assert_called_once_with(feed.id)
|