mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
test: add cypress tests for sharing download permission
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
57c3153b46
commit
30f3cbf5f8
3 changed files with 110 additions and 6 deletions
|
|
@ -20,9 +20,9 @@ export function createShare(fileName: string, username: string, shareSettings: P
|
|||
openSharingPanel(fileName)
|
||||
|
||||
cy.get('#app-sidebar-vue').within(() => {
|
||||
cy.get('#sharing-search-input').clear()
|
||||
cy.intercept({ times: 1, method: 'GET', url: '**/apps/files_sharing/api/v1/sharees?*' }).as('userSearch')
|
||||
cy.get('#sharing-search-input').type(username)
|
||||
cy.findByRole('combobox', { name: /Search for internal recipients/i })
|
||||
.type(`{selectAll}${username}`)
|
||||
cy.wait('@userSearch')
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@
|
|||
*/
|
||||
// @ts-expect-error The package is currently broken - but works...
|
||||
import { deleteDownloadsFolderBeforeEach } from 'cypress-delete-downloads-folder'
|
||||
import { createShare, getShareUrl, setupPublicShare, type ShareContext } from './setup-public-share.ts'
|
||||
import { createShare, getShareUrl, openLinkShareDetails, setupPublicShare, type ShareContext } from './setup-public-share.ts'
|
||||
import { getRowForFile, getRowForFileId, triggerActionForFile, triggerActionForFileId } from '../../files/FilesUtils.ts'
|
||||
import { zipFileContains } from '../../../support/utils/assertions.ts'
|
||||
import type { User } from '@nextcloud/cypress'
|
||||
|
||||
describe('files_sharing: Public share - downloading files', { testIsolation: true }, () => {
|
||||
|
||||
|
|
@ -170,4 +171,98 @@ describe('files_sharing: Public share - downloading files', { testIsolation: tru
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('download permission - link share', () => {
|
||||
let context: ShareContext
|
||||
beforeEach(() => {
|
||||
cy.createRandomUser().then((user) => {
|
||||
cy.mkdir(user, '/test')
|
||||
|
||||
context = { user }
|
||||
createShare(context, 'test')
|
||||
cy.login(context.user)
|
||||
cy.visit('/apps/files')
|
||||
})
|
||||
})
|
||||
|
||||
deleteDownloadsFolderBeforeEach()
|
||||
|
||||
it('download permission is retained', () => {
|
||||
getRowForFile('test').should('be.visible')
|
||||
triggerActionForFile('test', 'details')
|
||||
|
||||
openLinkShareDetails(0)
|
||||
|
||||
cy.intercept('PUT', '**/ocs/v2.php/apps/files_sharing/api/v1/shares/*').as('update')
|
||||
|
||||
cy.findByRole('checkbox', { name: /hide download/i })
|
||||
.should('exist')
|
||||
.and('not.be.checked')
|
||||
.check({ force: true })
|
||||
cy.findByRole('checkbox', { name: /hide download/i })
|
||||
.should('be.checked')
|
||||
cy.findByRole('button', { name: /update share/i })
|
||||
.click()
|
||||
|
||||
cy.wait('@update')
|
||||
|
||||
openLinkShareDetails(0)
|
||||
cy.findByRole('checkbox', { name: /hide download/i })
|
||||
.should('be.checked')
|
||||
|
||||
cy.reload()
|
||||
|
||||
getRowForFile('test').should('be.visible')
|
||||
triggerActionForFile('test', 'details')
|
||||
openLinkShareDetails(0)
|
||||
cy.findByRole('checkbox', { name: /hide download/i })
|
||||
.should('be.checked')
|
||||
})
|
||||
})
|
||||
|
||||
describe('download permission - mail share', () => {
|
||||
let user: User
|
||||
|
||||
beforeEach(() => {
|
||||
cy.createRandomUser().then(($user) => {
|
||||
user = $user
|
||||
cy.mkdir(user, '/test')
|
||||
cy.login(user)
|
||||
cy.visit('/apps/files')
|
||||
})
|
||||
})
|
||||
|
||||
it('download permission is retained', () => {
|
||||
getRowForFile('test').should('be.visible')
|
||||
triggerActionForFile('test', 'details')
|
||||
|
||||
cy.findByRole('combobox', { name: /Enter external recipients/i })
|
||||
.type('test@example.com')
|
||||
|
||||
cy.get('.option[sharetype="4"][user="test@example.com"]')
|
||||
.parent('li')
|
||||
.click()
|
||||
cy.findByRole('button', { name: /advanced settings/i })
|
||||
.should('be.visible')
|
||||
.click()
|
||||
|
||||
cy.intercept('PUT', '**/ocs/v2.php/apps/files_sharing/api/v1/shares/*').as('update')
|
||||
|
||||
cy.findByRole('checkbox', { name: /hide download/i })
|
||||
.should('exist')
|
||||
.and('not.be.checked')
|
||||
.check({ force: true })
|
||||
cy.findByRole('button', { name: /save share/i })
|
||||
.click()
|
||||
|
||||
cy.wait('@update')
|
||||
|
||||
openLinkShareDetails(1)
|
||||
cy.findByRole('button', { name: /advanced settings/i })
|
||||
.click()
|
||||
cy.findByRole('checkbox', { name: /hide download/i })
|
||||
.should('exist')
|
||||
.and('be.checked')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -122,15 +122,24 @@ export function createShare(context: ShareContext, shareName: string, options: S
|
|||
}
|
||||
|
||||
/**
|
||||
* Adjust share permissions to be editable
|
||||
* open link share details for specific index
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
function adjustSharePermission(): void {
|
||||
export function openLinkShareDetails(index: number) {
|
||||
cy.findByRole('list', { name: 'Link shares' })
|
||||
.findAllByRole('listitem')
|
||||
.first()
|
||||
.eq(index)
|
||||
.findByRole('button', { name: /Actions/i })
|
||||
.click()
|
||||
cy.findByRole('menuitem', { name: /Customize link/i }).click()
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust share permissions to be editable
|
||||
*/
|
||||
function adjustSharePermission(): void {
|
||||
openLinkShareDetails(0)
|
||||
|
||||
cy.get('[data-cy-files-sharing-share-permissions-bundle]').should('be.visible')
|
||||
cy.get('[data-cy-files-sharing-share-permissions-bundle="upload-edit"]').click()
|
||||
|
|
|
|||
Loading…
Reference in a new issue