aboutsummaryrefslogtreecommitdiffstats
path: root/cypress/support
diff options
context:
space:
mode:
Diffstat (limited to 'cypress/support')
-rw-r--r--cypress/support/commands.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts
index 1574a03705f..0cc57c90585 100644
--- a/cypress/support/commands.ts
+++ b/cypress/support/commands.ts
@@ -76,6 +76,12 @@ declare global {
* Default is the post-setup state
*/
restoreDB(snapshot?: string): Cypress.Chainable,
+
+ /**
+ * Remove the user data directory for listed users
+ * @param user user ids
+ */
+ removeUserData(user: string[]): Cypress.Chainable,
}
}
}
@@ -288,6 +294,15 @@ Cypress.Commands.add('runOccCommand', (command: string, options?: Partial<Cypres
return cy.exec(`docker exec --user www-data ${env} nextcloud-cypress-tests-server php ./occ ${command}`, options)
})
+Cypress.Commands.add('removeUserData', (users: string[]) => {
+ if (users.some((user) => user.includes('/') || user.startsWith('.'))) {
+ throw new Error('user id contains invalid character')
+ }
+ users = users.map((user) => `"data/${user}"`)
+
+ return cy.exec(`docker exec --user www-data nextcloud-cypress-tests-server rm -fr ${users.join(' ')}`)
+})
+
Cypress.Commands.add('backupDB', (): Cypress.Chainable<string> => {
const randomString = Math.random().toString(36).substring(7)
cy.exec(`docker exec --user www-data nextcloud-cypress-tests-server cp /var/www/html/data/owncloud.db /var/www/html/data/owncloud.db-${randomString}`)