From f54ff6d17eaba987728c71e59cd7094872b4ad5d Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 6 Dec 2022 11:48:34 +0100 Subject: [PATCH] Added cypress tests for newly added user management commands Signed-off-by: Ferdinand Thiessen --- cypress/dockerNode.ts | 1 - cypress/e2e/users.cy.ts | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/cypress/dockerNode.ts b/cypress/dockerNode.ts index 9f2ac8bc..497b06bc 100644 --- a/cypress/dockerNode.ts +++ b/cypress/dockerNode.ts @@ -22,7 +22,6 @@ import Docker from 'dockerode' import waitOn from 'wait-on' -import path from 'path' export const docker = new Docker() diff --git a/cypress/e2e/users.cy.ts b/cypress/e2e/users.cy.ts index 87e04293..2953c89b 100644 --- a/cypress/e2e/users.cy.ts +++ b/cypress/e2e/users.cy.ts @@ -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') + }) + }) +}) \ No newline at end of file