diff --git a/alfa-client/apps/admin-e2e/src/components/aggregation-mapping/aggregation-mapping.e2e.component.ts b/alfa-client/apps/admin-e2e/src/components/aggregation-mapping/aggregation-mapping.e2e.component.ts index 10e67b06e5b45984cdb19be1ab4ee33595cbbf21..69df7bcedef6c8927a65f0e24873afc3d6c54bbb 100644 --- a/alfa-client/apps/admin-e2e/src/components/aggregation-mapping/aggregation-mapping.e2e.component.ts +++ b/alfa-client/apps/admin-e2e/src/components/aggregation-mapping/aggregation-mapping.e2e.component.ts @@ -1,27 +1,47 @@ +import { getTestElement } from '../../support/cypress-helper'; +import { convertToDataTestId } from '../../support/tech-util'; + export class AggregationMappingE2EComponent { 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.headerText); } - public getListItemName(): Cypress.Chainable<Element> { - return cy.getTestElementWithClass(this.listItemName); + public getWeitereFelderAuswertenButton(): Cypress.Chainable<Element> { + return cy.getTestElement(this.weitereFelderAuswertenButton); + } + + public getListItem(name: string): AggregationMappingListItemE2EComponent { + return new AggregationMappingListItemE2EComponent(name); + } +} + +export class AggregationMappingListItemE2EComponent { + private root: string; + + private readonly listItemName: string = 'list-item-name'; + private readonly listItemFormEngineName: string = 'list-item-form-engine-name'; + private readonly listItemFormId: string = 'list-item-form-id'; + + constructor(root: string) { + this.root = convertToDataTestId(root); } - public getListItemFormEngineName(): Cypress.Chainable<Element> { - return cy.getTestElementWithClass(this.listItemFormEngineName); + public getRoot(): Cypress.Chainable<Element> { + return getTestElement(this.root); } - public getListItemFormId(): Cypress.Chainable<Element> { - return cy.getTestElementWithClass(this.listItemFormId); + public getName(): Cypress.Chainable<Element> { + return this.getRoot().findTestElementWithClass(this.listItemName); } - public getWeitereFelderAuswertenButton(): Cypress.Chainable<Element> { - return cy.getTestElement(this.weitereFelderAuswertenButton); + public getFormEngineName(): Cypress.Chainable<Element> { + return this.getRoot().findTestElementWithClass(this.listItemFormEngineName); + } + + public getFormId(): Cypress.Chainable<Element> { + return this.getRoot().findTestElementWithClass(this.listItemFormId); } } diff --git a/alfa-client/apps/admin-e2e/src/e2e/main-tests/aggregation-mapping/aggregation-mapping.cy.ts b/alfa-client/apps/admin-e2e/src/e2e/main-tests/aggregation-mapping/aggregation-mapping.cy.ts index 48a51be1788a5315081986693533d927ae3ffcd0..ffabc87021d990125ddb5402cac4244d4dc2fa6b 100644 --- a/alfa-client/apps/admin-e2e/src/e2e/main-tests/aggregation-mapping/aggregation-mapping.cy.ts +++ b/alfa-client/apps/admin-e2e/src/e2e/main-tests/aggregation-mapping/aggregation-mapping.cy.ts @@ -1,4 +1,5 @@ import { AggregationMapping, FieldMapping } from '@admin-client/reporting-shared'; +import { E2EAggregationMappingVerifier } from 'apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.verifier'; import { AggregationMappingFormE2EComponent } from '../../../components/aggregation-mapping/aggregation-mapping-form.e2e.component'; import { AggregationMappingE2EComponent } from '../../../components/aggregation-mapping/aggregation-mapping.e2e.component'; import { E2EAggregationMappingHelper } from '../../../helper/aggregation-mapping/aggregation-mapping.helper'; @@ -7,10 +8,11 @@ import { exist, notExist } from '../../../support/cypress.util'; import { loginAsDaria } from '../../../support/user-util'; describe('Aggregation Mapping hinzufügen', () => { - const component: AggregationMappingE2EComponent = new AggregationMappingE2EComponent(); - const formComponent: AggregationMappingFormE2EComponent = new AggregationMappingFormE2EComponent(); + const page: AggregationMappingE2EComponent = new AggregationMappingE2EComponent(); + const form: AggregationMappingFormE2EComponent = new AggregationMappingFormE2EComponent(); const helper: E2EAggregationMappingHelper = new E2EAggregationMappingHelper(); + const verifier: E2EAggregationMappingVerifier = new E2EAggregationMappingVerifier(); const fieldMapping0: FieldMapping = { sourcePath: '/path/to/source/a', @@ -40,43 +42,45 @@ describe('Aggregation Mapping hinzufügen', () => { }); it('should show "Weitere Felder auswerten" button', () => { - exist(component.getWeitereFelderAuswertenButton()); + helper.openStatistik(); + + exist(page.getWeitereFelderAuswertenButton()); }); it('should show form after button click', () => { - component.getWeitereFelderAuswertenButton().click(); + page.getWeitereFelderAuswertenButton().click(); - exist(formComponent.getRoot()); + exist(form.getRoot()); }); it('should navigate to aggregation mapping on cancel', () => { - formComponent.getCancelButton().click(); + form.getCancelButton().click(); - exist(component.getWeitereFelderAuswertenButton()); + exist(page.getWeitereFelderAuswertenButton()); }); it('should add data field in form', () => { - component.getWeitereFelderAuswertenButton().click(); - formComponent.getAddFieldButton().click(); + page.getWeitereFelderAuswertenButton().click(); + form.getAddFieldButton().click(); - exist(formComponent.getDataFieldInput(1)); + exist(form.getDataFieldInput(1)); }); it('should fill out form with two data fields', () => { - helper.enterForm(aggregationMapping); + helper.fillFormular(aggregationMapping); - helper.verifyForm(aggregationMapping); + verifier.verifyForm(aggregationMapping); }); it('should delete data fields', () => { - formComponent.getDataFieldDeleteButton(0).click(); + form.getDataFieldDeleteButton(0).click(); - notExist(formComponent.getDataFieldInput(1)); + notExist(form.getDataFieldInput(1)); }); it('should show aggregation mapping in list after save', () => { - formComponent.getSaveButton().click(); + form.getSaveButton().click(); - helper.verifyAggregationMappingInList(aggregationMapping); + verifier.verifyAggregationMappingInList(aggregationMapping); }); }); diff --git a/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.executor.ts b/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.executor.ts new file mode 100644 index 0000000000000000000000000000000000000000..7e9b392696e1839765a8d8c6668722db0bffd262 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.executor.ts @@ -0,0 +1,22 @@ +import { AggregationMapping, FieldMapping } from '@admin-client/reporting-shared'; +import { AggregationMappingFormE2EComponent } from '../../components/aggregation-mapping/aggregation-mapping-form.e2e.component'; +import { enterWith } from '../../support/cypress.util'; + +export class E2EAggregationMappingExecutor { + private formComponent: AggregationMappingFormE2EComponent = new AggregationMappingFormE2EComponent(); + + public fillFormular(aggregationMapping: AggregationMapping): void { + enterWith(this.formComponent.getNameInput(), aggregationMapping.name); + enterWith(this.formComponent.getFormEngineInput(), aggregationMapping.formIdentifier.formEngineName); + enterWith(this.formComponent.getFormIdInput(), aggregationMapping.formIdentifier.formId); + + aggregationMapping.mappings.forEach((fieldMapping, index) => { + this.enterFieldMapping(fieldMapping, index); + }); + } + + private enterFieldMapping(fieldMapping: FieldMapping, index: number): void { + enterWith(this.formComponent.getSourceMappingFieldInput(index), fieldMapping.sourcePath); + enterWith(this.formComponent.getTargetMappingFieldInput(index), fieldMapping.targetPath); + } +} diff --git a/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.helper.ts b/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.helper.ts index b36249dc2f9ef1a5e4ecf0d36a2bc17f7f61f7f5..b39a391240e6a139c1f9df4e673e4e3ccda6e3e8 100644 --- a/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.helper.ts +++ b/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.helper.ts @@ -1,65 +1,16 @@ -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'; +import { AggregationMapping } from '@admin-client/reporting-shared'; +import { E2EAggregationMappingExecutor } from './aggregation-mapping.executor'; +import { E2EAggregationMapperNavigator } from './aggregation-mapping.navigator'; export class E2EAggregationMappingHelper { - private component: AggregationMappingE2EComponent = new AggregationMappingE2EComponent(); - private formComponent: AggregationMappingFormE2EComponent = new AggregationMappingFormE2EComponent(); + private readonly navigator: E2EAggregationMapperNavigator = new E2EAggregationMapperNavigator(); + private readonly executor: E2EAggregationMappingExecutor = new E2EAggregationMappingExecutor(); - public enterName(text: string): void { - enterWith(this.formComponent.getNameInput(), text); + public openStatistik(): void { + this.navigator.openStatistik(); } - 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); + public fillFormular(aggregationMapping: AggregationMapping): void { + this.executor.fillFormular(aggregationMapping); } } diff --git a/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.navigator.ts b/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.navigator.ts new file mode 100644 index 0000000000000000000000000000000000000000..f82cc547926244caca1d78afeb30be3a843b665e --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.navigator.ts @@ -0,0 +1,18 @@ +import { AggregationMappingE2EComponent } from '../../components/aggregation-mapping/aggregation-mapping.e2e.component'; +import { MainPage } from '../../page-objects/main.po'; +import { exist } from '../../support/cypress.util'; +import { E2EAppHelper } from '../app.helper'; + +export class E2EAggregationMapperNavigator { + private readonly appHelper: E2EAppHelper = new E2EAppHelper(); + + private readonly mainPage: MainPage = new MainPage(); + + private readonly aggregationMappingPage: AggregationMappingE2EComponent = new AggregationMappingE2EComponent(); + + public openStatistik(): void { + this.appHelper.navigateToDomain(); + this.mainPage.getStatistikNavigationItem().click(); + exist(this.aggregationMappingPage.getHeaderText()); + } +} diff --git a/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.verifier.ts b/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.verifier.ts new file mode 100644 index 0000000000000000000000000000000000000000..df93defea446b90102747c7af9ddd41edb254e59 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/helper/aggregation-mapping/aggregation-mapping.verifier.ts @@ -0,0 +1,34 @@ +import { AggregationMapping, FieldMapping } from '@admin-client/reporting-shared'; +import { AggregationMappingFormE2EComponent } from '../../components/aggregation-mapping/aggregation-mapping-form.e2e.component'; +import { + AggregationMappingE2EComponent, + AggregationMappingListItemE2EComponent, +} from '../../components/aggregation-mapping/aggregation-mapping.e2e.component'; +import { haveText, haveValue } from '../../support/cypress.util'; + +export class E2EAggregationMappingVerifier { + private component: AggregationMappingE2EComponent = new AggregationMappingE2EComponent(); + private formComponent: AggregationMappingFormE2EComponent = new AggregationMappingFormE2EComponent(); + + 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 { + const listItem: AggregationMappingListItemE2EComponent = this.component.getListItem(aggregationMapping.name); + haveText(listItem.getName(), aggregationMapping.name); + haveText(listItem.getFormEngineName(), aggregationMapping.formIdentifier.formEngineName); + haveText(listItem.getFormId(), aggregationMapping.formIdentifier.formId); + } +} diff --git a/alfa-client/apps/admin-e2e/src/helper/app.helper.ts b/alfa-client/apps/admin-e2e/src/helper/app.helper.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee3170e548ffc5b7cad695a0f28d0b1e7e993a11 --- /dev/null +++ b/alfa-client/apps/admin-e2e/src/helper/app.helper.ts @@ -0,0 +1,9 @@ +import { MainPage } from '../page-objects/main.po'; + +export class E2EAppHelper { + private readonly mainPage: MainPage = new MainPage(); + + public navigateToDomain(): void { + this.mainPage.getHeader().getLogo().click(); + } +} diff --git a/alfa-client/apps/admin-e2e/src/page-objects/main.po.ts b/alfa-client/apps/admin-e2e/src/page-objects/main.po.ts index 75ecbdaefa5d692ca637af325afb58ec05f80abe..c982465ac95dbb58ecfc31e412b40c55b2c441fa 100644 --- a/alfa-client/apps/admin-e2e/src/page-objects/main.po.ts +++ b/alfa-client/apps/admin-e2e/src/page-objects/main.po.ts @@ -31,7 +31,7 @@ export class MainPage { private readonly benutzerNavigationItem: string = 'link-path-benutzer'; private readonly organisationEinheitNavigationItem: string = 'link-path-organisationseinheiten'; private readonly postfachNavigationItem: string = 'link-path-postfach'; - private readonly statistikNavigationItem: string = 'link-path-statistik'; + private readonly statistikNavigationItem: string = 'link-path-aggregation-mapping'; public getBuildInfo(): BuildInfoE2EComponent { return this.buildInfo; diff --git a/alfa-client/apps/admin-e2e/src/support/cypress-helper.ts b/alfa-client/apps/admin-e2e/src/support/cypress-helper.ts index 83e7bb11f0e77a4773924fb84431047ddd271a17..5d457ea558240cbd2d5e415ffc8136f8be4452ad 100644 --- a/alfa-client/apps/admin-e2e/src/support/cypress-helper.ts +++ b/alfa-client/apps/admin-e2e/src/support/cypress-helper.ts @@ -21,6 +21,7 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +import { HttpMethod } from '@alfa-client/tech-shared'; import { Interception, RouteHandler, RouteMatcher } from 'cypress/types/net-stubbing'; import { OrganisationsEinheitE2E } from './organisationseinheit'; @@ -31,7 +32,7 @@ enum CypressTasks { enum MongoCollections { ORGANISATIONS_EINHEIT = 'organisationsEinheit', - SETTINGS = 'settings', + AGGREGATION_MAPPING = 'aggregationMapping', } const DOWNLOAD_FOLDER: string = 'cypress/downloads'; @@ -48,7 +49,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: HttpMethod, url: RouteMatcher, response: RouteHandler): Cypress.Chainable<null> { return cy.intercept(method, url, response); } @@ -110,6 +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]); + cy.task(CypressTasks.DROP_COLLECTIONS, [MongoCollections.ORGANISATIONS_EINHEIT, MongoCollections.AGGREGATION_MAPPING]); }