discourse/spec/system/page_objects/pages/admin_user_fields.rb
Martin Brennan a879bcdc35
DEV: Introduce <DPageHeader /> and <DPageSubheader /> components (#30146)
This converts the `<AdminPageHeader />` component and the
`<AdminPageSubheader />` components into new components
that can be used outside of admin, and updates the CSS classes.
Also introduces a `<DPageActionButton />` component and child
components for the header action buttons.

I have to keep the old admin-only components around for
now until plugins are updated, then we can remove it,
and remove the re-exports that are done within
admin-page-action-button.gjs
2024-12-18 08:13:39 +10:00

45 lines
1.1 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Pages
class AdminUserFields < PageObjects::Pages::Base
def visit
page.visit "admin/customize/user_fields"
self
end
def form
PageObjects::Components::FormKit.new(".user-field .form-kit")
end
def choose_requirement(requirement)
form = page.find(".user-field")
form.choose(I18n.t("admin_js.admin.user_fields.requirement.#{requirement}.title"))
end
def click_add_field
page.find(".d-page-header__actions .btn-primary").click
end
def click_edit
page.find(".admin-user_field-item__edit").click
end
def add_field(name: nil, description: nil, requirement: nil, preferences: [])
click_add_field
form = page.find(".user-field")
form.find(".user-field-name").fill_in(with: name)
form.find(".user-field-desc").fill_in(with: description)
form.find(".save").click
end
def has_user_field?(name)
page.has_text?(name)
end
end
end
end