chore: remove deprecated demo make target and update attachment thumbnail resolution
- Remove `make demo` target from Makefile, AGENTS.md, and README.md - Improve `_row_to_attachment` to glob for thumbnail files with any extension instead of hardcoding `.jpg` - Rewrite `cmd_attachments_prune` to use time-based cutoff and `delete_attachment` helper instead of orphan detection - Add cursor-based pagination to feed and notifications endpoints with `before` parameter - Track `did_upvote` flag in vote handler to only notify on new upvotes, not vote changes - Add `PAGE_SIZE` constant and `next_cursor` template variable to notifications page - Implement Playwright tests for notification pagination with 30 seeded notifications
This commit is contained in:
@@ -1,4 +1,69 @@
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from tests.conftest import BASE_URL
|
||||
from devplacepy.database import get_table
|
||||
from devplacepy.utils import generate_uid
|
||||
|
||||
|
||||
def test_notifications_pagination(alice):
|
||||
page, _ = alice
|
||||
alice_row = get_table("users").find_one(username="alice_test")
|
||||
notifications_table = get_table("notifications")
|
||||
notifications_table.delete(user_uid=alice_row["uid"])
|
||||
|
||||
now = datetime.now(timezone.utc)
|
||||
for i in range(30):
|
||||
notifications_table.insert({
|
||||
"uid": generate_uid(),
|
||||
"user_uid": alice_row["uid"],
|
||||
"type": "test",
|
||||
"message": f"pagination-test-msg-{i:02d}",
|
||||
"related_uid": alice_row["uid"],
|
||||
"target_url": "/feed",
|
||||
"read": False,
|
||||
"created_at": (now - timedelta(seconds=i)).isoformat(),
|
||||
})
|
||||
|
||||
page.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
|
||||
cards = page.locator(".notification-card")
|
||||
assert cards.count() == 25, f"expected 25 cards on page 1, got {cards.count()}"
|
||||
|
||||
load_more = page.locator(".load-more-wrap a")
|
||||
load_more.wait_for(state="visible", timeout=5000)
|
||||
href = load_more.get_attribute("href")
|
||||
assert href and "before=" in href, f"Load More should carry cursor: {href}"
|
||||
|
||||
page.goto(f"{BASE_URL}{href}", wait_until="domcontentloaded")
|
||||
cards2 = page.locator(".notification-card")
|
||||
assert cards2.count() == 5, f"expected 5 cards on page 2, got {cards2.count()}"
|
||||
assert page.locator(".load-more-wrap").count() == 0, "Load More should be absent on final page"
|
||||
|
||||
notifications_table.delete(user_uid=alice_row["uid"])
|
||||
|
||||
|
||||
def test_notifications_no_load_more_when_under_page_size(alice):
|
||||
page, _ = alice
|
||||
alice_row = get_table("users").find_one(username="alice_test")
|
||||
notifications_table = get_table("notifications")
|
||||
notifications_table.delete(user_uid=alice_row["uid"])
|
||||
|
||||
now = datetime.now(timezone.utc)
|
||||
for i in range(3):
|
||||
notifications_table.insert({
|
||||
"uid": generate_uid(),
|
||||
"user_uid": alice_row["uid"],
|
||||
"type": "test",
|
||||
"message": f"small-set-msg-{i}",
|
||||
"related_uid": alice_row["uid"],
|
||||
"target_url": "/feed",
|
||||
"read": False,
|
||||
"created_at": (now - timedelta(seconds=i)).isoformat(),
|
||||
})
|
||||
|
||||
page.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
|
||||
assert page.locator(".notification-card").count() == 3
|
||||
assert page.locator(".load-more-wrap").count() == 0
|
||||
|
||||
notifications_table.delete(user_uid=alice_row["uid"])
|
||||
|
||||
|
||||
def test_notifications_page_loads(alice):
|
||||
|
||||
Reference in New Issue
Block a user