FIX: Badge image uploader (#28188)

In the formkit conversion in 2ca06ba2360c200b2be8e0718fcc04c64ca14935
we missed setting a type for the UppyImageUploader for badges. Also,
we were not passing down the `image_url` as form data, so when we used
`data.image` for that field the badge was not updating in the UI after
page loads and the image URL was not loading for preview.

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
This commit is contained in:
Martin Brennan
2024-08-01 23:36:17 +10:00
committed by GitHub
parent 6ee6b1f1d1
commit 77081de027
10 changed files with 146 additions and 35 deletions

View File

@ -18,6 +18,41 @@ module PageObjects
def has_badge?(title)
page.has_css?(".current-badge-header .badge-display-name", text: title)
end
def has_saved_form?
expect(PageObjects::Components::Toasts.new).to have_success(I18n.t("js.saved"))
end
def submit_form
form.submit
end
def choose_icon(name)
form.choose_conditional("choose-icon")
form.field("icon").select("ambulance")
self
end
def fill_query(query)
form.field("query").fill_in(query)
self
end
def upload_image(name)
form.choose_conditional("upload-image")
attach_file(File.absolute_path(file_from_fixtures(name))) do
form.field("image_url").find(".image-upload-controls .btn").click
end
expect(form.field("image_url")).to have_css(".btn-danger")
self
end
def form
@form ||= PageObjects::Components::FormKit.new("form")
end
end
end
end

View File

@ -2,6 +2,22 @@
module PageObjects
module Components
class FormKitContainer < PageObjects::Components::Base
attr_reader :component
def initialize(input)
if input.is_a?(Capybara::Node::Element)
@component = input
else
@component = find(input)
end
end
def has_content?(content)
component.has_content?(content)
end
end
class FormKitField < PageObjects::Components::Base
attr_reader :component
@ -166,6 +182,16 @@ module PageObjects
FormKitField.new(find(".form-kit__field[data-name='#{name}']"))
end
end
def container(name)
within component do
FormKitContainer.new(find(".form-kit__container[data-name='#{name}']"))
end
end
def choose_conditional(name)
find(".form-kit__conditional-display .form-kit__control-radio[value='#{name}']").click
end
end
end
end