Skip to content

Commit 8ef5647

Browse files
committed
test: add cypress tests for sharing download permission
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent fc6bd50 commit 8ef5647

File tree

2 files changed

+118
-4
lines changed

2 files changed

+118
-4
lines changed

cypress/e2e/files_sharing/public-share/download-files.cy.ts renamed to cypress/e2e/files_sharing/public-share/download.cy.ts

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
*/
55
// @ts-expect-error The package is currently broken - but works...
66
import { deleteDownloadsFolderBeforeEach } from 'cypress-delete-downloads-folder'
7-
import { createShare, getShareUrl, setupPublicShare, type ShareContext } from './setup-public-share.ts'
7+
import { createShare, getShareUrl, openLinkShareDetails, setupPublicShare, type ShareContext } from './setup-public-share.ts'
88
import { getRowForFile, getRowForFileId, triggerActionForFile, triggerActionForFileId } from '../../files/FilesUtils.ts'
99
import { zipFileContains } from '../../../support/utils/assertions.ts'
10+
import { openSharingDetails } from '../FilesSharingUtils.ts'
11+
import { c } from 'tar'
12+
import type { User } from '@nextcloud/cypress'
1013

1114
describe('files_sharing: Public share - downloading files', { testIsolation: true }, () => {
1215

@@ -170,4 +173,106 @@ describe('files_sharing: Public share - downloading files', { testIsolation: tru
170173
})
171174
})
172175
})
176+
177+
describe('download permission - link share', () => {
178+
let context: ShareContext
179+
before(() => {
180+
cy.createRandomUser()
181+
.then((user) => {
182+
cy.mkdir(user, '/test')
183+
184+
context = { user }
185+
createShare(context, 'test')
186+
})
187+
})
188+
189+
beforeEach(() => {
190+
cy.login(context.user)
191+
cy.visit('/apps/files')
192+
})
193+
194+
deleteDownloadsFolderBeforeEach()
195+
196+
it('download permission is retained', () => {
197+
getRowForFile('test').should('be.visible')
198+
triggerActionForFile('test', 'details')
199+
200+
openLinkShareDetails(0)
201+
202+
cy.intercept('PUT', '**/ocs/v2.php/apps/files_sharing/api/v1/shares/*').as('update')
203+
204+
cy.findByRole('checkbox', { name: /hide download/i })
205+
.should('exist')
206+
.and('not.be.checked')
207+
.check({ force: true })
208+
cy.findByRole('checkbox', { name: /hide download/i })
209+
.should('be.checked')
210+
cy.findByRole('button', { name: /update share/i })
211+
.click()
212+
213+
cy.wait('@update')
214+
215+
openLinkShareDetails(0)
216+
cy.findByRole('checkbox', { name: /hide download/i })
217+
.should('be.checked')
218+
219+
cy.reload()
220+
221+
getRowForFile('test').should('be.visible')
222+
triggerActionForFile('test', 'details')
223+
openLinkShareDetails(0)
224+
cy.findByRole('checkbox', { name: /hide download/i })
225+
.should('be.checked')
226+
})
227+
})
228+
229+
describe('download permission - mail share', () => {
230+
let user: User
231+
232+
before(() => {
233+
cy.createRandomUser()
234+
.then(($user) => {
235+
user = $user
236+
cy.mkdir(user, '/test')
237+
})
238+
})
239+
240+
beforeEach(() => {
241+
cy.login(user)
242+
cy.visit('/apps/files')
243+
})
244+
245+
it('download permission is retained', () => {
246+
getRowForFile('test').should('be.visible')
247+
triggerActionForFile('test', 'details')
248+
249+
cy.findByRole('combobox', { name: /Enter external recipients/i })
250+
.type('test@example.com')
251+
252+
cy.get('.option[sharetype="4"][user="test@example.com"]')
253+
.parent('li')
254+
.click()
255+
cy.findByRole('button', { name: /advanced settings/i })
256+
.should('be.visible')
257+
.click()
258+
259+
cy.intercept('PUT', '**/ocs/v2.php/apps/files_sharing/api/v1/shares/*').as('update')
260+
261+
cy.findByRole('checkbox', { name: /hide download/i })
262+
.should('exist')
263+
.and('not.be.checked')
264+
.check({ force: true })
265+
cy.findByRole('button', { name: /save share/i })
266+
.click()
267+
268+
cy.wait('@update')
269+
270+
openLinkShareDetails(1)
271+
cy.findByRole('button', { name: /advanced settings/i })
272+
.click()
273+
cy.findByRole('checkbox', { name: /hide download/i })
274+
.should('exist')
275+
.and('be.checked')
276+
})
277+
})
173278
})

cypress/e2e/files_sharing/public-share/setup-public-share.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,24 @@ export function createShare(context: ShareContext, shareName: string, options: S
122122
}
123123

124124
/**
125-
* Adjust share permissions to be editable
125+
* open link share details for specific index
126+
*
127+
* @param index
126128
*/
127-
function adjustSharePermission(): void {
129+
export function openLinkShareDetails(index: number) {
128130
cy.findByRole('list', { name: 'Link shares' })
129131
.findAllByRole('listitem')
130-
.first()
132+
.eq(index)
131133
.findByRole('button', { name: /Actions/i })
132134
.click()
133135
cy.findByRole('menuitem', { name: /Customize link/i }).click()
136+
}
137+
138+
/**
139+
* Adjust share permissions to be editable
140+
*/
141+
function adjustSharePermission(): void {
142+
openLinkShareDetails(0)
134143

135144
cy.get('[data-cy-files-sharing-share-permissions-bundle]').should('be.visible')
136145
cy.get('[data-cy-files-sharing-share-permissions-bundle="upload-edit"]').click()

0 commit comments

Comments
 (0)