DEV: Convert admin user fields to FormKit (#29070)

This change replaces the admin form for adding and editing custom user fields with a new FormKit implementation.
This commit is contained in:
Ted Johansson
2024-10-14 13:19:53 +08:00
committed by GitHub
parent ede06ffd43
commit 408de686bb
14 changed files with 313 additions and 395 deletions

View File

@ -23,7 +23,7 @@ describe "Admin User Fields", type: :system, js: true do
user_fields_page.add_field(name: "Occupation", description: "")
expect(user_fields_page).to have_text(/Description can't be blank/)
expect(user_fields_page.form.field(:description)).to have_errors("Required")
end
it "makes sure new required fields are editable after signup" do
@ -40,7 +40,7 @@ describe "Admin User Fields", type: :system, js: true do
user_fields_page.choose_requirement("optional")
expect(form).to have_field(editable_label, checked: false, disabled: false)
expect(form).to have_field(editable_label, checked: true, disabled: false)
end
it "requires confirmation when applying required fields retroactively" do

View File

@ -67,6 +67,16 @@ module PageObjects
expect(self.value).to eq(expected_value)
end
def has_errors?(*messages)
within component do
messages.all? { |m| find(".form-kit__errors", text: m) }
end
end
def has_no_errors?
!has_css?(".form-kit__errors")
end
def control_type
component["data-control-type"]
end

View File

@ -8,6 +8,10 @@ module PageObjects
self
end
def form
PageObjects::Components::FormKit.new(".user-field .form-kit")
end
def choose_requirement(requirement)
form = page.find(".user-field")