Skip to content
Snippets Groups Projects
Commit 3cd59e9d authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' into OZG-5326-bescheid-refactoring-part-1

parents 8197e253 77c8bf61
No related branches found
No related tags found
No related merge requests found
Showing
with 425 additions and 41 deletions
......@@ -3,7 +3,9 @@
"env": {
"keycloakRealm": "by-e2e-tests-local-dev",
"keycloakUrl": "https://sso.dev.by.ozg-cloud.de",
"keycloakClient": "admin"
"keycloakClient": "admin",
"dbUrl": "mongodb://localhost:27017",
"database": "config-db"
},
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
......
......@@ -13,16 +13,11 @@ export class BenutzerE2EComponent {
private readonly loeschenCheckbox: string = 'Loschen-checkbox-editor';
private readonly userCheckbox: string = 'User-checkbox-editor';
private readonly postCheckbox: string = 'Poststelle-checkbox-editor';
private readonly userRolesTable: string = 'User-roles-table';
public getHinzufuegenButton(): Cypress.Chainable<Element> {
return cy.getTestElement(this.benutzerHinzufuegenButton);
}
public getUserRolesTable(): Cypress.Chainable<Element> {
return cy.getTestElement(this.userRolesTable);
}
public addUser(): void {
this.getHinzufuegenButton().click();
}
......
import { clearText, haveValue, typeText } from '../../support/cypress.util';
export class OrganisationseinheitenSignaturE2EComponent {
private readonly organisationsEinheitName: string = 'organisations-form-container-headline';
private readonly signatureText: string = 'signature-textarea';
private readonly saveSignatureButton: string = 'save-button';
public getOrganisationsEinheitName(): Cypress.Chainable<Element> {
return cy.getTestElement(this.organisationsEinheitName);
}
public getSignatureText(): Cypress.Chainable<Element> {
return cy.getTestElement(this.signatureText);
}
public setSignature(signatur: string): void {
this.clearSignature();
typeText(this.getSignatureText(), signatur);
}
public clearSignature(): void {
clearText(this.getSignatureText());
}
public getSaveButton(): Cypress.Chainable<Element> {
return cy.getTestElement(this.saveSignatureButton);
}
public saveSignature(): void {
this.getSaveButton().click();
}
public hasSignature(compare: string): void {
haveValue(this.getSignatureText(), compare);
}
public hasScrollbar(): void {
this.getSignatureText().then((textarea) => {
const scrollHeight = textarea[0].scrollHeight;
const clientHeight = textarea[0].clientHeight;
expect(scrollHeight).to.be.greaterThan(clientHeight);
});
}
}
import { containClass, exist, haveText, notContainClass } from '../../support/cypress.util';
export class OrganisationsEinheitenE2EComponent {
private readonly organisationsEinheitenList: string = 'organisations-einheit-list';
private readonly organisationsEinheitenName: string = 'organisations-einheit-name';
private readonly organisationsEinheitenID: string = 'organisations-einheit-id';
private readonly errorColor: string = 'text-red-500';
private readonly errorIcon: string = 'organisations-einheit-sync-error';
private readonly errorText: string = 'Organisationseinheit wurde nicht in den PVOG-Daten gefunden.';
public getOrganisationsEinheitList(): Cypress.Chainable<Element> {
return cy.getTestElement(this.organisationsEinheitenList);
}
public getListItemByName(name: string): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.getTestElement(this.organisationsEinheitenName).contains(name);
}
public openOrganisationsEinheit(name: string): void {
this.getListItemByName(name).click();
}
public organisationsEinheitContainsID(name: string, id: string): void {
this.getListItemByName(name)
.parents('a')
.within(() => {
haveText(cy.getTestElement(this.organisationsEinheitenID), id);
});
}
public elementIsShownAsError(name: string): void {
containClass(this.getListItemByName(name).closest('ods-list-item'), this.errorColor);
}
public getErrorIconInElement(name: string): Cypress.Chainable<JQuery<HTMLAnchorElement>> {
return this.getListItemByName(name)
.parents('a')
.within(() => {
exist(cy.getTestElement(this.errorIcon));
});
}
public getErrorTooltip(name: string): Cypress.Chainable<JQuery<HTMLElement>> {
return this.getErrorIconInElement(name)
.find('ods-exclamation-icon[mattooltip]')
.should('have.attr', 'mattooltip')
.and('include', this.errorText);
}
public elementShowsNoError(name: string): void {
notContainClass(this.getListItemByName(name).closest('ods-list-item'), this.errorColor);
}
}
......@@ -9,6 +9,7 @@ export class PostfachE2EComponent {
}
public setSignatur(signatur: string): void {
this.clearSignatur();
typeText(this.getSignaturText(), signatur);
}
......
import { MainPage } from 'apps/admin-e2e/src/page-objects/main.po';
import { BenutzerE2EComponent } from '../../../components/benutzer/benutzer.e2e.component';
import { beChecked, beEnabled, exist, notBeChecked, notBeEnabled } from '../../../support/cypress.util';
import { loginAsAriane } from '../../../support/user-util';
import { AlfaRollen, AlfaUsers, loginAsAriane } from '../../../support/user-util';
const mainPage: MainPage = new MainPage();
const benutzerPage: BenutzerE2EComponent = new BenutzerE2EComponent();
const role1: string = 'VERWALTUNG_USER';
const role2: string = 'VERWALTUNG_LOESCHEN';
const role3: string = 'VERWALTUNG_POSTSTELLE';
const orga1: string = 'Ordnungsamt';
const orga2: string = 'Denkmalpflege';
const orga3: string = 'Wirtschaftsförderung';
const orga_none: string = 'keine zuständige Stelle zugewiesen';
const mail1: string = 'peter.von.der.post@ozg-sh.de';
const organistationsEinheitOrdnungsamt: string = 'Ordnungsamt';
const organisationsEinheitDenkmalpflege: string = 'Denkmalpflege';
const organisationsEinheitWirtschaftsfoerderung: string = 'Wirtschaftsförderung';
const organisationsEinheitNone: string = 'keine zuständige Stelle zugewiesen';
const emailAddress: string = 'peter.von.der.post@ozg-sh.de';
describe('Benutzer und Rollen', () => {
before(() => {
......@@ -25,21 +22,17 @@ describe('Benutzer und Rollen', () => {
exist(benutzerPage.getHinzufuegenButton());
});
it('should show table with users and roles', () => {
exist(benutzerPage.getUserRolesTable());
});
it('should show users and attributes in table', () => {
exist(benutzerPage.getUserEntry('ariane'));
benutzerPage.stringExistsInUserEntry(role1, 'dorothea');
benutzerPage.stringExistsInUserEntry(orga1, 'ludwig');
benutzerPage.stringExistsInUserEntry(role1, 'zelda');
benutzerPage.stringExistsInUserEntry(role2, 'zelda');
benutzerPage.stringExistsInUserEntry(orga2, 'zelda');
benutzerPage.stringExistsInUserEntry(orga3, 'zelda');
benutzerPage.stringExistsInUserEntry(orga_none, 'adelheit');
benutzerPage.stringExistsInUserEntry(mail1, 'peter');
benutzerPage.stringExistsInUserEntry(role3, 'peter');
benutzerPage.stringExistsInUserEntry(AlfaRollen.USER, AlfaUsers.DOROTHEA);
benutzerPage.stringExistsInUserEntry(organistationsEinheitOrdnungsamt, AlfaUsers.LUDWIG);
benutzerPage.stringExistsInUserEntry(AlfaRollen.USER, AlfaUsers.ZELDA);
benutzerPage.stringExistsInUserEntry(AlfaRollen.LOESCHEN, AlfaUsers.LUDWIG);
benutzerPage.stringExistsInUserEntry(organisationsEinheitDenkmalpflege, AlfaUsers.ZELDA);
benutzerPage.stringExistsInUserEntry(organisationsEinheitWirtschaftsfoerderung, AlfaUsers.ZELDA);
benutzerPage.stringExistsInUserEntry(organisationsEinheitNone, AlfaUsers.RICHARD);
benutzerPage.stringExistsInUserEntry(emailAddress, AlfaUsers.PETER);
benutzerPage.stringExistsInUserEntry(AlfaRollen.POSTSTELLE, AlfaUsers.PETER);
});
it('should show single user screen on click', () => {
......
import { PostfachE2EComponent } from '../../../components/postfach/postfach.e2e.component';
import { HeaderE2EComponent } from '../../../page-objects/header.po';
import { MainPage, waitForSpinnerToDisappear } from '../../../page-objects/main.po';
import { waitForSpinnerToDisappear } from '../../../page-objects/main.po';
import { exist } from '../../../support/cypress.util';
import { loginAsAriane } from '../../../support/user-util';
describe('Signatur', () => {
const mainPage: MainPage = new MainPage();
const header: HeaderE2EComponent = mainPage.getHeader();
const postfachTab: PostfachE2EComponent = new PostfachE2EComponent();
const postfach: PostfachE2EComponent = new PostfachE2EComponent();
const signaturText: string = 'Signatur\nmit\n\n\n\nZeilenumbruch\n\n';
......@@ -15,21 +12,23 @@ describe('Signatur', () => {
loginAsAriane();
});
it('should clear current signature', () => {
it('should show Postfach page', () => {
waitForSpinnerToDisappear();
exist(postfachTab.getSignaturText());
exist(postfach.getSignaturText());
});
postfachTab.clearSignatur();
postfachTab.signatureIs('');
it('should show signature input with scrollbar', () => {
postfach.setSignatur(signaturText);
postfach.saveSignatur();
postfachTab.saveSignatur();
postfach.signatureIs(signaturText);
postfach.scrollbarIsPresent();
});
it('should show Signatur input', () => {
postfachTab.setSignatur(signaturText);
postfachTab.saveSignatur();
it('should enter an save empty signature', () => {
postfach.clearSignatur();
postfach.saveSignatur();
postfachTab.signatureIs(signaturText);
postfachTab.scrollbarIsPresent();
postfach.signatureIs('');
});
});
import { OrganisationsEinheitenE2EComponent } from '../../components/organisationseinheiten/organisationseinheiten.e2e.component';
import { MainPage, waitForSpinnerToDisappear } from '../../page-objects/main.po';
import { exist } from '../../support/cypress.util';
import { OrganisationsEinheitSyncResultE2E } from '../../support/organisationseinheit';
import {
createBauamtOrganisationsEinheit,
createDenkmalpflegeOrganisationsEinheit,
createFundstelleOrganisationsEinheit,
initOrganisationsEinheiten,
} from '../../support/organisationseinheit-util';
import { loginAsAriane } from '../../support/user-util';
describe('show Organisationsheiten', () => {
const mainPage: MainPage = new MainPage();
const organisationsEinheitenTab: OrganisationsEinheitenE2EComponent = new OrganisationsEinheitenE2EComponent();
before(() => {
loginAsAriane();
initOrganisationsEinheiten([
createBauamtOrganisationsEinheit(),
{ ...createDenkmalpflegeOrganisationsEinheit(), syncResult: OrganisationsEinheitSyncResultE2E.NAME_MISMATCH },
{ ...createFundstelleOrganisationsEinheit(), syncResult: OrganisationsEinheitSyncResultE2E.NOT_FOUND_IN_PVOG },
]);
});
it('should show table of Organisationseinheiten', () => {
waitForSpinnerToDisappear();
mainPage.openOrganisationsEinheiten();
exist(organisationsEinheitenTab.getOrganisationsEinheitList());
});
it('should show identical data in Keycloak and PVOG without error', () => {
organisationsEinheitenTab.getListItemByName('Bauamt');
organisationsEinheitenTab.organisationsEinheitContainsID('Bauamt', '248240886');
organisationsEinheitenTab.elementShowsNoError('Bauamt');
});
it('should show data not found in PVOG in red color and with error icon and tooltip message', () => {
const organisationsEinheitName: string = 'Fundstelle';
organisationsEinheitenTab.organisationsEinheitContainsID(organisationsEinheitName, '10363455');
organisationsEinheitenTab.elementIsShownAsError(organisationsEinheitName);
organisationsEinheitenTab.getErrorIconInElement(organisationsEinheitName);
organisationsEinheitenTab.getErrorTooltip(organisationsEinheitName);
});
it('should get name for OE from PVOG, if mismatch with Keycloak, but without error', () => {
organisationsEinheitenTab.organisationsEinheitContainsID('Landesamt für Denkmalpflege', '9093371');
organisationsEinheitenTab.elementShowsNoError('Landesamt für Denkmalpflege');
});
});
import { OrganisationseinheitenSignaturE2EComponent } from '../../components/organisationseinheiten/organisationseinheiten-signatur.e2e.component';
import { OrganisationsEinheitenE2EComponent } from '../../components/organisationseinheiten/organisationseinheiten.e2e.component';
import { MainPage, waitForSpinnerToDisappear } from '../../page-objects/main.po';
import { haveText } from '../../support/cypress.util';
import { loginAsAriane } from '../../support/user-util';
describe('Signatur', () => {
const mainPage: MainPage = new MainPage();
const signaturePage: OrganisationseinheitenSignaturE2EComponent = new OrganisationseinheitenSignaturE2EComponent();
const organisationsEinheitenTab: OrganisationsEinheitenE2EComponent = new OrganisationsEinheitenE2EComponent();
const signatureText: string = 'Signatur\nmit\n\n\n\nZeilenumbruch\n\n';
before(() => {
loginAsAriane();
});
it('should open signature page for Bauamt on click', () => {
waitForSpinnerToDisappear();
mainPage.openOrganisationsEinheiten();
organisationsEinheitenTab.openOrganisationsEinheit('Bauamt');
haveText(signaturePage.getOrganisationsEinheitName(), 'Bauamt');
});
it('should show signature input with scrollbar', () => {
signaturePage.setSignature(signatureText);
signaturePage.saveSignature();
signaturePage.hasSignature(signatureText);
signaturePage.hasScrollbar();
});
it.skip('should enter and save empty signature', () => {
signaturePage.clearSignature();
signaturePage.saveSignature();
signaturePage.hasSignature('');
});
});
{
"_id": {
"$oid": "602566a807bb665df9a86101"
},
"name": "Bauamt",
"organisationsEinheitId": "248240886",
"syncResult": "OK"
}
{
"_id": {
"$oid": "602566a807bb665df9a86100"
},
"name": "Landesamt für Denkmalpflege",
"organisationsEinheitId": "9093371",
"syncResult": "OK"
}
{
"_id": {
"$oid": "602566a807bb665df9a86102"
},
"name": "Fundstelle",
"organisationsEinheitId": "10363455",
"syncResult": "OK"
}
export class ObjectIdE2E {
$oid: string;
}
......@@ -6,7 +6,7 @@ export class MainPage {
private readonly header: HeaderE2EComponent = new HeaderE2EComponent();
private readonly benutzerTab: string = 'caption-Benutzer__Rollen';
private readonly postfachTab: string = 'caption-Postfach';
private readonly organisationseinheitenTab: string = 'caption-Organisationseinheiten';
private readonly organisationsEinheitenTab: string = 'caption-Organisationseinheiten';
public getBuildInfo(): BuildInfoE2EComponent {
return this.buildInfo;
......@@ -24,12 +24,12 @@ export class MainPage {
this.getBenutzerTab().click();
}
public getOrganisationseinheitenTab(): Cypress.Chainable<Element> {
return cy.getTestElement(this.organisationseinheitenTab);
public getOrganisationsEinheitenMenu(): Cypress.Chainable<Element> {
return cy.getTestElement(this.organisationsEinheitenTab);
}
public clickOrganisationseinheitenTab(): void {
this.getOrganisationseinheitenTab().click();
public openOrganisationsEinheiten(): void {
this.getOrganisationsEinheitenMenu().click();
}
}
......
import { Interception, RouteHandler, RouteMatcher } from 'cypress/types/net-stubbing';
import { OrganisationsEinheitE2E } from './organisationseinheit';
enum CypressTasks {
DROP_COLLECTIONS = 'dropCollections',
INIT_ORGANISATIONS_EINHEIT_DATA = 'initOrganisationsEinheitData',
}
enum MongoCollections {
ORGANISATIONS_EINHEIT = 'organisationsEinheit',
}
const DOWNLOAD_FOLDER: string = 'cypress/downloads';
......@@ -14,11 +24,7 @@ export function intercept(method: string, url: string): Cypress.Chainable<null>
return cy.intercept(method, url);
}
export function interceptWithResponse(
method,
url: RouteMatcher,
response: RouteHandler,
): Cypress.Chainable<null> {
export function interceptWithResponse(method, url: RouteMatcher, response: RouteHandler): Cypress.Chainable<null> {
return cy.intercept(method, url, response);
}
......@@ -45,6 +51,7 @@ export function wait(ms: number, reason = ''): void {
console.log(`Had to wait ${ms}ms because of: ${reason}`);
}
}
//
export function reload(): void {
......@@ -68,3 +75,12 @@ export function getBaseUrl(): string {
export function getCypressEnv(value: string) {
return Cypress.env(value);
}
export function initOrganisationsEinheitenData(data: OrganisationsEinheitE2E[]): void {
cy.task(CypressTasks.DROP_COLLECTIONS, [MongoCollections.ORGANISATIONS_EINHEIT]);
cy.task(CypressTasks.INIT_ORGANISATIONS_EINHEIT_DATA, { collection: MongoCollections.ORGANISATIONS_EINHEIT, data });
}
export function dropCollections() {
cy.task(CypressTasks.DROP_COLLECTIONS, [MongoCollections.ORGANISATIONS_EINHEIT]);
}
import { MongoClient } from 'mongodb';
import { Db, MongoClient, ObjectId } from 'mongodb';
const fs = require('fs');
module.exports = (on: any, config: any) => {
......@@ -52,8 +53,12 @@ module.exports = (on: any, config: any) => {
dropCollectionsFromDatabase(config, collections);
return 0;
},
initOrganisationsEinheitData({ collection, data }) {
console.log('initOrganisationsEinheitData');
insertIntoDatabase(config, collection, parseOrganisationsEinheitData(data));
return 0;
},
});
return config;
// Ende - Workaround für Angular 13 und Cypress mit Webpack 4
};
......@@ -89,3 +94,58 @@ function dropCollections(databaseUrl, databaseName, collections) {
}
});
}
function insertIntoDatabase(config, collection, data) {
insert(getDatabaseUrl(config), getDatabase(config), collection, data);
}
function insert(databaseUrl, databaseName, collection, data) {
MongoClient.connect(databaseUrl, (error, connection) => {
console.log(`connect to ${databaseName} database with ${databaseUrl}`);
if (!error) {
console.log('success');
const db: Db = connection.db(databaseName);
db.collection(collection).drop(() => {
db.createCollection(collection, (error) => handleCreateCollection(db, connection, collection, data, error));
});
} else {
console.error('Error: ', error);
}
});
}
function handleCreateCollection(db, connection, collection, data, error) {
if (error) {
console.error(`Fehler beim Erstellen der Collection "${collection}": `, error);
} else {
console.log(`Collection ${collection} erfolgreich erstellt`);
insertManyToDatabase(db, connection, collection, data);
}
}
function insertManyToDatabase(db, connection, collection, data) {
db.collection(collection).insertMany(data, (error) => handleInsertMany(connection, error));
}
function handleInsertMany(connection, error) {
if (error) {
console.error('Fehler beim Einlesen der Daten: ', error);
} else {
console.log('Die Daten wurden erfolgreich eingelesen.');
}
connection.close();
}
function parseOrganisationsEinheit(organisationsEinheit) {
organisationsEinheit._id = createObjectId(organisationsEinheit);
}
function createObjectId(field) {
return new ObjectId(field._id.$oid);
}
function parseOrganisationsEinheitData(data) {
data.forEach((organisationsEinheit) => parseOrganisationsEinheit(organisationsEinheit));
return data;
}
......@@ -113,6 +113,10 @@ export function backspaceOn(element: Cypress.Chainable<Element>): void {
element.type(CypressKeyboardActions.BACKSPACE);
}
export function clearText(element: Cypress.Chainable<Element>): void {
element.type('{selectAll}{del}');
}
enum CypressKeyboardActions {
ENTER = '{enter}',
BACKSPACE = '{backspace}',
......
import { initOrganisationsEinheitenData } from './cypress-helper';
import { OrganisationsEinheitE2E } from './organisationseinheit';
const denkmalpflegeOrganisationseinheitFixture = require('../fixtures/organisationseinheit/denkmalpflege.json');
const bauamtOrganisationseinheitFixture = require('../fixtures/organisationseinheit/bauamt.json');
const fundstelleOrganisationseinheitFixture = require('../fixtures/organisationseinheit/fundstelle.json');
export function initOrganisationsEinheit(organisationsEinheiten: OrganisationsEinheitE2E): void {
initOrganisationsEinheitenData([organisationsEinheiten]);
}
export function initOrganisationsEinheiten(organisationsEinheiten: OrganisationsEinheitE2E[]): void {
initOrganisationsEinheitenData(organisationsEinheiten);
}
export function createBauamtOrganisationsEinheit(): OrganisationsEinheitE2E {
return bauamtOrganisationseinheitFixture;
}
export function createFundstelleOrganisationsEinheit(): OrganisationsEinheitE2E {
return fundstelleOrganisationseinheitFixture;
}
export function createDenkmalpflegeOrganisationsEinheit(): OrganisationsEinheitE2E {
return denkmalpflegeOrganisationseinheitFixture;
}
import { ObjectIdE2E } from '../model/util';
export class OrganisationsEinheitE2E {
_id: ObjectIdE2E;
name: string;
organisationsEinheitId: string;
syncResult: OrganisationsEinheitSyncResultE2E;
settings: OrganisationsEinheitSettingsE2E;
}
export enum OrganisationsEinheitSyncResultE2E {
OK = 'OK',
NOT_FOUND_IN_PVOG = 'NOT_FOUND_IN_PVOG',
NAME_MISMATCH = 'NAME_MISMATCH',
ORGANISATIONSEINHEIT_ID_NOT_UNIQUE = 'ORGANISATIONSEINHEIT_ID_NOT_UNIQUE',
DELETED = 'DELETED',
}
export class OrganisationsEinheitSettingsE2E {
signatur: string;
}
......@@ -42,3 +42,17 @@ export function logout(): void {
const header: HeaderE2EComponent = mainPage.getHeader();
header.getCurrentUserProfile().logout();
}
export enum AlfaRollen {
USER = 'VERWALTUNG_USER',
LOESCHEN = 'VERWALTUNG_LOESCHEN',
POSTSTELLE = 'VERWALTUNG_POSTSTELLE',
}
export enum AlfaUsers {
DOROTHEA = 'dorothea',
LUDWIG = 'ludwig',
PETER = 'peter',
RICHARD = 'richard',
ZELDA = 'zelda',
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment