Skip to content

Commit

Permalink
tests: Add cypress tests for disabled download permissions
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Dec 20, 2022
1 parent 137faf1 commit e4dd6aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions cypress/e2e/share.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import { randUser } from '../utils/index.js'

const user = randUser()
const recipient = randUser()

describe('Open test.md in viewer', function() {
before(function() {
Expand All @@ -37,6 +38,8 @@ describe('Open test.md in viewer', function() {
cy.uploadFile('test.md', 'text/markdown', 'folder/Readme.md')
cy.uploadFile('test.md', 'text/markdown', 'test2.md')
cy.uploadFile('test.md', 'text/markdown')

cy.createUser(recipient)
})
beforeEach(function() {
cy.login(user)
Expand Down Expand Up @@ -120,4 +123,16 @@ describe('Open test.md in viewer', function() {
})
})

it('Share a file with download disabled shows an error', function() {
cy.shareFileToUser('test.md', recipient, {
attributes: '[{"scope":"permissions","key":"download","enabled":false}]',
}).then(() => {
cy.login(recipient)
cy.visit('/apps/files')
cy.openFile('test.md')
cy.getModal().find('.empty-content__title').should('contain', 'Failed to load file')
cy.getModal().getContent().should('not.exist')
})
})

})
3 changes: 2 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Cypress.Commands.add('createFile', (target, content, mimeType = 'text/markdown')

})

Cypress.Commands.add('shareFileToUser', (path, targetUser) => {
Cypress.Commands.add('shareFileToUser', (path, targetUser, shareData = {}) => {
cy.clearCookies()
cy.ocsRequest({
method: 'POST',
Expand All @@ -104,6 +104,7 @@ Cypress.Commands.add('shareFileToUser', (path, targetUser) => {
path,
shareType: 0,
shareWith: targetUser.userId,
...shareData,
},
}).then(response => {
cy.log(`${auth.user} shared ${path} with ${targetUser.userId}`, response.status)
Expand Down

0 comments on commit e4dd6aa

Please sign in to comment.