From 6a338dbfd3bcc19bd6f2effc6bf8890ccc5abdb0 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Fri, 7 Jan 2022 12:58:10 +0100 Subject: refs #2049 add cypress test for local image upload Signed-off-by: Julien Veyssier --- cypress/fixtures/table.png | Bin 0 -> 433 bytes cypress/integration/images.spec.js | 47 +++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 cypress/fixtures/table.png (limited to 'cypress') diff --git a/cypress/fixtures/table.png b/cypress/fixtures/table.png new file mode 100644 index 000000000..96fcef4dc Binary files /dev/null and b/cypress/fixtures/table.png differ diff --git a/cypress/integration/images.spec.js b/cypress/integration/images.spec.js index de23d2769..251ed6453 100644 --- a/cypress/integration/images.spec.js +++ b/cypress/integration/images.spec.js @@ -22,6 +22,7 @@ import { randHash } from '../utils/' +import 'cypress-file-upload' const randUser = randHash() describe('Open test.md in viewer', function() { @@ -106,13 +107,16 @@ describe('Open test.md in viewer', function() { const popover = cy.get('div#' + popoverId) popover.should('have.class', 'open') cy.get('div#' + popoverId + ' li:nth-child(3)').click() + cy.wait(2000) cy.log('Type and validate') cy.get('div#' + popoverId + ' li:nth-child(3) input[type=text]') .type('https://nextcloud.com/wp-content/themes/next/assets/img/headers/engineering-small.jpg') + .wait(2000) .type('{enter}') - //cy.get('div#' + popoverId + ' li:nth-child(3) form > label').click() + // click on the validation button is an alternative to typing {enter} + // cy.get('div#' + popoverId + ' li:nth-child(3) form > label').click() - cy.wait(4000) + cy.wait(2000) cy.log('Check the image is visible and well formed') const editor = cy.get('#editor .ProseMirror') editor.get('div.image:nth-child(1)') @@ -125,6 +129,45 @@ describe('Open test.md in viewer', function() { .should('contain', '.jpg') }) + cy.screenshot() + }) + + it('Upload a local imagee', function() { + cy.openFile('test.md') + const viewer = cy.get('#viewer') + const submenu = viewer.get('.action-item.submenu') + submenu.click() + submenu.should('have.class', 'action-item--open') + + const trigger = submenu.get('.action-item.submenu > div.v-popover > .trigger') + trigger + .should('have.class', 'trigger') + .invoke('attr','aria-describedby') + .should('contain', 'popover_') + .as('popoverId') + + cy.get('@popoverId').then(popoverId => { + cy.log('Click on action entry') + const popover = cy.get('div#' + popoverId) + popover.should('have.class', 'open') + cy.get('div#' + popoverId + ' li:nth-child(1)').click() + + cy.wait(4000) + cy.get('.menubar input[type="file"]') + .attachFile('table.png') + + cy.wait(4000) + cy.log('Check the image is visible and well formed') + const editor = cy.get('#editor .ProseMirror') + editor.get('div.image:nth-child(1)') + .should('be.visible') + .invoke('attr', 'data-src') + .should('contain', 'table.png') + editor.get('div.image:nth-child(1) img').invoke('attr', 'src') + .should('contain', 'apps/text/image?documentId=') + .should('contain', 'imageFileName') + .should('contain', 'table.png') + }) cy.screenshot() }) -- cgit v1.2.3