diff --git a/apps/reader/tests.py b/apps/reader/tests.py index 8f80527..ea8c6e1 100644 --- a/apps/reader/tests.py +++ b/apps/reader/tests.py @@ -1,3 +1,5 @@ +import re + import pytest from django.contrib.auth import get_user_model from django.urls import reverse @@ -188,3 +190,30 @@ def test_sidebar_shows_a_tags_total_unread_count(client, alice): # The only "7" on the page — the individual feeds show 3 and 4. content = response.content.decode() assert '7' in content + + +@pytest.mark.django_db +def test_article_rows_carry_their_utc_instant_for_client_side_date_grouping(client, alice): + """The server still groups date headers in UTC, but ships each row's + raw UTC instant so date-groups.js can rebuild the headers using the + viewer's local calendar day instead.""" + from django.utils import timezone + + feed = Feed.objects.create(feed_url="https://example.com/feed.xml") + Subscription.objects.create(user=alice, feed=feed) + dated = Article.objects.create( + feed=feed, guid="dated", title="Dated", published_at=timezone.now() + ) + undated = Article.objects.create(feed=feed, guid="undated", title="Undated") + + client.login(username="alice", password="pw-alice-123") + response = client.get(reverse("reader:stream"), {"filter": "all"}) + content = response.content.decode() + + expected_iso = dated.published_at.isoformat() + assert f'id="article-{dated.pk}"' in content + assert f'data-published-utc="{expected_iso}"' in content + + undated_row = re.search(rf'