From 4bfbb4fbf79e751f2bf0b716e384f9afe34d81e9 Mon Sep 17 00:00:00 2001 From: Vinicius Reis Date: Mon, 17 Oct 2022 16:59:31 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20(#1220):=20test:=20keep=20last=20pa?= =?UTF-8?q?th=20when=20choose=20a=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vinicius Reis --- cypress/e2e/attachments.spec.js | 49 ++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/attachments.spec.js b/cypress/e2e/attachments.spec.js index fd3401d63a1..5a7357d0513 100644 --- a/cypress/e2e/attachments.spec.js +++ b/cypress/e2e/attachments.spec.js @@ -145,7 +145,13 @@ describe('Test all attachment insertion methods', () => { before(() => { initUserAndFiles(randUser, 'test.md', 'empty.md') + cy.createFolder('sub') + cy.createFolder('sub/a') + cy.createFolder('sub/b') + cy.uploadFile('github.png', 'image/png') + cy.uploadFile('github.png', 'image/png', 'sub/a/a.png') + cy.uploadFile('github.png', 'image/png', 'sub/b/b.png') cy.nextcloudCreateUser(randUser2, 'password') cy.shareFileToUser(randUser, 'password', 'test.md', randUser2) @@ -168,9 +174,44 @@ describe('Test all attachment insertion methods', () => { clickOnAttachmentAction(ACTION_INSERT_FROM_FILES) .then(() => { - const requestAlias = 'insertPathRequest' + const requestAlias = 'insertPathRequest-a' cy.intercept({ method: 'POST', url: '**/filepath' }).as(requestAlias) + cy.log('Go to sub folder (a)') + cy.get('#picker-filestable tr[data-entryname="sub"]').click() + cy.get('#picker-filestable tr[data-entryname="a"]').click() + cy.get('#picker-filestable tr[data-entryname="a.png"]').click() + + cy.get('.oc-dialog > .oc-dialog-buttonrow button').click() + + return waitForRequestAndCheckAttachment(requestAlias) + }) + .then(() => clickOnAttachmentAction(ACTION_INSERT_FROM_FILES)) + .then(() => { + const requestAlias = 'insertPathRequest-b' + cy.intercept({ method: 'POST', url: '**/filepath' }).as(requestAlias) + + cy.log('Go back to sub folder') + cy.get('#oc-dialog-filepicker-content .dirtree [data-dir="/sub"] a').click() + + cy.log('Go to sub folder (b)') + cy.get('#picker-filestable tr[data-entryname="b"]').click() + cy.get('#picker-filestable tr[data-entryname="b.png"]').click() + + cy.get('.oc-dialog > .oc-dialog-buttonrow button').click() + + return waitForRequestAndCheckAttachment(requestAlias) + }) + + .then(() => clickOnAttachmentAction(ACTION_INSERT_FROM_FILES)) + + .then(() => { + const requestAlias = 'insertPathRequest-root' + cy.intercept({ method: 'POST', url: '**/filepath' }).as(requestAlias) + + cy.log('Go back to home') + cy.get('#oc-dialog-filepicker-content .dirtree > .crumb:first-child').click() + cy.log('Select the file in the filepicker') cy.get('#picker-filestable tr[data-entryname="github.png"]').click() cy.log('Click OK in the filepicker') @@ -180,7 +221,7 @@ describe('Test all attachment insertion methods', () => { }) }) - it('Upload a local image file', () => { + it('Upload a local image file (table.png)', () => { cy.openFile('test.md') // in this case we almost could just attach the file to the input // BUT we still need to click on the action because otherwise the command @@ -196,7 +237,7 @@ describe('Test all attachment insertion methods', () => { }) }) - it('Upload a local media file', () => { + it('Upload a local media file (file.txt.gz)', () => { cy.openFile('test.md') // in this case we almost could just attach the file to the input // BUT we still need to click on the action because otherwise the command @@ -252,7 +293,7 @@ describe('Test all attachment insertion methods', () => { .then((documentId) => { const files = attachmentFileNameToId[documentId] - cy.expect(Object.keys(files)).to.have.lengthOf(3) + cy.expect(Object.keys(files)).to.have.lengthOf(5) cy.openFolder('.attachments.' + documentId) cy.screenshot() for (const name in files) {