0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-14 13:58:53 +08:00
discourse/spec/system/page_objects/modals/create_invite_with_roles.rb
Keegan George abe5700838
FEATURE: Allow inviting new users directly as admins (#41748)
**Previously**, getting a second admin onto a site took many steps:
create an invite, wait for the person to sign up, find their profile,
grant admin, and confirm via email.

**In this update**, a redesigned invite modal (gated behind the
`enable_admin_invites` upcoming change) lets admins invite someone as an
admin by email in one step. The invitee becomes a moderator on signup
and an admin once the inviter confirms via the existing admin
confirmation email. The admin onboarding panel's "Invite collaborators"
step now opens this flow with the admin option preselected.

| Invite members | Advanced options | Email delivery |
| --- | --- | --- |
|
![invite-members.png](https://github.com/discourse/discourse/releases/download/_gh-attach-assets/invite-members.png)
|
![invite-members-advanced.png](https://github.com/discourse/discourse/releases/download/_gh-attach-assets/invite-members-advanced.png)
|
![invite-members-email.png](https://github.com/discourse/discourse/releases/download/_gh-attach-assets/invite-members-email.png)
|

| Invite admins | Advanced options | Invite sent |
| --- | --- | --- |
|
![invite-admins.png](https://github.com/discourse/discourse/releases/download/_gh-attach-assets/invite-admins.png)
|
![invite-admins-advanced.png](https://github.com/discourse/discourse/releases/download/_gh-attach-assets/invite-admins-advanced.png)
|
![admin-invite-sent.png](https://github.com/discourse/discourse/releases/download/_gh-attach-assets/admin-invite-sent.png)
|

| Link created | Email invitation sent | Onboarding panel |
| --- | --- | --- |
|
![invite-created.png](https://github.com/discourse/discourse/releases/download/_gh-attach-assets/invite-created.png)
|
![invitation-sent.png](https://github.com/discourse/discourse/releases/download/_gh-attach-assets/invitation-sent.png)
|
![onboarding-banner.png](https://github.com/discourse/discourse/releases/download/_gh-attach-assets/onboarding-banner.png)
|
2026-07-16 14:59:24 -07:00

98 lines
2.4 KiB
Ruby
Vendored

# frozen_string_literal: true
module PageObjects
module Modals
class CreateInviteWithRoles < PageObjects::Modals::Base
MODAL_SELECTOR = ".create-invite-with-roles-modal"
def modal
find(MODAL_SELECTOR)
end
def open?
has_css?(MODAL_SELECTOR)
end
def closed?
has_no_css?(MODAL_SELECTOR)
end
def form
PageObjects::Components::FormKit.new("#{MODAL_SELECTOR} .form-kit")
end
def has_role_toggle?
within(modal) { has_css?(".create-invite-with-roles-modal__role-toggle") }
end
def has_no_role_toggle?
within(modal) { has_no_css?(".create-invite-with-roles-modal__role-toggle") }
end
def selected_role
within(modal) do
find(".create-invite-with-roles-modal__role-toggle input:checked", visible: false)[:value]
end
end
def select_role(role)
within(modal) do
find(
".create-invite-with-roles-modal__role-toggle input[value='#{role}']",
visible: false,
).ancestor("label").click
end
end
def role_option_disabled?(role)
within(modal) do
find(
".create-invite-with-roles-modal__role-toggle input[value='#{role}']",
visible: false,
).disabled?
end
end
def select_delivery(delivery)
within(modal) do
find(
".create-invite-with-roles-modal__delivery input[value='#{delivery}']",
visible: false,
).ancestor("label").click
end
end
def save_button
within(modal) { find(".save-invite") }
end
def toggle_advanced_options
within(modal) { find(".toggle-advanced").click }
end
def edit_button
within(modal) { find(".edit-invite") }
end
def cancel_button
within(modal) { find(".cancel-button") }
end
def invite_link_input
within(modal) { find("input.invite-link") }
end
def has_summary?
within(modal) { has_css?(".create-invite-with-roles-modal__summary") }
end
def has_sent_to_message?(email)
within(modal) { has_css?(".create-invite-with-roles-modal__sent-to", text: email) }
end
def has_email_sent_confirmation?(email)
within(modal) { has_css?(".create-invite-with-roles-modal__email-sent", text: email) }
end
end
end
end