-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add cypress tests for sharing download permission
Signed-off-by: Ferdinand Thiessen <[email protected]>
- Loading branch information
Showing
2 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,12 @@ | |
*/ | ||
// @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 { openSharingDetails } from '../FilesSharingUtils.ts' | ||
import { c } from 'tar' | ||
import type { User } from '@nextcloud/cypress' | ||
|
||
describe('files_sharing: Public share - downloading files', { testIsolation: true }, () => { | ||
|
||
|
@@ -170,4 +173,106 @@ describe('files_sharing: Public share - downloading files', { testIsolation: tru | |
}) | ||
}) | ||
}) | ||
|
||
describe('download permission - link share', () => { | ||
let context: ShareContext | ||
before(() => { | ||
cy.createRandomUser() | ||
.then((user) => { | ||
cy.mkdir(user, '/test') | ||
|
||
context = { user } | ||
createShare(context, 'test') | ||
}) | ||
}) | ||
|
||
beforeEach(() => { | ||
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 | ||
|
||
before(() => { | ||
cy.createRandomUser() | ||
.then(($user) => { | ||
user = $user | ||
cy.mkdir(user, '/test') | ||
}) | ||
}) | ||
|
||
beforeEach(() => { | ||
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('[email protected]') | ||
|
||
cy.get('.option[sharetype="4"][user="[email protected]"]') | ||
.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') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters