feat: replace JS card-link data-href with CSS overlay and add DOMPurify sanitizer
This commit is contained in:
+11
-11
@@ -391,12 +391,12 @@ def test_comment_notification_click_opens_comment(app_server, browser, seeded_db
|
||||
pb.wait_for_timeout(1500)
|
||||
|
||||
pa.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
|
||||
card = pa.locator(".notification-card[data-href]").filter(has_text="commented on your post").first
|
||||
card = pa.locator(".notification-card").filter(has_text="commented on your post").first
|
||||
card.wait_for(state="visible", timeout=10000)
|
||||
href = card.get_attribute("data-href")
|
||||
assert href.startswith("/notifications/open/"), f"unexpected data-href: {href}"
|
||||
href = card.locator("a.card-link").get_attribute("href")
|
||||
assert href.startswith("/notifications/open/"), f"unexpected href: {href}"
|
||||
|
||||
card.locator(".notification-text").click()
|
||||
card.locator("a.card-link").click()
|
||||
pa.wait_for_url("**/posts/**", timeout=10000, wait_until="domcontentloaded")
|
||||
assert "#comment-" in pa.url, f"click did not deep-link to a comment: {pa.url}"
|
||||
|
||||
@@ -406,7 +406,7 @@ def test_comment_notification_click_opens_comment(app_server, browser, seeded_db
|
||||
|
||||
pa.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
|
||||
pa.wait_for_timeout(1000)
|
||||
target = pa.locator(f'.notification-card[data-href="{href}"]')
|
||||
target = pa.locator(f'.notification-card:has(a.card-link[href="{href}"])')
|
||||
target.wait_for(state="visible", timeout=10000)
|
||||
assert "unread" not in (target.get_attribute("class") or ""), "opening a notification should mark it read"
|
||||
|
||||
@@ -434,9 +434,9 @@ def test_follow_notification_click_opens_profile(app_server, browser, seeded_db)
|
||||
pb.wait_for_timeout(1000)
|
||||
|
||||
pa.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
|
||||
card = pa.locator(".notification-card[data-href]").filter(has_text="started following you").first
|
||||
card = pa.locator(".notification-card").filter(has_text="started following you").first
|
||||
card.wait_for(state="visible", timeout=10000)
|
||||
card.locator(".notification-text").click()
|
||||
card.locator("a.card-link").click()
|
||||
pa.wait_for_url("**/profile/bob_test", timeout=10000, wait_until="domcontentloaded")
|
||||
assert pa.url.endswith("/profile/bob_test"), f"follow notification should open the follower profile: {pa.url}"
|
||||
|
||||
@@ -465,9 +465,9 @@ def test_message_notification_click_opens_conversation(app_server, browser, seed
|
||||
pb.wait_for_timeout(1500)
|
||||
|
||||
pa.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
|
||||
card = pa.locator(".notification-card[data-href]").filter(has_text="sent you a message").first
|
||||
card = pa.locator(".notification-card").filter(has_text="sent you a message").first
|
||||
card.wait_for(state="visible", timeout=10000)
|
||||
card.locator(".notification-text").click()
|
||||
card.locator("a.card-link").click()
|
||||
pa.wait_for_url("**/messages**", timeout=10000, wait_until="domcontentloaded")
|
||||
assert "with_uid=" in pa.url, f"message notification should open the conversation: {pa.url}"
|
||||
|
||||
@@ -503,9 +503,9 @@ def test_vote_notification_click_opens_target(app_server, browser, seeded_db):
|
||||
pa.wait_for_timeout(1500)
|
||||
|
||||
pb.goto(f"{BASE_URL}/notifications", wait_until="domcontentloaded")
|
||||
card = pb.locator(".notification-card[data-href]").filter(has_text="++'d").first
|
||||
card = pb.locator(".notification-card").filter(has_text="++'d").first
|
||||
card.wait_for(state="visible", timeout=10000)
|
||||
card.locator(".notification-text").click()
|
||||
card.locator("a.card-link").click()
|
||||
pb.wait_for_url(f"**{post_path}", timeout=10000, wait_until="domcontentloaded")
|
||||
assert post_path in pb.url, f"vote notification should open the voted post: {pb.url}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user