mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 22:33:45 +08:00
77081de027
In the formkit conversion in 2ca06ba236
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>
59 lines
1.3 KiB
Ruby
59 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Pages
|
|
class AdminBadges < PageObjects::Pages::Base
|
|
def visit_page(badge_id = nil)
|
|
path = "/admin/badges"
|
|
path += "/#{badge_id}" if badge_id
|
|
page.visit path
|
|
self
|
|
end
|
|
|
|
def new_page
|
|
page.visit "/admin/badges/new"
|
|
self
|
|
end
|
|
|
|
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
|