Skip to content

Commit aa7897f

Browse files
committed
tests: Add cypress tests for disabled download permissions
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent 181623a commit aa7897f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

cypress/e2e/share.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import { randHash } from '../utils/index.js'
2525
const randUser = randHash()
26+
const recipient = randHash()
2627

2728
describe('Open test.md in viewer', function() {
2829
before(function() {
@@ -39,6 +40,8 @@ describe('Open test.md in viewer', function() {
3940
cy.visit('/apps/files')
4041
cy.get('.files-fileList tr[data-file="test.md"]')
4142
.should('contain', 'test.md')
43+
44+
cy.nextcloudCreateUser(recipient, 'password')
4245
})
4346
beforeEach(function() {
4447
cy.login(randUser, 'password')
@@ -121,4 +124,16 @@ describe('Open test.md in viewer', function() {
121124
})
122125
})
123126

127+
it('Share a file with download disabled shows an error', function() {
128+
cy.shareFileToUser(randUser, 'password', 'test.md', recipient, {
129+
attributes: '[{"scope":"permissions","key":"download","enabled":false}]',
130+
}).then(() => {
131+
cy.login(recipient, 'password')
132+
cy.visit('/apps/files')
133+
cy.openFile('test.md')
134+
cy.getModal().find('.empty-content__title').should('contain', 'Failed to load file')
135+
cy.getModal().getContent().should('not.exist')
136+
})
137+
})
138+
124139
})

cypress/support/commands.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Cypress.Commands.add('createFile', (target, content, mimeType = 'text/markdown')
141141

142142
})
143143

144-
Cypress.Commands.add('shareFileToUser', (userId, password, path, targetUserId) => {
144+
Cypress.Commands.add('shareFileToUser', (userId, password, path, targetUserId, shareData = {}) => {
145145
cy.clearCookies()
146146
cy.request({
147147
method: 'POST',
@@ -151,6 +151,7 @@ Cypress.Commands.add('shareFileToUser', (userId, password, path, targetUserId) =
151151
path,
152152
shareType: 0,
153153
shareWith: targetUserId,
154+
...shareData,
154155
},
155156
auth: { user: userId, pass: password },
156157
headers: {

0 commit comments

Comments
 (0)