From 2dde360cb9cfc034533fd22599a3fa6400b66936 Mon Sep 17 00:00:00 2001 From: Lias Kleisa Date: Mon, 27 May 2024 16:57:54 +0200 Subject: [PATCH] Adjust e2e tests --- .../cypress/e2e/objective-alignment.cy.ts | 82 +++++++++---------- .../objective-form.component.html | 1 + 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/frontend/cypress/e2e/objective-alignment.cy.ts b/frontend/cypress/e2e/objective-alignment.cy.ts index 1d6cb6f990..c415b6371f 100644 --- a/frontend/cypress/e2e/objective-alignment.cy.ts +++ b/frontend/cypress/e2e/objective-alignment.cy.ts @@ -10,13 +10,9 @@ describe('OKR Objective Alignment e2e tests', () => { cy.getByTestId('add-objective').first().click(); cy.getByTestId('title').first().clear().type('Objective with new alignment'); - cy.get('select#alignment option:selected').should('contain.text', 'Bitte wählen'); - cy.get('select#alignment') - .contains('K - Steigern der URS um 25%') - .then(($option) => { - const optionValue = $option.attr('value'); - cy.get('select#alignment').select(optionValue!); - }); + cy.tabForwardUntil('[data-testId="alignmentInput"]'); + cy.realPress('ArrowDown'); + cy.realPress('Enter'); cy.getByTestId('safe').click(); @@ -31,20 +27,18 @@ describe('OKR Objective Alignment e2e tests', () => { .contains('Objective bearbeiten') .click(); - cy.get('select#alignment option:selected').should('contain.text', 'K - Steigern der URS um 25%'); + cy.getByTestId('alignmentInput') + .first() + .should('have.value', 'O - Als BBT wollen wir den Arbeitsalltag der Members von Puzzle ITC erleichtern.'); }); it(`Update alignment of Objective`, () => { cy.getByTestId('add-objective').first().click(); cy.getByTestId('title').first().clear().type('We change alignment of this Objective'); - cy.get('select#alignment option:selected').should('contain.text', 'Bitte wählen'); - cy.get('select#alignment') - .contains('K - Steigern der URS um 25%') - .then(($option) => { - const optionValue = $option.attr('value'); - cy.get('select#alignment').select(optionValue!); - }); + cy.tabForwardUntil('[data-testId="alignmentInput"]'); + cy.realPress('ArrowDown'); + cy.realPress('Enter'); cy.getByTestId('safe').click(); cy.contains('We change alignment of this Objective'); @@ -58,12 +52,11 @@ describe('OKR Objective Alignment e2e tests', () => { .contains('Objective bearbeiten') .click(); - cy.get('select#alignment') - .contains('K - Antwortzeit für Supportanfragen um 33% verkürzen.') - .then(($option) => { - const optionValue = $option.attr('value'); - cy.get('select#alignment').select(optionValue!); - }); + cy.tabForwardUntil('[data-testId="alignmentInput"]'); + cy.realPress('Delete'); + cy.realPress('ArrowDown'); + cy.realPress('ArrowDown'); + cy.realPress('Enter'); cy.getByTestId('safe').click(); cy.getByTestId('objective') @@ -76,23 +69,18 @@ describe('OKR Objective Alignment e2e tests', () => { .contains('Objective bearbeiten') .click(); - cy.get('select#alignment option:selected').should( - 'contain.text', - 'K - Antwortzeit für Supportanfragen um 33% verkürzen.', - ); + cy.getByTestId('alignmentInput') + .first() + .should('have.value', 'KR - Das BBT hilft den Membern 20% mehr beim Töggelen'); }); it(`Delete alignment of Objective`, () => { cy.getByTestId('add-objective').first().click(); cy.getByTestId('title').first().clear().type('We delete the alignment'); - cy.get('select#alignment option:selected').should('contain.text', 'Bitte wählen'); - cy.get('select#alignment') - .contains('K - Steigern der URS um 25%') - .then(($option) => { - const optionValue = $option.attr('value'); - cy.get('select#alignment').select(optionValue!); - }); + cy.tabForwardUntil('[data-testId="alignmentInput"]'); + cy.realPress('ArrowDown'); + cy.realPress('Enter'); cy.getByTestId('safe').click(); cy.contains('We delete the alignment'); @@ -106,7 +94,9 @@ describe('OKR Objective Alignment e2e tests', () => { .contains('Objective bearbeiten') .click(); - cy.get('select#alignment').select('Kein Alignment'); + cy.tabForwardUntil('[data-testId="alignmentInput"]'); + cy.realPress('Delete'); + cy.tabForward(); cy.getByTestId('safe').click(); cy.getByTestId('objective') @@ -119,28 +109,36 @@ describe('OKR Objective Alignment e2e tests', () => { .contains('Objective bearbeiten') .click(); - cy.get('select#alignment option:selected').should('contain.text', 'Bitte wählen'); + cy.getByTestId('alignmentInput').first().should('have.value', 'Bezug wählen'); }); - it(`Alignment Possibilites change when quarter change`, () => { + it(`Alignment Possibilities change when quarter change`, () => { cy.visit('/?quarter=1'); + cy.get('mat-chip:visible:contains("Alle")').click(); + cy.get('mat-chip:visible:contains("Alle")').click(); + cy.get('mat-chip:visible:contains("/BBT")').click(); + cy.getByTestId('add-objective').first().click(); cy.getByTestId('title').first().clear().type('We can link later on this'); cy.getByTestId('safe').click(); + cy.get('mat-chip:visible:contains("Alle")').click(); + cy.getByTestId('add-objective').first().click(); cy.getByTestId('title').first().clear().type('There is my other alignment'); - cy.get('select#alignment option:selected').should('contain.text', 'Bitte wählen'); - - cy.get('select#alignment').select(1); + cy.tabForwardUntil('[data-testId="alignmentInput"]'); + cy.realPress('ArrowDown'); + cy.realPress('Enter'); cy.get('select#alignment option:selected').then(($select) => { const selectValue = $select.text(); - cy.getByTestId('quarterSelect').select('GJ 23/24-Q1'); + cy.getByTestId('quarterSelect').select('GJ 22/23-Q3'); cy.getByTestId('title').first().clear().type('There is our other alignment'); - cy.get('select#alignment').select(1); + cy.tabForwardUntil('[data-testId="alignmentInput"]'); + cy.realPress('ArrowDown'); + cy.realPress('Enter'); cy.get('select#alignment option:selected').should('not.contain.text', selectValue); cy.getByTestId('cancel').click(); @@ -152,7 +150,9 @@ describe('OKR Objective Alignment e2e tests', () => { cy.get('select#quarter').select('GJ 22/23-Q4'); cy.getByTestId('title').first().clear().type('A new title'); - cy.get('select#alignment').select(1); + cy.tabForwardUntil('[data-testId="alignmentInput"]'); + cy.realPress('ArrowDown'); + cy.realPress('Enter'); cy.get('select#alignment option:selected').should('contain.text', selectValue); }); diff --git a/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.html b/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.html index e650325af8..a9a41bbc52 100644 --- a/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.html +++ b/frontend/src/app/shared/dialog/objective-dialog/objective-form.component.html @@ -78,6 +78,7 @@ (this.filteredOptions$ | async)?.length == 0 ? 'Kein Alignment vorhanden' : 'Bezug wählen' }}" [matAutocomplete]="auto" + [attr.data-testId]="'alignmentInput'" (input)="filter()" (focus)="filter(); input.select()" (focusout)="scrollLeft()"