-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: e2e test for user management CRUD functionality (#310)
- Loading branch information
Showing
9 changed files
with
165 additions
and
5 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
e2e/cypress/integration/pages/organizationmanagement/user-create.page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { fillFormField } from '../../framework'; | ||
|
||
declare interface B2BUserCreateForm { | ||
title: string; | ||
firstName: string; | ||
lastName: string; | ||
email: string; | ||
phone: string; | ||
} | ||
|
||
export class UserCreatePage { | ||
readonly tag = 'ish-user-create-page'; | ||
|
||
private submitButton = () => cy.get('[data-testing-id="create-user-submit"]'); | ||
|
||
fillForm(content: B2BUserCreateForm) { | ||
Object.keys(content) | ||
.filter(key => content[key] !== undefined) | ||
.forEach((key: keyof B2BUserCreateForm) => { | ||
fillFormField(this.tag, key, content[key]); | ||
}); | ||
|
||
return this; | ||
} | ||
|
||
submit() { | ||
this.submitButton().click(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
e2e/cypress/integration/pages/organizationmanagement/user-edit.page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { fillFormField } from '../../framework'; | ||
|
||
export class UserEditPage { | ||
readonly tag = 'ish-user-edit-profile-page'; | ||
|
||
private submitButton = () => cy.get('[data-testing-id="edit-user-submit"]'); | ||
|
||
editTitle(val: string) { | ||
fillFormField(this.tag, 'title', val); | ||
} | ||
|
||
editFirstName(val: string) { | ||
fillFormField(this.tag, 'firstName', val); | ||
} | ||
|
||
submit() { | ||
this.submitButton().click(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
e2e/cypress/integration/specs/organizationmanagement/user-management-crud.b2b.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { at } from '../../framework'; | ||
import { createB2BUserViaREST } from '../../framework/b2b-user'; | ||
import { LoginPage } from '../../pages/account/login.page'; | ||
import { sensibleDefaults } from '../../pages/account/registration.page'; | ||
import { UserCreatePage } from '../../pages/organizationmanagement/user-create.page'; | ||
import { UserEditPage } from '../../pages/organizationmanagement/user-edit.page'; | ||
import { UsersDetailPage } from '../../pages/organizationmanagement/users-detail.page'; | ||
import { UsersPage } from '../../pages/organizationmanagement/users.page'; | ||
|
||
// test for viewing functionality only | ||
|
||
const _ = { | ||
user: { | ||
login: `test${new Date().getTime()}@testcity.de`, | ||
...sensibleDefaults, | ||
}, | ||
newUser: { | ||
title: 'Mr.', | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
phone: '5551234', | ||
email: `j.joe${new Date().getTime()}@testcity.de`, | ||
}, | ||
editUser: { | ||
title: 'Ms.', | ||
firstName: 'Jane', | ||
}, | ||
}; | ||
|
||
describe('User Management - CRUD', () => { | ||
before(() => { | ||
createB2BUserViaREST(_.user); | ||
}); | ||
|
||
it('should start user management by logging in', () => { | ||
LoginPage.navigateTo('/account/organization/users'); | ||
at(LoginPage, page => { | ||
page.fillForm(_.user.login, _.user.password); | ||
page.submit().its('status').should('equal', 200); | ||
}); | ||
at(UsersPage, page => { | ||
page.usersList.should('contain', `${_.user.firstName}`); | ||
}); | ||
}); | ||
|
||
it('should be able to create a new user', () => { | ||
at(UsersPage, page => page.addUser()); | ||
at(UserCreatePage, page => { | ||
page.fillForm(_.newUser); | ||
page.submit(); | ||
}); | ||
at(UsersPage, page => { | ||
page.usersList.should('contain', `${_.newUser.firstName}`); | ||
}); | ||
}); | ||
|
||
it('should be able to edit user', () => { | ||
at(UsersPage, page => page.goToUser(`${_.newUser.firstName} ${_.newUser.lastName}`)); | ||
at(UsersDetailPage, page => { | ||
page.name.should('contain', `${_.newUser.firstName} ${_.newUser.lastName}`); | ||
page.editUser(); | ||
}); | ||
at(UserEditPage, page => { | ||
page.editTitle(_.editUser.title); | ||
page.editFirstName(_.editUser.firstName); | ||
page.submit(); | ||
}); | ||
at(UsersDetailPage, page => { | ||
page.name.should('contain', `${_.editUser.firstName} ${_.newUser.lastName}`); | ||
page.goToUserManagement(); | ||
}); | ||
}); | ||
|
||
it('should be able to delete user', () => { | ||
at(UsersPage, page => { | ||
page.usersList.should('contain', `${_.editUser.firstName}`); | ||
page.deleteUser(`${_.editUser.firstName} ${_.newUser.lastName}`); | ||
page.usersList.should('not.contain', `${_.editUser.firstName}`); | ||
page.usersList.should('contain', `${_.user.firstName}`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters