FIX: _uploadDropTargetOptions is now public (#29246)

Chat was using a private function which has now been made public.

This commit also adds a test for this codepath.
This commit is contained in:
Joffrey JAFFEUX 2024-10-17 13:10:01 +09:00 committed by GitHub
parent 070afcf605
commit 23d90ecb26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View File

@ -80,7 +80,7 @@ export default class ChatComposerUploads extends Component.extend(
this._triggerUploadsChanged();
}
_uploadDropTargetOptions() {
uploadDropTargetOptions() {
return {
target: this.uploadDropZone || document.body,
};

View File

@ -17,6 +17,29 @@ describe "Uploading files in chat messages", type: :system do
sign_in(current_user)
end
it "allows to drag files to start upload" do
chat.visit_channel(channel_1)
# Define the JavaScript to simulate dragging an external image
page.execute_script(<<-JS)
const target = document.querySelector('.chat-channel');
const dataTransfer = new DataTransfer();
const file = new File(['dummy content'], 'test-image.png', { type: 'image/png' });
dataTransfer.items.add(file);
const dragEnterEvent = new DragEvent('dragenter', { dataTransfer: dataTransfer });
target.dispatchEvent(dragEnterEvent);
const dragOverEvent = new DragEvent('dragover', { dataTransfer: dataTransfer });
target.dispatchEvent(dragOverEvent);
JS
expect(find(".chat-upload-drop-zone__text__title")).to have_content(
I18n.t("js.chat.upload_to_channel", { title: channel_1.title }),
)
end
it "allows uploading a single file" do
chat.visit_channel(channel_1)
file_path = file_from_fixtures("logo.png", "images").path