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

OZG-6988 add e2e tests

Sub task: OZG-67455
parent 0fc53ba3
Branches
Tags
1 merge request!34OZG-6988 add e2e tests
Showing
with 136 additions and 19 deletions
......@@ -44,6 +44,7 @@ services:
environment:
- SPRING_PROFILES_ACTIVE=${SPRING_PROFILE:-local,remotekc}
- SPRING_DATA_MONGODB_URI=mongodb://mongodb:27017/config-db
- OZGCLOUD_OAUTH2_REALM=${KEYCLOAK_REAM:-by-e2e-tests-local-dev}
ports:
- 8080:8080
depends_on:
......
import { exist } from '../../support/cypress.util';
export class StatistikE2EComponent {
private readonly headerText: string = 'statistik-header-text';
public isHeaderTextVisible(): void {
exist(cy.getTestElement(this.headerText));
}
}
import { enterWith } from '../../support/cypress.util';
export class StatistikFieldsFormE2EComponent {
private readonly locatorFormEngineInput: string = 'form-engine-input';
private readonly locatorFormIdInput: string = 'form-id-input';
private readonly locatorFormDataFieldInput: string = 'data-statistik-field-';
private readonly locatorAddFieldButton: string = 'add-data-field-button';
private readonly locatorSaveButton: string = 'save-statistik-fields-button';
private readonly locatorCancelButton: string = 'cancel-statistik-fields-button';
public getFormEngineInput() {
return cy.getTestElement(this.locatorFormEngineInput);
}
public enterFormEngine(text: string): void {
enterWith(this.getFormEngineInput(), text);
}
public getFormIdInput() {
return cy.getTestElement(this.locatorFormIdInput);
}
public enterFormId(text: string): void {
enterWith(this.getFormIdInput(), text);
}
public getAddFieldButton() {
return cy.getTestElement(this.locatorAddFieldButton);
}
public addField(): void {
this.getAddFieldButton().click();
}
public getDataFieldInput(index: number) {
return cy.getTestElement(this.locatorFormDataFieldInput + index);
}
public enterDataFieldPath(text: string, index: number): void {
enterWith(this.getDataFieldInput(index), text);
}
public getSaveButton() {
return cy.getTestElement(this.locatorSaveButton);
}
public save(): void {
this.getSaveButton().click();
}
public getCancelButton() {
return cy.getTestElement(this.locatorCancelButton);
}
public cancel(): void {
this.getCancelButton().click();
}
}
import { exist } from '../../support/cypress.util';
export class StatistikE2EComponent {
private readonly locatorHeaderText: string = 'statistik-header-text';
private readonly locatorWeitereFelderAuswertenButton = 'weitere-felder-auswerten-button';
public isHeaderTextVisible(): void {
exist(cy.getTestElement(this.locatorHeaderText));
}
public getWeiterFelderAuswertenButton() {
return cy.getTestElement(this.locatorWeitereFelderAuswertenButton);
}
}
import { StatistikE2EComponent } from 'apps/admin-e2e/src/components/statistik/statistik-component';
import { MainPage, waitForSpinnerToDisappear } from 'apps/admin-e2e/src/page-objects/main.po';
import { exist, notExist } from 'apps/admin-e2e/src/support/cypress.util';
import { loginAsDaria } from 'apps/admin-e2e/src/support/user-util';
import { StatistikE2EComponent } from '../../../components/statistik/statistik.e2e.component';
describe('Navigation', () => {
const mainPage: MainPage = new MainPage();
......
import { StatistikE2EComponent } from 'apps/admin-e2e/src/components/statistik/statistik-component';
import { MainPage, waitForSpinnerToDisappear } from 'apps/admin-e2e/src/page-objects/main.po';
import { exist } from 'apps/admin-e2e/src/support/cypress.util';
import { loginAsSafira } from 'apps/admin-e2e/src/support/user-util';
import { StatistikE2EComponent } from '../../../components/statistik/statistik.e2e.component';
describe('Navigation', () => {
const mainPage: MainPage = new MainPage();
......
import { ROUTES } from '@admin-client/shared';
import { StatistikFieldsFormE2EComponent } from '../../../components/statistik/statistik-fields-form.e2e.component';
import { StatistikE2EComponent } from '../../../components/statistik/statistik.e2e.component';
import { urlShouldEndsWith } from '../../../support/cypress-helper';
import { exist } from '../../../support/cypress.util';
import { loginAsDaria } from '../../../support/user-util';
describe('Felder in Statistik hinzufügen', () => {
const component: StatistikE2EComponent = new StatistikE2EComponent();
const fieldsFormComponent: StatistikFieldsFormE2EComponent = new StatistikFieldsFormE2EComponent();
before(() => {
loginAsDaria();
});
it('should be on statistik page', () => {
urlShouldEndsWith(ROUTES.STATISTIK);
});
it('should show "Weiter Felder auswerten" button', () => {
exist(component.getWeiterFelderAuswertenButton());
});
it('should navigate to route', () => {
component.getWeiterFelderAuswertenButton().click();
urlShouldEndsWith(ROUTES.STATISTIK_NEU);
});
it('should have all form elements', () => {
exist(fieldsFormComponent.getFormEngineInput());
exist(fieldsFormComponent.getFormIdInput());
exist(fieldsFormComponent.getDataFieldInput(0));
exist(fieldsFormComponent.getAddFieldButton());
exist(fieldsFormComponent.getSaveButton());
exist(fieldsFormComponent.getCancelButton());
});
it('should add data field', () => {
fieldsFormComponent.addField();
exist(fieldsFormComponent.getDataFieldInput(1));
});
it('should navigate to statistik on cancel', () => {
fieldsFormComponent.cancel();
urlShouldEndsWith(ROUTES.STATISTIK);
});
});
......@@ -67,6 +67,10 @@ export function urlShouldInclude(text: string) {
return cy.url().should('include', text);
}
export function urlShouldEndsWith(route: string) {
return cy.url().should('match', new RegExp(`/${route}$`));
}
//TODO: anders loesen -> bad practice
export function wait(ms: number, reason = ''): void {
cy.wait(ms);
......
......@@ -24,13 +24,13 @@
></ods-text-input>
}
<ods-button text="Datenfeld hinzufügen" (clickEmitter)="addDataField()" data-test-id="add-data-field-button">
<ods-button text="Datenfeld hinzufügen" (clickEmitter)="addDataField()" dataTestId="add-data-field-button">
<ods-plus-icon icon class="fill-whitetext"/>
</ods-button>
<div class="mt-4 flex gap-4">
<ods-button text="Speichern" data-test-id="save-statistik-fields-button"></ods-button>
<ods-button text="Abbrechen" variant="outline" (clickEmitter)="onCancel()" data-test-id="cancel-statistik-fields-button">
<ods-button text="Speichern" dataTestId="save-statistik-fields-button"></ods-button>
<ods-button text="Abbrechen" variant="outline" (clickEmitter)="onCancel()" dataTestId="cancel-statistik-fields-button">
<ods-close-icon icon class="fill-primary"/>
</ods-button>
</div>
......
......@@ -4,7 +4,7 @@ import { existsAsHtmlElement, getElementComponentFromFixtureByCss, mock, Mock, t
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormBuilder } from '@angular/forms';
import { TextInputComponent } from '@ods/system';
import { getDataTestIdOf } from '../../../../../tech-shared/test/data-test';
import { getDataTestIdAttributeOf, getDataTestIdOf } from '../../../../../tech-shared/test/data-test';
import { AdminStatistikFieldsFormComponent } from './admin-statistik-fields-form.component';
import { StatistikFieldsFormService } from './statistik-fields.formservice';
......@@ -14,9 +14,9 @@ describe('AdminStatistikFieldsFormComponent', () => {
const formEngineInputTestId: string = getDataTestIdOf('form-engine-input');
const formIdInputTestId: string = getDataTestIdOf('form-id-input');
const addDataFieldButtonTestId: string = getDataTestIdOf('add-data-field-button');
const saveButtonTestId: string = getDataTestIdOf('save-statistik-fields-button');
const cancelButtonTestId: string = getDataTestIdOf('cancel-statistik-fields-button');
const addDataFieldButtonTestId: string = getDataTestIdAttributeOf('add-data-field-button');
const saveButtonTestId: string = getDataTestIdAttributeOf('save-statistik-fields-button');
const cancelButtonTestId: string = getDataTestIdAttributeOf('cancel-statistik-fields-button');
const dataField1TestId: string = getDataTestIdOf('data-statistik-field-0');
let formService: StatistikFieldsFormService;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment