Skip to content
Snippets Groups Projects
Verified Commit d1e258d8 authored by Sebastian Bergandy's avatar Sebastian Bergandy :keyboard:
Browse files

OZG-7837 change test to gherkins rules

parent 307a2367
No related branches found
No related tags found
1 merge request!95OZG-7383 add realm-management roles for admin
import UserRepresentation from '@keycloak/keycloak-admin-client/lib/defs/userRepresentation';
import { E2EBenutzerHelper } from 'apps/admin-e2e/src/helper/benutzer/benutzer.helper';
import { E2EBenutzerVerifier } from 'apps/admin-e2e/src/helper/benutzer/benutzer.verifier';
import { getCypressEnv, interceptWithResponse, waitOfInterceptor } from 'apps/admin-e2e/src/support/cypress-helper';
......@@ -16,7 +15,7 @@ describe('Benutzer anlegen', () => {
const snackBar: SnackBarE2EComponent = new SnackBarE2EComponent();
const newUserPassword: string = 'TestTestTest';
const newUser: AdminUserE2E = {
const newAdminUser: AdminUserE2E = {
vorname: 'Theo',
nachname: 'Testuser',
username: 'testtheo',
......@@ -26,6 +25,15 @@ describe('Benutzer anlegen', () => {
organisationseinheiten: [],
};
const newRegularUser: AdminUserE2E = {
vorname: 'Max',
nachname: 'Mustermann',
username: 'maxmust',
email: 'max.mustermann@ozg-sh.de',
isUser: true,
organisationseinheiten: [],
};
before(() => {
loginAsAriane();
});
......@@ -38,7 +46,7 @@ describe('Benutzer anlegen', () => {
interceptWithResponse(HttpMethodE2E.POST, url, { errorCode, errorBody }).as(interceptor);
benutzerHelper.openNewBenutzerPage();
benutzerHelper.addBenutzer(newUser);
benutzerHelper.addBenutzer(newAdminUser);
benutzerHelper.saveBenutzer();
waitOfInterceptor(interceptor).then(() => {
......@@ -51,7 +59,7 @@ describe('Benutzer anlegen', () => {
it('should show snackbar after save', () => {
benutzerHelper.openNewBenutzerPage();
benutzerHelper.addBenutzer(newUser);
benutzerHelper.addBenutzer(newAdminUser);
benutzerHelper.saveBenutzer();
contains(snackBar.getMessage(), SnackbarMessagesE2E.NUTZER_ANGELEGT);
......@@ -59,46 +67,49 @@ describe('Benutzer anlegen', () => {
});
it('should show created user in list', () => {
benutzerVerifier.verifyUserInList(newUser);
benutzerVerifier.verifyUserInList(newAdminUser);
});
it('should remove benutzer', () => {
benutzerHelper.deleteBenutzer(newUser.username);
benutzerVerifier.verifyUserNotInList(newUser.username);
benutzerHelper.deleteBenutzer(newAdminUser.username);
benutzerVerifier.verifyUserNotInList(newAdminUser.username);
});
describe('admin user', () => {
describe('newly created admin user', () => {
it('should create new admin user', () => {
benutzerHelper.openNewBenutzerPage();
benutzerHelper.addBenutzer(newUser);
benutzerHelper.addBenutzer(newAdminUser);
benutzerHelper.saveBenutzer();
benutzerVerifier.verifyUserInList(newUser);
benutzerVerifier.verifyUserInList(newAdminUser);
});
it('should set verified email and reset password', () => {
cy.findUser(newUser.username).then((userRepresentation: UserRepresentation) =>
cy.verifyEmail(userRepresentation.id!).then(() => cy.resetPassword(userRepresentation.id!, newUserPassword)),
);
});
it('should create new regular user', () => {
benutzerHelper.openNewBenutzerPage();
it('should login', () => {
loginByUsernameAndPassword(newUser.username, newUserPassword);
benutzerHelper.addBenutzer(newRegularUser);
benutzerHelper.saveBenutzer();
benutzerVerifier.verifyUserInList(newRegularUser);
});
it('should navigate user list', () => {
it('should have rights to delete user', () => {
benutzerHelper.activateUser(newAdminUser.username, newUserPassword).then(() => {
loginByUsernameAndPassword(newAdminUser.username, newUserPassword);
benutzerHelper.openBenutzerListPage();
});
benutzerVerifier.verifyUserInList(newRegularUser);
it('should navigate to Organisationseinheiten', () => {
organisationsEinheitHelper.openOrganisationsEinheitPage();
benutzerHelper.deleteBenutzer(newRegularUser.username);
benutzerVerifier.verifyUserNotInList(newRegularUser.username);
});
});
it('should delete user', () => {
loginAsAriane();
benutzerHelper.deleteBenutzer(newUser.username);
benutzerHelper.deleteBenutzer(newAdminUser.username);
});
});
});
import UserRepresentation from '@keycloak/keycloak-admin-client/lib/defs/userRepresentation';
import {
BenutzerDeleteDialogE2EComponent,
BenutzerE2EComponent,
......@@ -7,6 +8,7 @@ import { SnackBarE2EComponent } from '../../components/ui/snackbar.e2e.component
import { OrganisationsEinheitE2E } from '../../model/organisations-einheit';
import { AdminUserE2E } from '../../model/util';
import { exist, notExist } from '../../support/cypress.util';
import Chainable = Cypress.Chainable;
export class E2EBenutzerExecutor {
private benutzerPage: BenutzerE2EComponent = new BenutzerE2EComponent();
......@@ -58,4 +60,16 @@ export class E2EBenutzerExecutor {
this.benutzerDeleteDialog.getDeleteButton().click();
exist(this.benutzerListPage.getList());
}
public verifyEmail(userId: string): Chainable<Cypress.Response<void>> {
return cy.verifyEmail(userId);
}
public resetPassword(userId: string, newPassword: string): Chainable<Cypress.Response<void>> {
return cy.resetPassword(userId, newPassword);
}
public findUser(username: string): Chainable<UserRepresentation> {
return cy.findUser(username);
}
}
import UserRepresentation from '@keycloak/keycloak-admin-client/lib/defs/userRepresentation';
import { OrganisationsEinheitE2E } from '../../model/organisations-einheit';
import { AdminUserE2E } from '../../model/util';
import { E2EBenutzerExecutor } from './benutzer.executor';
......@@ -5,7 +6,7 @@ import { E2EBenutzerNavigator } from './benutzer.navigator';
export class E2EBenutzerHelper {
private navigator: E2EBenutzerNavigator = new E2EBenutzerNavigator();
private executer: E2EBenutzerExecutor = new E2EBenutzerExecutor();
private executor: E2EBenutzerExecutor = new E2EBenutzerExecutor();
public openBenutzerListPage(): void {
this.navigator.openBenutzerListPage();
......@@ -34,28 +35,37 @@ export class E2EBenutzerHelper {
}
private modifyBenutzer(user: AdminUserE2E): void {
this.executer.modifyBenutzer(user);
this.executor.modifyBenutzer(user);
}
public editOrganisationsEinheitenAndSave(organisationsEinheiten: OrganisationsEinheitE2E[]): void {
this.executer.modifyOrganisationsEinheiten(organisationsEinheiten);
this.executor.modifyOrganisationsEinheiten(organisationsEinheiten);
this.saveAndCloseSnackbar();
}
private saveAndCloseSnackbar(): void {
this.executer.saveAndCloseSnackbar();
this.executor.saveAndCloseSnackbar();
}
public saveBenutzer(): void {
this.executer.saveBenutzer();
this.executor.saveBenutzer();
}
public deleteBenutzer(userName: string): void {
this.openBenutzerPage(userName);
this.executer.deleteBenutzer();
this.executor.deleteBenutzer();
}
public openBenutzerPage(userName: string): void {
this.navigator.openBenutzerPage(userName);
}
public activateUser(username: string, newPassword: string): Cypress.Chainable<UserRepresentation> {
return cy
.findUser(username)
.then((userRepresentation: UserRepresentation) => cy.verifyEmail(userRepresentation.id!).then(() => userRepresentation))
.then((userRepresentation: UserRepresentation) =>
cy.resetPassword(userRepresentation.id!, newPassword).then(() => userRepresentation),
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment