diff options
author | Julien Veyssier <eneiluj@posteo.net> | 2022-03-11 14:21:12 +0300 |
---|---|---|
committer | Julien Veyssier <eneiluj@posteo.net> | 2022-03-11 14:21:12 +0300 |
commit | 76abf29f8ce06d416e36b4b7f118f130021f5795 (patch) | |
tree | 7c9237f9f7e2b4f6a861b6722df99b45f234806a /cypress | |
parent | b534208eb7bff270edfb31f16e5eaeeaa32c0fbe (diff) |
test attachment folder feature with shared files
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
Diffstat (limited to 'cypress')
-rw-r--r-- | cypress/integration/images.spec.js | 77 | ||||
-rw-r--r-- | cypress/support/commands.js | 21 |
2 files changed, 97 insertions, 1 deletions
diff --git a/cypress/integration/images.spec.js b/cypress/integration/images.spec.js index 6ee1ec5a1..a63f7dbba 100644 --- a/cypress/integration/images.spec.js +++ b/cypress/integration/images.spec.js @@ -24,6 +24,8 @@ import { randHash } from '../utils/' import 'cypress-file-upload' const randUser = randHash() +const randUser2 = randHash() +let currentUser = randUser const attachmentFileNameToId = {} const ACTION_UPLOAD_LOCAL_FILE = 1 @@ -99,10 +101,13 @@ describe('Test all image insertion methods', () => { // Upload test files to user's storage cy.uploadFile('test.md', 'text/markdown') cy.uploadFile('github.png', 'image/png') + + cy.nextcloudCreateUser(randUser2, 'password') + cy.shareFileToUser(randUser, 'password', 'test.md', randUser2) }) beforeEach(() => { - cy.login(randUser, 'password') + cy.login(currentUser, 'password') }) it('See test files in the list and display hidden files', () => { @@ -264,10 +269,80 @@ describe('Test all image insertion methods', () => { cy.get(`#fileList tr[data-file=".attachments.${documentId}"]`, { timeout: 10000 }) .should('not.exist') }) + // change the current user for next tests + currentUser = randUser2 + }) + + it('[share] check everything behaves correctly on the share target user side', () => { + // check the file list + cy.get('#fileList tr[data-file="test.md"]', { timeout: 10000 }) + .should('contain', 'test.md') + cy.get('#fileList tr[data-file="github.png"]').should('not.exist') + + // show hidden files + cy.get('#app-settings-header', { timeout: 10000 }) + .click() + cy.intercept({ method: 'POST', url: '**/showhidden' }).as('showHidden') + cy.get('#app-settings-content label[for=showhiddenfilesToggle]', { timeout: 10000 }) + .click() + cy.wait('@showHidden') + + // check the attachment folder is not there + cy.get(`#fileList tr[data-file="test.md"]`, { timeout: 10000 }) + .should('exist') + .should('have.attr', 'data-id') + .then((documentId) => { + cy.get(`#fileList tr[data-file=".attachments.${documentId}"]`, { timeout: 10000 }) + .should('not.exist') + }) + + // move the file and check the attachment folder is still not there + cy.intercept({ method: 'MOVE', url: '**/test.md' }).as('move') + cy.moveFile('test.md', 'testMoved.md') + cy.wait('@move') + + cy.intercept({ method: 'PROPFIND', url: '**/' }).as('reload') + cy.reloadFileList() + cy.wait('@reload') + + cy.get(`#fileList tr[data-file="testMoved.md"]`, { timeout: 10000 }) + .should('exist') + .should('have.attr', 'data-id') + .then((documentId) => { + cy.get(`#fileList tr[data-file=".attachments.${documentId}"]`, { timeout: 10000 }) + .should('not.exist') + }) + + // copy the file and check the attachment folder was copied + cy.intercept({ method: 'COPY', url: '**/testMoved.md' }).as('copyFile') + cy.copyFile('testMoved.md', 'testCopied.md') + cy.wait('@copyFile') + cy.intercept({ method: 'PROPFIND', url: '**/' }).as('reload2') + cy.reloadFileList() + cy.wait('@reload2') + + cy.get(`#fileList tr[data-file="testCopied.md"]`, { timeout: 10000 }) + .should('exist') + .should('have.attr', 'data-id') + .then((documentId) => { + cy.intercept({ method: 'PROPFIND', url: '**/.attachments.' + documentId }).as('chdir') + cy.openFile('.attachments.' + documentId) + cy.wait('@chdir') + cy.screenshot() + for (const name in attachmentFileNameToId) { + cy.get(`#fileList tr[data-file="${name}"]`, { timeout: 10000 }) + .should('exist') + .should('have.attr', 'data-id') + // these are new copied attachment files + // so they should not have the same IDs than the ones created when uploading the images + .should('not.eq', String(attachmentFileNameToId[name])) + } + }) }) it('Delete the user', () => { cy.nextcloudDeleteUser(randUser, 'password') + cy.nextcloudDeleteUser(randUser2, 'password') }) }) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 19ab081ba..b04170534 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -116,6 +116,27 @@ Cypress.Commands.add('uploadFile', (fileName, mimeType, target) => { }) }) +Cypress.Commands.add('shareFileToUser', (userId, password, path, targetUserId) => { + cy.clearCookies() + cy.request({ + method: 'POST', + url: `${Cypress.env('baseUrl')}/ocs/v2.php/apps/files_sharing/api/v1/shares`, + form: true, + body: { + path, + shareType: 0, + shareWith: targetUserId, + }, + auth: { user: userId, pass: password }, + headers: { + 'OCS-ApiRequest': 'true', + 'Content-Type': 'application/x-www-form-urlencoded', + } + }).then(response => { + cy.log(`${userId} shared ${path} with ${targetUserId}`, response.status) + }) +}) + Cypress.Commands.add('createFolder', dirName => { cy.window().then( win => { win.OC.Files.getClient().createDirectory(dirName) |