mirror of
https://github.com/discourse/discourse.git
synced 2025-03-31 19:35:57 +08:00
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:
parent
070afcf605
commit
23d90ecb26
plugins/chat
@ -80,7 +80,7 @@ export default class ChatComposerUploads extends Component.extend(
|
|||||||
this._triggerUploadsChanged();
|
this._triggerUploadsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
_uploadDropTargetOptions() {
|
uploadDropTargetOptions() {
|
||||||
return {
|
return {
|
||||||
target: this.uploadDropZone || document.body,
|
target: this.uploadDropZone || document.body,
|
||||||
};
|
};
|
||||||
|
@ -17,6 +17,29 @@ describe "Uploading files in chat messages", type: :system do
|
|||||||
sign_in(current_user)
|
sign_in(current_user)
|
||||||
end
|
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
|
it "allows uploading a single file" do
|
||||||
chat.visit_channel(channel_1)
|
chat.visit_channel(channel_1)
|
||||||
file_path = file_from_fixtures("logo.png", "images").path
|
file_path = file_from_fixtures("logo.png", "images").path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user