Skip to content

Commit

Permalink
Added cypress tests for newly added user management commands
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Dec 6, 2022
1 parent fe38ab2 commit f54ff6d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
1 change: 0 additions & 1 deletion cypress/dockerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import Docker from 'dockerode'
import waitOn from 'wait-on'
import path from 'path'

export const docker = new Docker()

Expand Down
45 changes: 45 additions & 0 deletions cypress/e2e/users.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,48 @@ describe('Create user and login', function() {
})
})
})

describe('List users and delete user', () => {
const hash = 'user' + randHash()
it(`Create '${hash}' user and delete them`, () => {
const user = new User(hash, 'password')
cy.createUser(user).then(() => {
cy.login(user)
cy.listUsers().then(users => {
expect(users).to.contain(user.userId)
})
})

cy.deleteUser(user).then(() => {
cy.listUsers().then(users => {
expect(users).to.not.contain(user.userId)
})
})
})

it('Fail deleting non existing user', () => {
const hash = 'nouser' + randHash()
const user = new User(hash, 'password')

cy.deleteUser(user).then((response) => {
cy.wrap(response).its('status').should('eq', 404)
})
})
})

describe('Write and read user metadata', () => {
const hash = 'user' + randHash()
it(`Create '${hash}' user and write user data`, () => {
const user = new User(hash, 'password')
cy.createUser(user).then(() => {
cy.login(user)
})

cy.modifyUser(user, 'displayname', 'John Doe')
cy.getUserData(user).then(response => {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(response.body, "text/xml");
expect(xmlDoc.querySelector('data displayname')?.textContent).to.eq('John Doe')
})
})
})

0 comments on commit f54ff6d

Please sign in to comment.