diff --git a/services/web/cypress/fixtures/images/gradient.png b/services/web/cypress/fixtures/images/gradient.png new file mode 100644 index 0000000000..a2152f9e9e Binary files /dev/null and b/services/web/cypress/fixtures/images/gradient.png differ diff --git a/services/web/test/frontend/features/source-editor/components/figure-modal.spec.tsx b/services/web/test/frontend/features/source-editor/components/figure-modal.spec.tsx index a8558a5d6e..c8cf0f788e 100644 --- a/services/web/test/frontend/features/source-editor/components/figure-modal.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/figure-modal.spec.tsx @@ -384,6 +384,23 @@ text below`, cy.get('.cm-content').should('have.text', 'text abovetext below') }) + it('Opens figure modal on pasting image', function () { + cy.fixture('images/gradient.png').then(gradientBuffer => { + const gradientFile = new File([gradientBuffer], 'gradient.png', { + type: 'image/png', + }) + const clipboardData = new DataTransfer() + clipboardData.items.add(gradientFile) + cy.wrap(clipboardData.files).should('have.length', 1) + cy.get('.cm-content').trigger('paste', { clipboardData }) + cy.findByText('Upload from computer').should('be.visible') + cy.findByLabelText('File name in this project').should( + 'have.value', + 'gradient.png' + ) + }) + }) + // TODO: Add tests for replacing image when we can match on image path // TODO: Add tests for changing image size when we can match on figure width })