discourse/spec/system/page_objects/modals/bulk_user_delete_confirmation.rb
Régis Hanol e1a47e7311
FIX: Make confirmation phrase matching locale-safe (#38923)
The bulk user delete confirmation button remained permanently disabled
for locales with uppercase characters in the confirmation phrase (e.g.
German's "2 Benutzer löschen"). The input was lowercased via
`toLowerCase()` but the expected i18n phrase was not, so the comparison
always failed. English worked by coincidence since "delete 2 users" is
already lowercase.

Replace `toLowerCase()` with `toLocaleLowerCase()` on both sides of the
comparison to handle locale-specific casing rules (e.g. Turkish İ/ı).
Apply the same fix to the second-factor disable confirmation which used
a strict exact match with no case normalization at all.

Also fix a pre-existing typo: `fill_in_confirmation_phase` →
`fill_in_confirmation_phrase` in the page object and specs.

Ref - t/180698
2026-03-27 16:38:57 +01:00

72 lines
1.9 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Modals
class BulkUserDeleteConfirmation < Base
MODAL_SELECTOR = ".bulk-user-delete-confirmation"
def confirm
confirm_button.click
end
def confirm_button
within(modal) { find(".btn.confirm-delete") }
end
def block_ip_and_email_checkbox
within(modal) { find("input.block-ip-and-email") }
end
def has_confirm_button_disabled?
within(modal) { has_css?(".btn.confirm-delete[disabled]") }
end
def has_confirm_button_enabled?
within(modal) do
has_no_css?(".btn.confirm-delete[disabled]") && has_css?(".btn.confirm-delete")
end
end
def fill_in_confirmation_phrase(user_count:, upcase: false)
phrase =
I18n.t(
"admin_js.admin.users.bulk_actions.delete.confirmation_modal.confirmation_phrase",
count: user_count,
)
phrase = phrase.upcase if upcase
within(modal) { find("input.confirmation-phrase").fill_in(with: phrase) }
end
def has_successful_log_entry_for_user?(user:, position:, total:)
within(modal) do
has_css?(
".bulk-user-delete-confirmation__progress-line.-success",
text:
I18n.t(
"admin_js.admin.users.bulk_actions.delete.confirmation_modal.user_delete_succeeded",
position:,
total:,
username: user.username,
),
)
end
end
def has_no_error_log_entries?
within(modal) { has_no_css?(".bulk-user-delete-confirmation__progress-line.-error") }
end
def has_error_log_entry?(message)
within(modal) do
has_css?(".bulk-user-delete-confirmation__progress-line.-error", text: message)
end
end
private
def modal
find(MODAL_SELECTOR)
end
end
end
end