Fix ElementClickInterceptedError in test_update_status_fails_for_admin

The test injects a submit button into a table row to simulate an
unauthorized PATCH request, verifying the server returns 422. The
button was obscured by a full-row <a class="link"> overlay, causing
Selenium to throw ElementClickInterceptedError.

Since the test exercises server-side authorization rather than UI
behavior, switched to a JS click via execute_script to bypass the
visual interception check.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-02 19:10:47 +00:00
parent 33004f62bd
commit 3019f0fbec

View File

@@ -229,7 +229,7 @@ class UsersTest < ApplicationSystemTestCase
user = User.find_by_email!(first(:link).text) user = User.find_by_email!(first(:link).text)
inject_button_to first('td:not(.link)'), "update status", user_path(user), method: :patch, inject_button_to first('td:not(.link)'), "update status", user_path(user), method: :patch,
params: {user: {status: User.statuses.keys.sample}}, data: {turbo: false} params: {user: {status: User.statuses.keys.sample}}, data: {turbo: false}
click_on "update status" execute_script("arguments[0].click()", find_button("update status"))
end end
assert_title 'The change you wanted was rejected (422)' assert_title 'The change you wanted was rejected (422)'
end end