From a95597f8645c5151998adb1df076786d33417c04 Mon Sep 17 00:00:00 2001 From: TripleU <182648541+TripleU613@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:35:50 -0500 Subject: [PATCH] Moderator-note notification spec: click through Playwright's locator The user menu's list re-renders after it opens (the notifications are marked seen), and a Capybara element found just before the click could still be detached by the time Playwright clicked it, failing main's system tests now and then. Playwright's locator looks the link up again on each try. Co-Authored-By: Claude Opus 5.5 --- spec/system/moderator_messages_spec.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/system/moderator_messages_spec.rb b/spec/system/moderator_messages_spec.rb index c4fbec27..270f9b3c 100644 --- a/spec/system/moderator_messages_spec.rb +++ b/spec/system/moderator_messages_spec.rb @@ -678,9 +678,12 @@ def navigate_to_topic(title) expect(link[:href]).to include("/t/") shot("95_mod_note_notification_in_user_menu") - # Found again: opening the menu marks the notifications seen, and the - # list can re-render between the checks above and the click. - find(".notification.custom a[title='Moderator note']", match: :first).click + # Opening the menu marks the notifications seen, and the list can + # re-render under a click, even one on a freshly found link. Playwright's + # locator finds the link again on each try; Capybara's element doesn't. + page.driver.with_playwright_page do |pw| + pw.locator(".notification.custom a[title='Moderator note']").first.click + end # Clicking the notification lands on the topic — at the note, the same # target the notes feed uses.