# retoor from datetime import datetime, timezone from playwright.sync_api import expect from tests.conftest import BASE_URL from devplacepy.database import get_table, refresh_snapshot from devplacepy.utils import generate_uid JSON = {"Accept": "application/json"} def _seed_votes(user_uid, count=4): now = datetime.now(timezone.utc).isoformat() table = get_table("notifications") for i in range(count): table.insert( { "uid": generate_uid(), "user_uid": user_uid, "type": "vote", "message": f"voter-{i} ++'d your post", "related_uid": user_uid, "target_url": "/posts/grouped-seed", "read": False, "created_at": now, } ) refresh_snapshot() def test_grouped_notifications_card(alice, seeded_db): page, user = alice uid = get_table("users").find_one(username=user["username"])["uid"] _seed_votes(uid) try: page.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded") card = page.locator("[data-notification-group]").first expect(card).to_be_visible(timeout=10000) expect(card.locator(".notif-group-count")).to_have_text("×4") finally: get_table("notifications").delete(user_uid=uid, target_url="/posts/grouped-seed") refresh_snapshot() def test_grouping_toggle_on_profile_notifications_tab(alice): page, user = alice username = user["username"] page.goto(f"{BASE_URL}/profile/{username}?tab=notifications", wait_until="domcontentloaded") panel = page.locator("[data-notif-prefs]") expect(panel.locator("form[action$='/notifications/grouping']")).to_be_attached() expect(panel.locator("form[action$='/notifications/throttling']")).to_be_attached() expect(page.locator("[data-enter-to-submit-card]")).to_be_attached()