2023-08-24 00:04:26 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-11-20 11:22:14 -05:00
|
|
|
describe "Uploading files in the composer", type: :system do
|
2023-12-17 21:39:53 -05:00
|
|
|
fab!(:current_user) { Fabricate(:user, refresh_auto_groups: true) }
|
2023-08-24 00:04:26 -04:00
|
|
|
|
|
|
|
let(:modal) { PageObjects::Modals::Base.new }
|
|
|
|
let(:composer) { PageObjects::Components::Composer.new }
|
|
|
|
let(:topic) { PageObjects::Pages::Topic.new }
|
2023-08-28 00:59:22 -04:00
|
|
|
let(:cdp) { PageObjects::CDP.new }
|
2023-08-24 00:04:26 -04:00
|
|
|
|
|
|
|
before { sign_in(current_user) }
|
|
|
|
|
|
|
|
it "uploads multiple files at once" do
|
|
|
|
visit "/new-topic"
|
|
|
|
expect(composer).to be_opened
|
|
|
|
|
|
|
|
file_path_1 = file_from_fixtures("logo.png", "images").path
|
|
|
|
file_path_2 = file_from_fixtures("logo.jpg", "images").path
|
|
|
|
attach_file([file_path_1, file_path_2]) { composer.click_toolbar_button("upload") }
|
|
|
|
|
|
|
|
expect(composer).to have_no_in_progress_uploads
|
|
|
|
expect(composer.preview).to have_css(".image-wrapper", count: 2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "allows cancelling uploads" do
|
|
|
|
visit "/new-topic"
|
|
|
|
expect(composer).to be_opened
|
|
|
|
|
2023-08-28 00:59:22 -04:00
|
|
|
file_path_1 = file_from_fixtures("huge.jpg", "images").path
|
|
|
|
cdp.with_slow_upload do
|
|
|
|
attach_file(file_path_1) { composer.click_toolbar_button("upload") }
|
|
|
|
expect(composer).to have_in_progress_uploads
|
|
|
|
find("#cancel-file-upload").click
|
2023-08-24 00:04:26 -04:00
|
|
|
|
2023-08-28 00:59:22 -04:00
|
|
|
expect(composer).to have_no_in_progress_uploads
|
|
|
|
expect(composer.preview).to have_no_css(".image-wrapper")
|
|
|
|
end
|
2023-08-24 00:04:26 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when video thumbnails are enabled" do
|
|
|
|
before do
|
|
|
|
SiteSetting.video_thumbnails_enabled = true
|
|
|
|
SiteSetting.authorized_extensions += "|mp4"
|
|
|
|
end
|
|
|
|
|
|
|
|
# TODO (martin): Video streaming is not yet available in Chrome for Testing,
|
|
|
|
# we need to come back to this in a few months and try again.
|
|
|
|
#
|
|
|
|
# c.f. https://groups.google.com/g/chromedriver-users/c/1SMbByMfO2U
|
2024-02-14 15:43:53 -05:00
|
|
|
xit "generates a topic preview thumbnail from the video" do
|
2023-08-24 00:04:26 -04:00
|
|
|
visit "/new-topic"
|
|
|
|
expect(composer).to be_opened
|
|
|
|
topic.fill_in_composer_title("Video upload test")
|
|
|
|
|
|
|
|
file_path_1 = file_from_fixtures("small.mp4", "media").path
|
|
|
|
attach_file(file_path_1) { composer.click_toolbar_button("upload") }
|
|
|
|
|
|
|
|
expect(composer).to have_no_in_progress_uploads
|
2024-02-14 15:43:53 -05:00
|
|
|
expect(composer.preview).to have_css(".onebox-placeholder-container")
|
2023-08-24 00:04:26 -04:00
|
|
|
|
|
|
|
composer.submit
|
|
|
|
|
|
|
|
expect(find("#topic-title")).to have_content("Video upload test")
|
2024-02-14 15:43:53 -05:00
|
|
|
# I think topic list previews need to be enabled for this?
|
|
|
|
#expect(topic.image_upload_id).to eq(Upload.last.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "generates a thumbnail from the video" do
|
|
|
|
visit "/new-topic"
|
|
|
|
expect(composer).to be_opened
|
|
|
|
topic.fill_in_composer_title("Video upload test")
|
|
|
|
|
|
|
|
file_path_1 = file_from_fixtures("small.mp4", "media").path
|
|
|
|
attach_file(file_path_1) { composer.click_toolbar_button("upload") }
|
|
|
|
|
|
|
|
expect(composer).to have_no_in_progress_uploads
|
|
|
|
expect(composer.preview).to have_css(".onebox-placeholder-container")
|
|
|
|
|
2024-05-29 10:24:29 -04:00
|
|
|
expect(page).to have_css(
|
|
|
|
'.onebox-placeholder-container[style*="background-image"]',
|
|
|
|
wait: Capybara.default_max_wait_time,
|
|
|
|
)
|
|
|
|
|
2024-02-14 15:43:53 -05:00
|
|
|
composer.submit
|
|
|
|
|
|
|
|
expect(find("#topic-title")).to have_content("Video upload test")
|
|
|
|
|
|
|
|
selector = topic.post_by_number_selector(1)
|
|
|
|
|
|
|
|
expect(page).to have_css(selector)
|
|
|
|
within(selector) do
|
|
|
|
expect(page).to have_css(".video-placeholder-container[data-thumbnail-src]")
|
|
|
|
end
|
2023-08-24 00:04:26 -04:00
|
|
|
end
|
2024-05-29 10:24:29 -04:00
|
|
|
|
|
|
|
it "shows video player in composer" do
|
|
|
|
SiteSetting.enable_diffhtml_preview = true
|
|
|
|
|
|
|
|
visit "/new-topic"
|
|
|
|
expect(composer).to be_opened
|
|
|
|
topic.fill_in_composer_title("Video upload test")
|
|
|
|
|
|
|
|
file_path_1 = file_from_fixtures("small.mp4", "media").path
|
|
|
|
attach_file(file_path_1) { composer.click_toolbar_button("upload") }
|
|
|
|
|
|
|
|
expect(composer).to have_no_in_progress_uploads
|
|
|
|
expect(composer.preview).to have_css(".video-container video")
|
|
|
|
|
|
|
|
expect(page).to have_css(
|
|
|
|
".video-container video source[src]",
|
|
|
|
visible: false,
|
|
|
|
wait: Capybara.default_max_wait_time,
|
|
|
|
)
|
|
|
|
end
|
2023-08-24 00:04:26 -04:00
|
|
|
end
|
|
|
|
end
|