aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-01-31 00:00:30 +0100
committerFerdinand Thiessen <opensource@fthiessen.de>2025-02-05 18:40:00 +0100
commit8fd6d8025ffbf1c0b798babc08d79718afdc25db (patch)
tree149ad83eebfbcc6caf406143be1946680e1e02cc
parentd6007918055be45d91c7d81b3e08fa092c55f9c2 (diff)
downloadnextcloud-server-8fd6d8025ffbf1c0b798babc08d79718afdc25db.tar.gz
nextcloud-server-8fd6d8025ffbf1c0b798babc08d79718afdc25db.zip
test: Add Cypress command for deleting files
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r--cypress/support/commands.ts23
-rw-r--r--cypress/support/cypress-e2e.d.ts5
2 files changed, 28 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
diff --git a/cypress/support/cypress-e2e.d.ts b/cypress/support/cypress-e2e.d.ts
index afe93077d6a..50a8bb990e9 100644
--- a/cypress/support/cypress-e2e.d.ts
+++ b/cypress/support/cypress-e2e.d.ts
@@ -30,6 +30,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
*/