From 56a0becbcad7c700169e59ab4a0baa368ff41140 Mon Sep 17 00:00:00 2001 From: Andrey K Date: Fri, 18 Aug 2023 14:37:58 +0300 Subject: [PATCH] [MM-32576] Text copied from Microsoft OneNote pastes as an image (v2) (#23530) * [MM-32576] Text copied from Microsoft OneNote pastes as an image * [MM-32576] Text copied from Microsoft OneNote pastes as an image (linter and tests fix) * [MM-32576] Text copied from Microsoft OneNote pastes as an image (E2E tests fix: mock clipboardData.getData()) --------- Co-authored-by: Andrey Karavashkin --- .../files_and_attachments/disabled_file_upload_spec.js | 2 ++ .../channels/files_and_attachments/paste_image_spec.js | 1 + .../channels/src/components/file_upload/file_upload.test.tsx | 4 ++-- webapp/channels/src/components/file_upload/file_upload.tsx | 3 +-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/e2e-tests/cypress/tests/integration/channels/files_and_attachments/disabled_file_upload_spec.js b/e2e-tests/cypress/tests/integration/channels/files_and_attachments/disabled_file_upload_spec.js index 77574bc69a..917b84ac50 100644 --- a/e2e-tests/cypress/tests/integration/channels/files_and_attachments/disabled_file_upload_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/files_and_attachments/disabled_file_upload_spec.js @@ -140,6 +140,7 @@ describe('Upload Files - Settings', () => { }, }], types: [], + getData: () => {}, }}); // * An error should be visible saying 'File attachments are disabled' @@ -165,6 +166,7 @@ describe('Upload Files - Settings', () => { }, }], types: [], + getData: () => {}, }}); // * An error should be visible saying 'File attachments are disabled' diff --git a/e2e-tests/cypress/tests/integration/channels/files_and_attachments/paste_image_spec.js b/e2e-tests/cypress/tests/integration/channels/files_and_attachments/paste_image_spec.js index bb2596f5de..5fc68aef9f 100644 --- a/e2e-tests/cypress/tests/integration/channels/files_and_attachments/paste_image_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/files_and_attachments/paste_image_spec.js @@ -41,6 +41,7 @@ describe('Paste Image', () => { }, }], types: [], + getData: () => {}, }}); cy.uiWaitForFileUploadPreview(); diff --git a/webapp/channels/src/components/file_upload/file_upload.test.tsx b/webapp/channels/src/components/file_upload/file_upload.test.tsx index e7b75a6b91..a08d58d6ef 100644 --- a/webapp/channels/src/components/file_upload/file_upload.test.tsx +++ b/webapp/channels/src/components/file_upload/file_upload.test.tsx @@ -206,7 +206,7 @@ describe('components/FileUpload', () => { event.preventDefault = jest.fn(); const getAsFile = jest.fn().mockReturnValue(new File(['test'], 'test.png')); const file = {getAsFile, kind: 'file', name: 'test.png'}; - (event as any).clipboardData = {items: [file], types: ['image/png']}; + (event as any).clipboardData = {items: [file], types: ['image/png'], getData: () => {}}; const wrapper = shallowWithIntl( { const event = new Event('paste'); event.preventDefault = jest.fn(); const getAsString = jest.fn(); - (event as any).clipboardData = {items: [{getAsString, kind: 'string', type: 'text/plain'}], types: ['text/plain']}; + (event as any).clipboardData = {items: [{getAsString, kind: 'string', type: 'text/plain'}], types: ['text/plain'], getData: () => {}}; const wrapper = shallowWithIntl( { pasteUpload = (e: ClipboardEvent) => { const {formatMessage} = this.props.intl; - if (!e.clipboardData || !e.clipboardData.items || getHtmlTable(e.clipboardData)) { + if (!e.clipboardData || !e.clipboardData.items || e.clipboardData.getData('text/html')) { return; }