Skip to content
Snippets Groups Projects
Commit 2791163f authored by Albert Bruns's avatar Albert Bruns
Browse files

Merge branch 'OZG-7473-e2e' into 'OZG-7473-save-statistic-fields'

OZG-7473-e2e
parents 977be843 6b71b9cf
No related branches found
No related tags found
2 merge requests!106OZG-7473-e2e,!104Administration: Neu hinzugefügte Felder für Statistik speichern
Showing
with 164 additions and 67 deletions
import { enterWith } from '../../support/cypress.util';
export class AggregationMappingFormE2EComponent {
private readonly rootElement: string = 'aggregation-mapping-form';
private readonly nameInput: string = 'aggregation-mapping-name-text-input';
private readonly formEngineInput: string = 'form-engine-name-text-input';
private readonly formIdInput: string = 'form-id-text-input';
private readonly formDataFieldInput: string = 'mapping-field-';
private readonly dataFieldInputPrefix: string = 'aggregation-mapping-field-mapping-form-';
private readonly sourceMappingFieldInputPrefix: string = 'source-mapping-field-';
private readonly targetMappingFieldInputPrefix: string = 'target-mapping-field-';
private readonly addDataFieldButton: string = 'add-mapping-button';
private readonly deleteDataFieldButtonPrefix: string = 'remove-mapping-button-';
private readonly saveButton: string = 'save-button';
private readonly cancelButton: string = 'cancel-button';
public getFormEngineInput(): Cypress.Chainable<Element> {
return cy.getTestElement(this.formEngineInput);
public getRootElement(): Cypress.Chainable<Element> {
return cy.getTestElement(this.rootElement);
}
public enterFormEngine(text: string): void {
enterWith(this.getFormEngineInput(), text);
public getNameInput(): Cypress.Chainable<Element> {
return cy.getTestElement(this.nameInput);
}
public getFormEngineInput(): Cypress.Chainable<Element> {
return cy.getTestElement(this.formEngineInput);
}
public getFormIdInput(): Cypress.Chainable<Element> {
return cy.getTestElement(this.formIdInput);
}
public enterFormId(text: string): void {
enterWith(this.getFormIdInput(), text);
public getDataFieldInput(index: number): Cypress.Chainable<Element> {
return cy.getTestElement(`${this.dataFieldInputPrefix}${index}`);
}
public getAddFieldButton(): Cypress.Chainable<Element> {
return cy.getTestElement(this.addDataFieldButton);
}
public addField(): void {
this.getAddFieldButton().click();
public getSourceMappingFieldInput(index: number): Cypress.Chainable<Element> {
return cy.getTestElement(`${this.sourceMappingFieldInputPrefix}${index}-text-input`);
}
public getDataFieldInput(index: number): Cypress.Chainable<Element> {
return cy.getTestElement(this.formDataFieldInput + index + '-text-input');
}
public enterDataFieldPath(text: string, index: number): void {
enterWith(this.getDataFieldInput(index), text);
public getTargetMappingFieldInput(index: number): Cypress.Chainable<Element> {
return cy.getTestElement(`${this.targetMappingFieldInputPrefix}${index}-text-input`);
}
public getDataFieldDeleteButton(index: number): Cypress.Chainable<Element> {
return cy.getTestElement(this.deleteDataFieldButtonPrefix + index);
}
public deleteDataField(index: number): void {
this.getDataFieldDeleteButton(index).click();
}
public getSaveButton(): Cypress.Chainable<Element> {
return cy.getTestElement(this.saveButton);
}
public save(): void {
this.getSaveButton().click();
}
public getCancelButton(): Cypress.Chainable<Element> {
return cy.getTestElement(this.cancelButton);
}
public cancel(): void {
this.getCancelButton().click();
}
}
export class AggregationMappingE2EComponent {
private readonly locatorHeaderText: string = 'aggregation-mapping-header-text';
private readonly locatorWeitereFelderAuswertenButton = 'weitere-felder-auswerten-button';
private readonly headerText: string = 'aggregation-mapping-header-text';
private readonly listItemName: string = 'list-item-name';
private readonly listItemFormEngineName: string = 'list-item-form-engine-name';
private readonly listItemFormId: string = 'list-item-form-id';
private readonly weitereFelderAuswertenButton = 'weitere-felder-auswerten-button';
public getHeaderText(): Cypress.Chainable<Element> {
return cy.getTestElement(this.locatorHeaderText);
return cy.getTestElement(this.headerText);
}
public getListItemName(): Cypress.Chainable<Element> {
return cy.getTestElementWithClass(this.listItemName);
}
public getListItemFormEngineName(): Cypress.Chainable<Element> {
return cy.getTestElementWithClass(this.listItemFormEngineName);
}
public getListItemFormId(): Cypress.Chainable<Element> {
return cy.getTestElementWithClass(this.listItemFormId);
}
public getWeitereFelderAuswertenButton(): Cypress.Chainable<Element> {
return cy.getTestElement(this.locatorWeitereFelderAuswertenButton);
return cy.getTestElement(this.weitereFelderAuswertenButton);
}
}
import { AggregationMapping, FieldMapping } from '@admin-client/reporting-shared';
import { AggregationMappingFormE2EComponent } from '../../../components/aggregation-mapping/aggregation-mapping-form.e2e.component';
import { AggregationMappingE2EComponent } from '../../../components/aggregation-mapping/aggregation-mapping.e2e.component';
import { exist, haveValue } from '../../../support/cypress.util';
import { E2EAggregationMappingHelper } from '../../../helper/aggregation-mapping/aggregation-mapping.helper';
import { dropCollections } from '../../../support/cypress-helper';
import { exist, notExist } from '../../../support/cypress.util';
import { loginAsDaria } from '../../../support/user-util';
describe('Aggregation Mapping hinzufügen', () => {
const component: AggregationMappingE2EComponent = new AggregationMappingE2EComponent();
const fieldsFormComponent: AggregationMappingFormE2EComponent = new AggregationMappingFormE2EComponent();
const formComponent: AggregationMappingFormE2EComponent = new AggregationMappingFormE2EComponent();
const dataText1: string = 'Eingabe A';
const dataText2: string = 'Eingabe B';
const helper: E2EAggregationMappingHelper = new E2EAggregationMappingHelper();
const fieldMapping0: FieldMapping = {
sourcePath: '/path/to/source/a',
targetPath: '/path/to/target/a',
};
const fieldMapping1: FieldMapping = {
sourcePath: '/path/to/source/b',
targetPath: '/path/to/target/b',
};
const aggregationMapping: AggregationMapping = {
name: 'Aggregation Mapping',
formIdentifier: {
formEngineName: 'formEngineName',
formId: 'formId',
},
mappings: [fieldMapping0, fieldMapping1],
};
before(() => {
loginAsDaria();
});
after(() => {
dropCollections();
});
it('should show "Weitere Felder auswerten" button', () => {
exist(component.getWeitereFelderAuswertenButton());
});
it('should have all form elements after button click', () => {
it('should show form after button click', () => {
component.getWeitereFelderAuswertenButton().click();
exist(fieldsFormComponent.getFormEngineInput());
exist(fieldsFormComponent.getFormIdInput());
exist(fieldsFormComponent.getDataFieldInput(0));
exist(fieldsFormComponent.getDataFieldDeleteButton(0));
exist(fieldsFormComponent.getAddFieldButton());
exist(fieldsFormComponent.getSaveButton());
exist(fieldsFormComponent.getCancelButton());
exist(formComponent.getRootElement());
});
it('should navigate to aggregation mapping on cancel', () => {
formComponent.getCancelButton().click();
exist(component.getWeitereFelderAuswertenButton());
});
it('should add data field', () => {
fieldsFormComponent.addField();
it('should add data field in form', () => {
component.getWeitereFelderAuswertenButton().click();
formComponent.getAddFieldButton().click();
exist(fieldsFormComponent.getDataFieldInput(1));
exist(formComponent.getDataFieldInput(1));
});
it('should enter text in both data fields', () => {
fieldsFormComponent.enterDataFieldPath(dataText1, 0);
fieldsFormComponent.enterDataFieldPath(dataText2, 1);
it('should fill out form with two data fields', () => {
helper.enterForm(aggregationMapping);
haveValue(fieldsFormComponent.getDataFieldInput(0), dataText1);
haveValue(fieldsFormComponent.getDataFieldInput(1), dataText2);
helper.verifyForm(aggregationMapping);
});
it('should delete data fields', () => {
fieldsFormComponent.deleteDataField(0);
haveValue(fieldsFormComponent.getDataFieldInput(0), dataText2);
formComponent.getDataFieldDeleteButton(0).click();
notExist(formComponent.getDataFieldInput(1));
});
it('should navigate to aggregation mapping on cancel', () => {
fieldsFormComponent.cancel();
it('should show aggregation mapping in list after save', () => {
formComponent.getSaveButton().click();
exist(component.getWeitereFelderAuswertenButton());
helper.verifyAggregationMappingInList(aggregationMapping);
});
});
import { AggregationMapping, FieldMapping } from '@admin-client/reporting-shared';
import { AggregationMappingFormE2EComponent } from '../../components/aggregation-mapping/aggregation-mapping-form.e2e.component';
import { AggregationMappingE2EComponent } from '../../components/aggregation-mapping/aggregation-mapping.e2e.component';
import { enterWith, haveText, haveValue } from '../../support/cypress.util';
export class E2EAggregationMappingHelper {
private component: AggregationMappingE2EComponent = new AggregationMappingE2EComponent();
private formComponent: AggregationMappingFormE2EComponent = new AggregationMappingFormE2EComponent();
public enterName(text: string): void {
enterWith(this.formComponent.getNameInput(), text);
}
public enterFormEngine(text: string): void {
enterWith(this.formComponent.getFormEngineInput(), text);
}
public enterFormId(text: string): void {
enterWith(this.formComponent.getFormIdInput(), text);
}
public enterSourcePath(text: string, index: number): void {
enterWith(this.formComponent.getSourceMappingFieldInput(index), text);
}
public enterTargetPath(text: string, index: number): void {
enterWith(this.formComponent.getTargetMappingFieldInput(index), text);
}
public enterFieldMapping(fieldMapping: FieldMapping, index: number): void {
this.enterSourcePath(fieldMapping.sourcePath, index);
this.enterTargetPath(fieldMapping.targetPath, index);
}
public enterForm(aggregationMapping: AggregationMapping): void {
this.enterName(aggregationMapping.name);
this.enterFormEngine(aggregationMapping.formIdentifier.formEngineName);
this.enterFormId(aggregationMapping.formIdentifier.formId);
aggregationMapping.mappings.forEach((fieldMapping, index) => {
this.enterFieldMapping(fieldMapping, index);
});
}
public verifyFieldMapping(fieldMapping: FieldMapping, index: number): void {
haveValue(this.formComponent.getSourceMappingFieldInput(index), fieldMapping.sourcePath);
haveValue(this.formComponent.getTargetMappingFieldInput(index), fieldMapping.targetPath);
}
public verifyForm(aggregationMapping: AggregationMapping): void {
haveValue(this.formComponent.getNameInput(), aggregationMapping.name);
haveValue(this.formComponent.getFormEngineInput(), aggregationMapping.formIdentifier.formEngineName);
haveValue(this.formComponent.getFormIdInput(), aggregationMapping.formIdentifier.formId);
aggregationMapping.mappings.forEach((fieldMapping, index) => {
this.verifyFieldMapping(fieldMapping, index);
});
}
public verifyAggregationMappingInList(aggregationMapping: AggregationMapping): void {
haveText(this.component.getListItemName(), aggregationMapping.name);
haveText(this.component.getListItemFormEngineName(), aggregationMapping.formIdentifier.formEngineName);
haveText(this.component.getListItemFormId(), aggregationMapping.formIdentifier.formId);
}
}
......@@ -31,6 +31,7 @@ enum CypressTasks {
enum MongoCollections {
ORGANISATIONS_EINHEIT = 'organisationsEinheit',
SETTINGS = 'settings',
}
const DOWNLOAD_FOLDER: string = 'cypress/downloads';
......@@ -110,4 +111,5 @@ export function initOrganisationsEinheitenData(data: OrganisationsEinheitE2E[]):
export function dropCollections() {
cy.task(CypressTasks.DROP_COLLECTIONS, [MongoCollections.ORGANISATIONS_EINHEIT]);
cy.task(CypressTasks.DROP_COLLECTIONS, [MongoCollections.SETTINGS]);
}
<ods-spinner [stateResource]="listStateResource$ | async">
<admin-aggregation-mapping-form data-test-id="evaluate-fields-form"></admin-aggregation-mapping-form>
<admin-aggregation-mapping-form data-test-id="aggregation-mapping-form" />
</ods-spinner>
......@@ -6,7 +6,7 @@ import { ButtonComponent, DeleteIconComponent } from '@ods/system';
import { AggregationMappingFormService } from '../../aggregation-mapping-form.service';
@Component({
selector: 'admin-aggregatin-mapping-field-form',
selector: 'admin-aggregation-mapping-field-form',
standalone: true,
templateUrl: './aggregation-mapping-field-form.component.html',
imports: [ButtonComponent, DeleteIconComponent, ReactiveFormsModule, TextEditorComponent],
......
<form [formGroup]="formService.form">
<div class="flex flex-col" [formArrayName]="AggregationMappingFormService.FIELD_MAPPINGS">
<div *ngFor="let ignore of mappingsFormArray; let i = index">
<admin-aggregatin-mapping-field-form
<admin-aggregation-mapping-field-form
[index]="i"
[attr.data-test-id]="'aggregation-mapping-field-mapping-form-' + i"
></admin-aggregatin-mapping-field-form>
></admin-aggregation-mapping-field-form>
</div>
</div>
</form>
<ods-list-item [path]="aggregationMapping | toResourceUri" [attr.data-test-id]="aggregationMapping.name | convertForDataTest">
<dl class="flex w-full">
<div class="w-1/2">
<div class="flex-1">
<dt class="sr-only">Name</dt>
<dd class="font-semibold" data-test-class="fullname">{{ aggregationMapping.name }}</dd>
<dd class="font-semibold" data-test-class="list-item-name">{{ aggregationMapping.name }}</dd>
</div>
<!-- Remove null safe check operator after backend provides correct data. -->
<div class="flex-wrap w-1/2">
<div class="flex-wrap flex-1">
<dt class="sr-only">Formengine</dt>
<dd>{{ aggregationMapping.formIdentifier?.formEngineName }}</dd>
<dd data-test-class="list-item-form-engine-name">{{ aggregationMapping.formIdentifier?.formEngineName }}</dd>
<dt class="sr-only">Form ID</dt>
<dd>{{ aggregationMapping.formIdentifier?.formId }}</dd>
<dd data-test-class="list-item-form-id">{{ aggregationMapping.formIdentifier?.formId }}</dd>
</div>
</dl>
</ods-list-item>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment