Update
DevPlace CI / test (push) Has been cancelled

This commit is contained in:
2026-05-29 00:45:07 +02:00
parent 51832664c4
commit 3a4c6b14d5
10 changed files with 121 additions and 60 deletions
+65
View File
@@ -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):