Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions cypress/e2e/settings/users_groups.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
*/

import { User } from '@nextcloud/e2e-test-server/cypress'
import { clearState } from '../../support/commonUtils.ts'
import { randomString } from '../../support/utils/randomString.ts'
import { assertNotExistOrNotVisible, getUserListRow, handlePasswordConfirmation, toggleEditButton } from './usersUtils.ts'

const admin = new User('admin', 'admin')

describe('Settings: Create groups', () => {
let groupName: string

after(() => {
cy.runOccCommand(`group:delete '${groupName!}'`)
})

before(() => {
cy.login(admin)
cy.visit('/settings/users')
Expand All @@ -18,7 +25,7 @@ describe('Settings: Create groups', () => {
it('Can create a group', () => {
cy.intercept('POST', '**/ocs/v2.php/cloud/groups').as('createGroups')

const groupName = randomString(7)
groupName = randomString(7)
// open the Create group menu
cy.get('button[aria-label="Create group"]').click()

Expand Down Expand Up @@ -49,8 +56,14 @@ describe('Settings: Assign user to a group', { testIsolation: false }, () => {
const groupName = randomString(7)
let testUser: User

after(() => cy.deleteUser(testUser))
after(() => {
cy.deleteUser(testUser)
cy.runOccCommand(`group:delete '${groupName}'`)
})

before(() => {
clearState()

cy.createRandomUser().then((user) => {
testUser = user
})
Expand Down Expand Up @@ -120,6 +133,9 @@ describe('Settings: Assign user to a group', { testIsolation: false }, () => {
describe('Settings: Delete an empty group', { testIsolation: false }, () => {
const groupName = randomString(7)

after(() => {
cy.runOccCommand(`group:delete '${groupName}'`, { failOnNonZeroExit: false })
})
before(() => {
cy.runOccCommand(`group:add '${groupName}'`)
cy.login(admin)
Expand Down Expand Up @@ -151,7 +167,8 @@ describe('Settings: Delete an empty group', { testIsolation: false }, () => {

it('deleted group is not shown anymore', () => {
// see that the list of groups does not contain the group
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').find('li').contains(groupName)
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]')
.find('li')
.should('not.exist')
// and also not in database
cy.runOccCommand('group:list --output=json').then(($response) => {
Expand All @@ -165,6 +182,10 @@ describe('Settings: Delete a non empty group', () => {
let testUser: User
const groupName = randomString(7)

after(() => {
cy.runOccCommand(`group:delete '${groupName}'`, { failOnNonZeroExit: false })
})

before(() => {
cy.runOccCommand(`group:add '${groupName}'`)
cy.createRandomUser().then(($user) => {
Expand Down Expand Up @@ -202,7 +223,8 @@ describe('Settings: Delete a non empty group', () => {

it('deleted group is not shown anymore', () => {
// see that the list of groups does not contain the group foo
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]').find('li').contains(groupName)
cy.get('ul[data-cy-users-settings-navigation-groups="custom"]')
.find('li')
.should('not.exist')
// and also not in database
cy.runOccCommand('group:list --output=json').then(($response) => {
Expand All @@ -215,12 +237,7 @@ describe('Settings: Delete a non empty group', () => {
describe('Settings: Sort groups in the UI', () => {
before(() => {
// Clear state
cy.runOccCommand('group:list --output json').then((output) => {
const groups = Object.keys(JSON.parse(output.stdout)).filter((group) => group !== 'admin')
groups.forEach((group) => {
cy.runOccCommand(`group:delete '${group}'`)
})
})
clearState()

// Add two groups and add one user to group B
cy.runOccCommand('group:add A')
Expand Down
Loading