discourse/spec/system/page_objects/pages/user_invited_expired.rb
Linca 826dda2d52
FIX: Show bulk removal of expired invites (#33716)
An existing codepath to bulk delete invites exists, but does not show
up. This commit fixes it and also fixes the old code's bug.

Specifically,
- `destroy_all_expired` endpoint only acts on the `current_user` which
is absolutely counter-intuitive, when a person visits another person’s
profile and is able to see the button, clicking it would delete their
own invites and not those of the profile they are visiting.
- In `UserInvitedShowController` the removedAll state is never set to
the original state, which results in the link being displayed in the
list when the new link expires, but the batch deletion cannot be
displayed unless the page is refreshed. It is replaced by a toast.
2025-07-21 17:13:06 +08:00

37 lines
868 B
Ruby

# frozen_string_literal: true
module PageObjects
module Pages
class UserInvitedExpired < PageObjects::Pages::Base
def visit(user)
url = "/u/#{user.username_lower}/invited/expired"
page.visit(url)
has_css?(".user-content.--loaded")
end
def wait_till_loaded
has_css?(".user-content.--loaded")
end
def bulk_remove_expired_button
find(".user-content .bulk-remove-expired")
end
def invites_list
all(".user-content .user-invite-list tbody tr").map do |row|
UserInvitedPending::Invite.new(row)
end
end
def empty?
has_css?(".empty-state__container")
end
def latest_invite
UserInvitedPending::Invite.new(
find(".user-content .user-invite-list tbody tr:first-of-type"),
)
end
end
end
end