chore(cypress): Move clearState from user utils to shared common utils

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2023-10-26 16:40:06 +02:00
parent bfc8b0bc15
commit a7c88519f7
No known key found for this signature in database
GPG key ID: 45FAE7268762B400
5 changed files with 22 additions and 20 deletions

View file

@ -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')

View file

@ -35,22 +35,6 @@ export function assertNotExistOrNotVisible(element: JQuery<HTMLElement>) {
expect(doesNotExist || isNotVisible, 'does not exist or is not visible').to.be.true
}
/**
* 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

View file

@ -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')

View file

@ -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')

View file

@ -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}'`))
})
}