diff --git a/alfa-client/apps/alfa-e2e/src/components/attachment/attachment.e2e.component.ts b/alfa-client/apps/alfa-e2e/src/components/attachment/attachment.e2e.component.ts index 3277623c9aec9bf551906c97e921c752cf292862..72c76d17bbc6f654870ce3ac7e4714bb74beb1a9 100644 --- a/alfa-client/apps/alfa-e2e/src/components/attachment/attachment.e2e.component.ts +++ b/alfa-client/apps/alfa-e2e/src/components/attachment/attachment.e2e.component.ts @@ -49,7 +49,7 @@ export class AttachmentListE2EComponent { } public getDownloadAttachmentsButton(parent: any): Cypress.Chainable<JQuery<HTMLElement>> { - return cy.get(parent).getTestElementWithClass(this.downloadAttachmentsButton); + return cy.get(parent).findTestElementWithClass(this.downloadAttachmentsButton); } public downloadAttachments(parent: any): Cypress.Chainable<any> { diff --git a/alfa-client/apps/alfa-e2e/src/components/vorgang/vorgang-views.e2e.component.ts b/alfa-client/apps/alfa-e2e/src/components/vorgang/vorgang-views.e2e.component.ts index f1240912ebb55269bfea578cd2a72a23187a61a6..5563aebb65360b245fd8641624a2bca487e1465a 100644 --- a/alfa-client/apps/alfa-e2e/src/components/vorgang/vorgang-views.e2e.component.ts +++ b/alfa-client/apps/alfa-e2e/src/components/vorgang/vorgang-views.e2e.component.ts @@ -71,6 +71,8 @@ export class VorgangViewE2EComponent { private readonly count: string = 'views-menu-item-count-'; private readonly root: string = 'views-menu-item-'; private readonly button: string = 'routing-button'; + private readonly iconTag: string = 'ozgcloud-icon'; + private readonly svgIconTag: string = 'ozgcloud-svgicon'; private rootId: string; @@ -87,6 +89,14 @@ export class VorgangViewE2EComponent { } public getButton() { - return this.getRoot().getTestElementWithClass(this.button); + return this.getRoot().findTestElementWithClass(this.button); + } + + public getIcon() { + return this.getRoot().findElement(this.iconTag); + } + + public getSvgIcon() { + return this.getRoot().findElement(this.svgIconTag); } } diff --git a/alfa-client/apps/alfa-e2e/src/components/vorgang/vorgang.formular-daten.historie.e2e.component.ts b/alfa-client/apps/alfa-e2e/src/components/vorgang/vorgang.formular-daten.historie.e2e.component.ts index 2b0fe296fec1a11d59f843624c441ae14788dea9..d4b039afbb15779a709339c390a2a4f6d8c70e73 100644 --- a/alfa-client/apps/alfa-e2e/src/components/vorgang/vorgang.formular-daten.historie.e2e.component.ts +++ b/alfa-client/apps/alfa-e2e/src/components/vorgang/vorgang.formular-daten.historie.e2e.component.ts @@ -205,14 +205,14 @@ export class BescheidHistorieItemE2EComponent { } public getStatus() { - return cy.getTestElementWithClass(this.status); + return this.getRoot().findTestElementWithClass(this.status); } public getBescheidDokumentText() { - return cy.getTestElementWithClass(this.bescheidDokument); + return this.getRoot().findTestElementWithClass(this.bescheidDokument); } public getBescheidAnhaengeText() { - return cy.getTestElementWithClass(this.bescheidAnhaenge); + return this.getRoot().findTestElementWithClass(this.bescheidAnhaenge); } } diff --git a/alfa-client/apps/alfa-e2e/src/e2e/main-tests/wiedervorlage/wiedervorlage.erledigen.cy.ts b/alfa-client/apps/alfa-e2e/src/e2e/main-tests/wiedervorlage/wiedervorlage.erledigen.cy.ts index aa4fff7aa195f8cc186e71b62bd1e50da1331443..9912791a62cbd0616f5516d369d6a2fc2eb1f8d7 100644 --- a/alfa-client/apps/alfa-e2e/src/e2e/main-tests/wiedervorlage/wiedervorlage.erledigen.cy.ts +++ b/alfa-client/apps/alfa-e2e/src/e2e/main-tests/wiedervorlage/wiedervorlage.erledigen.cy.ts @@ -49,6 +49,7 @@ import { exist, notContainClass, notExist, + shouldHaveAttribute, } from '../../../support/cypress.util'; import { loginAsSabine } from '../../../support/user-util'; import { createVorgang, initVorgang, objectIds } from '../../../support/vorgang-util'; @@ -320,11 +321,9 @@ describe('Wiedervorlage erledigen/wiedereroeffnen', () => { }); it('should show red icon', () => { - wiedervorlagenView - .getRoot() - .get('ozgcloud-svgicon') - .should('have.attr', 'data-test-class', locatorIconIsOverdue); - // exist(wiedervorlagenView.getRoot().getTestElementWithClass(locatorIconIsOverdue)); + const svgIcon = wiedervorlagenView.getSvgIcon(); + + shouldHaveAttribute(svgIcon, 'data-test-class', locatorIconIsOverdue); }); it('Open Vorgang-Detail-Page', () => { @@ -333,7 +332,9 @@ describe('Wiedervorlage erledigen/wiedereroeffnen', () => { }); it('should mark as erledigt', () => { - wiedervorlage.getLink().click(); + wait(500, 'Flaky - page content changed while waiting'); + const link = wiedervorlage.getLink(); + link.click(); waitForSpinnerToDisappear(); subnavigation.erledigen(); waitForSpinnerToDisappear(); @@ -347,8 +348,9 @@ describe('Wiedervorlage erledigen/wiedereroeffnen', () => { }); it('should show default icon', () => { - // wiedervorlagenView.getRoot().get('ozgcloud-icon').should('have.attr', 'data-test-class'); - exist(wiedervorlagenView.getRoot().getTestElementWithClass(locatorIconDefault)); + const icon = wiedervorlagenView.getIcon(); + + shouldHaveAttribute(icon, 'data-test-class', locatorIconDefault); }); }); }); diff --git a/alfa-client/apps/alfa-e2e/src/support/commands.ts b/alfa-client/apps/alfa-e2e/src/support/commands.ts index 1d1403d708893387744dec0e12e7783f116802a6..84507bff8920feece8d4c8a470a362a03cf38668 100644 --- a/alfa-client/apps/alfa-e2e/src/support/commands.ts +++ b/alfa-client/apps/alfa-e2e/src/support/commands.ts @@ -91,6 +91,7 @@ Cypress.Commands.add('getTestElement', (selector, ...args) => { }); Cypress.Commands.add('getTestElementWithClass', (selector, ...args) => { + console.log('Achtung:‚ Potentiell nicht eindeutiges Ergebnis wegen cy.get()'); return cy.get(`[${DATA_TEST_CLASS}="${selector}"]`, ...args); }); @@ -106,7 +107,7 @@ Cypress.Commands.add( }, ); -Cypress.Commands.add('findElement', { prevSubject: true }, (subject: any, selector) => { +Cypress.Commands.add('findElement', { prevSubject: true }, (subject: any, selector: string) => { return subject.find(selector); }); @@ -250,8 +251,8 @@ Cypress.Commands.add('addMockToSmocker', (mock) => { url: `${getSmockerUrl()}/mocks`, body: mockFile, headers: { - "Content-Type": "application/x-yaml" - } + 'Content-Type': 'application/x-yaml', + }, }); }); }); @@ -270,4 +271,4 @@ function getSmockerUrl(): string { function getSmockerEnv(): string { return Cypress.env(CypressEnv.SMOCKER); -} \ No newline at end of file +} diff --git a/alfa-client/apps/alfa-e2e/src/support/cypress-helper.ts b/alfa-client/apps/alfa-e2e/src/support/cypress-helper.ts index 7666dbcaf8155666c509a50bc3f954b4da517961..a0e6f18ca0f0c88776781bad9a6ee25479b20f23 100644 --- a/alfa-client/apps/alfa-e2e/src/support/cypress-helper.ts +++ b/alfa-client/apps/alfa-e2e/src/support/cypress-helper.ts @@ -179,8 +179,11 @@ export function urlShouldInclude(text: string) { } //TODO: anders loesen -> bad practice -export function wait(ms: number): void { +export function wait(ms: number, reason = ''): void { cy.wait(ms); + if (reason) { + console.log(`Had to wait ${ms} because of: ${reason}`); + } } // diff --git a/alfa-client/apps/alfa-e2e/src/support/cypress.util.ts b/alfa-client/apps/alfa-e2e/src/support/cypress.util.ts index 34935393bc51d6b7acf38b8494e7c2ba70f25689..4440874cbfcc512a5b23c9394c60f50f15e07d21 100644 --- a/alfa-client/apps/alfa-e2e/src/support/cypress.util.ts +++ b/alfa-client/apps/alfa-e2e/src/support/cypress.util.ts @@ -103,6 +103,10 @@ export function shouldHaveAttributeBeLowerThan(element: any, attributeName: stri } // +export function shouldHaveAttribute(element: any, name: string, value: string) { + element.should('have.attr', name, value); +} + export function visible(element: any) { element.should('be.visible'); }