diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2023-10-26 16:40:06 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2023-10-29 23:36:58 +0100 |
commit | a7c88519f73dbb52132c849113d522d117b1dbfa (patch) | |
tree | 590c3e6b61a16d6f842e08a850480c93e5c4b06c /cypress/support | |
parent | bfc8b0bc15c2c8b0e0ba1a6534715289c40415bc (diff) | |
download | nextcloud-server-a7c88519f73dbb52132c849113d522d117b1dbfa.tar.gz nextcloud-server-a7c88519f73dbb52132c849113d522d117b1dbfa.zip |
chore(cypress): Move `clearState` from user utils to shared common utils
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'cypress/support')
-rw-r--r-- | cypress/support/commonUtils.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cypress/support/commonUtils.ts b/cypress/support/commonUtils.ts index 4b201b38da5..5f0feae4824 100644 --- a/cypress/support/commonUtils.ts +++ b/cypress/support/commonUtils.ts @@ -18,3 +18,20 @@ export function getNextcloudUserMenu() { export function getNextcloudUserMenuToggle() { return getNextcloudUserMenu().find('.header-menu__trigger').should('have.length', 1) } + +/** + * Helper function ensure users and groups in this tests have a clean state + * Deletes all users (except admin) and groups + */ +export function clearState() { + // cleanup ignoring any failures + cy.runOccCommand('group:list --output=json').then(($result) => { + const groups = Object.keys(JSON.parse($result.stdout)).filter((name) => name !== 'admin') + groups.forEach((groupID) => cy.runOccCommand(`group:delete '${groupID}'`)) + }) + + cy.runOccCommand('user:list --output=json').then(($result) => { + const users = Object.keys(JSON.parse($result.stdout)).filter((name) => name !== 'admin') + users.forEach((userID) => cy.runOccCommand(`user:delete '${userID}'`)) + }) +} |