aboutsummaryrefslogtreecommitdiffstats
path: root/cypress/support/commands.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cypress/support/commands.ts')
-rw-r--r--cypress/support/commands.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts
index 410a970f77b..d610d79f7f4 100644
--- a/cypress/support/commands.ts
+++ b/cypress/support/commands.ts
@@ -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