diff options
-rw-r--r-- | cypress/e2e/settings/access-levels.cy.ts | 3 | ||||
-rw-r--r-- | cypress/e2e/settings/usersUtils.ts | 16 | ||||
-rw-r--r-- | cypress/e2e/settings/users_disable.cy.ts | 3 | ||||
-rw-r--r-- | cypress/e2e/settings/users_modify.cy.ts | 3 | ||||
-rw-r--r-- | cypress/support/commonUtils.ts | 17 |
5 files changed, 22 insertions, 20 deletions
diff --git a/cypress/e2e/settings/access-levels.cy.ts b/cypress/e2e/settings/access-levels.cy.ts index 1fb9efe8f03..ff95cf6c48a 100644 --- a/cypress/e2e/settings/access-levels.cy.ts +++ b/cypress/e2e/settings/access-levels.cy.ts @@ -21,8 +21,7 @@ */ import { User } from '@nextcloud/cypress' -import { clearState } from './usersUtils' -import { getNextcloudUserMenu, getNextcloudUserMenuToggle } from '../../support/commonUtils' +import { clearState, getNextcloudUserMenu, getNextcloudUserMenuToggle } from '../../support/commonUtils' const admin = new User('admin', 'admin') diff --git a/cypress/e2e/settings/usersUtils.ts b/cypress/e2e/settings/usersUtils.ts index 0537f5b0ecb..56eff5e7d7d 100644 --- a/cypress/e2e/settings/usersUtils.ts +++ b/cypress/e2e/settings/usersUtils.ts @@ -36,22 +36,6 @@ export function assertNotExistOrNotVisible(element: JQuery<HTMLElement>) { } /** - * Helper function ensure users and groups in this tests have a clean state - */ -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}'`)) - }) -} - -/** * Get the settings users list * @return Cypress chainable object */ diff --git a/cypress/e2e/settings/users_disable.cy.ts b/cypress/e2e/settings/users_disable.cy.ts index e63ba4fc3d6..1218d4f770b 100644 --- a/cypress/e2e/settings/users_disable.cy.ts +++ b/cypress/e2e/settings/users_disable.cy.ts @@ -21,7 +21,8 @@ */ import { User } from '@nextcloud/cypress' -import { clearState, getUserListRow } from './usersUtils' +import { getUserListRow } from './usersUtils' +import { clearState } from '../../support/commonUtils' const admin = new User('admin', 'admin') diff --git a/cypress/e2e/settings/users_modify.cy.ts b/cypress/e2e/settings/users_modify.cy.ts index ee3d1f37c02..b230fb998a5 100644 --- a/cypress/e2e/settings/users_modify.cy.ts +++ b/cypress/e2e/settings/users_modify.cy.ts @@ -21,7 +21,8 @@ */ import { User } from '@nextcloud/cypress' -import { clearState, getUserListRow, handlePasswordConfirmation, toggleEditButton, waitLoading } from './usersUtils' +import { getUserListRow, handlePasswordConfirmation, toggleEditButton, waitLoading } from './usersUtils' +import { clearState } from '../../support/commonUtils' const admin = new User('admin', 'admin') 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}'`)) + }) +} |