mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
test: Add Cypress command for deleting files
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
d600791805
commit
8fd6d8025f
2 changed files with 28 additions and 0 deletions
|
|
@ -119,6 +119,29 @@ Cypress.Commands.add('mkdir', (user: User, target: string) => {
|
|||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('rm', (user: User, target: string) => {
|
||||
// eslint-disable-next-line cypress/unsafe-to-chain-command
|
||||
cy.clearCookies()
|
||||
.then(async () => {
|
||||
try {
|
||||
const rootPath = `${Cypress.env('baseUrl')}/remote.php/dav/files/${encodeURIComponent(user.userId)}`
|
||||
const filePath = target.split('/').map(encodeURIComponent).join('/')
|
||||
const response = await axios({
|
||||
url: `${rootPath}${filePath}`,
|
||||
method: 'DELETE',
|
||||
auth: {
|
||||
username: user.userId,
|
||||
password: user.password,
|
||||
},
|
||||
})
|
||||
cy.log(`delete file or directory ${target}`, response)
|
||||
} catch (error) {
|
||||
cy.log('error', error)
|
||||
throw new Error('Unable to delete file or directory')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* cy.uploadedContent - uploads a raw content
|
||||
* TODO: standardize in @nextcloud/cypress
|
||||
|
|
|
|||
5
cypress/support/cypress-e2e.d.ts
vendored
5
cypress/support/cypress-e2e.d.ts
vendored
|
|
@ -29,6 +29,11 @@ declare global {
|
|||
*/
|
||||
uploadContent(user: User, content: Blob, mimeType: string, target: string, mtime?: number): Cypress.Chainable<AxiosResponse>,
|
||||
|
||||
/**
|
||||
* Delete a file or directory
|
||||
*/
|
||||
rm(user: User, target: string): Cypress.Chainable<AxiosResponse>,
|
||||
|
||||
/**
|
||||
* Create a new directory
|
||||
* **Warning**: Using this function will reset the previous session
|
||||
|
|
|
|||
Loading…
Reference in a new issue