2023-08-23 09:18:33 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-08-24 12:04:26 +08:00
|
|
|
describe "Uploading files in the composer to S3", type: :system do
|
2023-08-23 09:18:33 +08:00
|
|
|
fab!(:current_user) { Fabricate(:admin) }
|
|
|
|
|
|
|
|
let(:modal) { PageObjects::Modals::Base.new }
|
|
|
|
let(:composer) { PageObjects::Components::Composer.new }
|
2023-09-06 07:39:09 +08:00
|
|
|
let(:topic) { PageObjects::Pages::Topic.new }
|
2023-08-23 09:18:33 +08:00
|
|
|
|
|
|
|
describe "direct S3 uploads" do
|
|
|
|
describe "single part uploads" do
|
|
|
|
it "uploads custom avatars to S3" do
|
2024-11-05 07:28:14 +08:00
|
|
|
setup_or_skip_s3_system_test
|
2023-08-23 09:18:33 +08:00
|
|
|
sign_in(current_user)
|
|
|
|
|
|
|
|
visit "/my/preferences/account"
|
|
|
|
|
|
|
|
find("#edit-avatar").click
|
|
|
|
find("#uploaded-avatar").click
|
|
|
|
attach_file(File.absolute_path(file_from_fixtures("logo.jpg"))) do
|
|
|
|
find("#avatar-uploader").click
|
|
|
|
end
|
2023-10-24 10:43:14 +08:00
|
|
|
expect(page).to have_css(".avatar-uploader .avatar-uploader__button[data-uploaded]")
|
2023-08-23 09:18:33 +08:00
|
|
|
modal.click_primary_button
|
2023-08-28 12:59:22 +08:00
|
|
|
expect(modal).to be_closed
|
2023-08-23 09:18:33 +08:00
|
|
|
expect(page).to have_css(
|
|
|
|
"#user-avatar-uploads[data-custom-avatar-upload-id]",
|
2023-12-07 06:25:00 +08:00
|
|
|
visible: :hidden,
|
2023-08-23 09:18:33 +08:00
|
|
|
)
|
|
|
|
expect(current_user.reload.uploaded_avatar_id).to eq(
|
|
|
|
find("#user-avatar-uploads", visible: false)["data-custom-avatar-upload-id"].to_i,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "multipart uploads" do
|
|
|
|
it "uploads a file in the post composer" do
|
2024-11-05 07:28:14 +08:00
|
|
|
setup_or_skip_s3_system_test
|
2023-08-23 09:18:33 +08:00
|
|
|
sign_in(current_user)
|
|
|
|
|
2023-09-06 07:39:09 +08:00
|
|
|
topic.open_new_topic
|
2023-08-23 09:18:33 +08:00
|
|
|
|
|
|
|
file_path = file_from_fixtures("logo.png", "images").path
|
|
|
|
attach_file(file_path) { composer.click_toolbar_button("upload") }
|
|
|
|
|
|
|
|
expect(page).to have_no_css("#file-uploading")
|
|
|
|
expect(composer.preview).to have_css(".image-wrapper")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|