discourse/spec/system/edit_category_images_spec.rb
Gary Pendergast c53cf93225
DEV: Fix flaky test when editing category logo image (#33961)
Introduced in 497bfec3a9.

This test was flaky due to the page having multiple uploaders on the same page, so the `have_css(".uploaded-image-preview.input-xxlarge")` check will always be true for the entire page. It would sometimes work correctly depending on if the uploader managed to finish quickly enough.
2025-07-30 13:33:41 +10:00

38 lines
1.2 KiB
Ruby

# frozen_string_literal: true
describe "Edit Category Images", type: :system do
fab!(:admin)
fab!(:category)
let(:category_page) { PageObjects::Pages::Category.new }
context "when trying to upload an image" do
before { sign_in(admin) }
context "when authorized_extensions blank and authorized_extensions_for_staff have restrictions" do
before do
SiteSetting.authorized_extensions = ""
SiteSetting.authorized_extensions_for_staff = "jpg|jpeg|png"
SiteSetting.enable_s3_uploads = false
end
it "displays and updates new counter" do
category_page.visit_images(category)
find("#category-logo-uploader .image-upload-controls").click
attach_file(
"category-logo-uploader__input",
"#{Rails.root}/spec/fixtures/images/logo.png",
make_visible: true,
)
expect(page).to have_content("uploaded successfully").or have_css(
".has-image .uploaded-image-preview.input-xxlarge",
)
upload = Upload.last
expect(upload.user_id).to eq(admin.id)
expect(upload.original_filename).to eq("logo.png")
end
end
end
end