From 86b30e1229cedccba72bffca7fbce7f2b3ecf24a Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Fri, 8 Nov 2024 13:43:05 +0100 Subject: [PATCH] clean up objective tests --- frontend/cypress/e2e/objective.cy.ts | 260 +++++++++++------------ frontend/cypress/support/OverviewPage.ts | 4 +- frontend/package.json | 2 +- 3 files changed, 133 insertions(+), 133 deletions(-) diff --git a/frontend/cypress/e2e/objective.cy.ts b/frontend/cypress/e2e/objective.cy.ts index 25e1abc2f8..4387de9e68 100644 --- a/frontend/cypress/e2e/objective.cy.ts +++ b/frontend/cypress/e2e/objective.cy.ts @@ -5,190 +5,188 @@ import CyObjectiveFormPage from '../support/objectiveFormPage'; describe('OKR Objective e2e tests', () => { let op = new CyOverviewPage(); - describe('tests via click', () => { - describe('Functionality', () => { - beforeEach(() => { - op = new CyOverviewPage(); - cy.loginAsUser(users.gl); - op.visitCurrentQuarter(); - }); + beforeEach(() => { + op = new CyOverviewPage(); + cy.loginAsUser(users.gl); + op.visitCurrentQuarter(); + }); - it(`Release Objective from Draft to Ongoing`, () => { - const ofp: CyObjectiveFormPage = op.addObjective(); - ofp.fillObjectiveTitle('A objective in state draft'); - ofp.submitDraftObjective(); + describe('tests via click', () => { + it(`Release Objective from Draft to Ongoing`, () => { + const ofp: CyObjectiveFormPage = op.addObjective(); + ofp.fillObjectiveTitle('A objective in state draft'); + ofp.submitDraftObjective(); - op.getObjectiveByNameAndState('A objective in state draft', 'draft').findByTestId('three-dot-menu').click(); - op.selectFromThreeDotMenu('Objective veröffentlichen'); + op.getObjectiveByNameAndState('A objective in state draft', 'draft').findByTestId('three-dot-menu').click(); + op.selectFromThreeDotMenu('Objective veröffentlichen'); - cy.contains('Objective veröffentlichen'); - cy.contains('Soll dieses Objective veröffentlicht werden?'); - cy.getByTestId('confirm-yes').click(); + cy.contains('Objective veröffentlichen'); + cy.contains('Soll dieses Objective veröffentlicht werden?'); + cy.getByTestId('confirm-yes').click(); - op.getObjectiveByNameAndState('A objective in state draft', 'ongoing').should('exist'); - }); + op.getObjectiveByNameAndState('A objective in state draft', 'ongoing').should('exist'); + }); - it(`Complete Objective with Successful`, () => { - const ofp: CyObjectiveFormPage = op.addObjective(); + it(`Complete Objective with Successful`, () => { + const ofp: CyObjectiveFormPage = op.addObjective(); - ofp.fillObjectiveTitle('We want to complete this successful'); - ofp.submitObjective(); + ofp.fillObjectiveTitle('We want to complete this successful'); + ofp.submitObjective(); - op.getObjectiveByNameAndState('We want to complete this successful', 'ongoing') - .findByTestId('three-dot-menu') - .click(); - op.selectFromThreeDotMenu('Objective abschliessen'); + op.getObjectiveByNameAndState('We want to complete this successful', 'ongoing') + .findByTestId('three-dot-menu') + .click(); + op.selectFromThreeDotMenu('Objective abschliessen'); - cy.contains('Bewertung'); - cy.contains('Objective erreicht'); - cy.contains('Objective nicht erreicht'); - cy.contains('Kommentar (optional)'); - cy.contains('Objective abschliessen'); - cy.contains('Abbrechen'); + cy.contains('Bewertung'); + cy.contains('Objective erreicht'); + cy.contains('Objective nicht erreicht'); + cy.contains('Kommentar (optional)'); + cy.contains('Objective abschliessen'); + cy.contains('Abbrechen'); - cy.getByTestId('successful').click(); - cy.getByTestId('submit').click(); + cy.getByTestId('successful').click(); + cy.getByTestId('submit').click(); - op.getObjectiveByNameAndState('We want to complete this successful', 'successful'); - }); + op.getObjectiveByNameAndState('We want to complete this successful', 'successful'); + }); - it(`Complete Objective with Not-Successful`, () => { - const ofp: CyObjectiveFormPage = op.addObjective(); + it(`Complete Objective with Not-Successful`, () => { + const ofp: CyObjectiveFormPage = op.addObjective(); - ofp.fillObjectiveTitle('A not successful objective'); - ofp.submitObjective(); + ofp.fillObjectiveTitle('A not successful objective'); + ofp.submitObjective(); - op.getObjectiveByNameAndState('A not successful objective', 'ongoing').findByTestId('three-dot-menu').click(); - op.selectFromThreeDotMenu('Objective abschliessen'); + op.getObjectiveByNameAndState('A not successful objective', 'ongoing').findByTestId('three-dot-menu').click(); + op.selectFromThreeDotMenu('Objective abschliessen'); - cy.contains('Bewertung'); - cy.contains('Objective erreicht'); - cy.contains('Objective nicht erreicht'); - cy.contains('Kommentar (optional)'); - cy.contains('Objective abschliessen'); - cy.contains('Abbrechen'); + cy.contains('Bewertung'); + cy.contains('Objective erreicht'); + cy.contains('Objective nicht erreicht'); + cy.contains('Kommentar (optional)'); + cy.contains('Objective abschliessen'); + cy.contains('Abbrechen'); - cy.getByTestId('not-successful').click(); - cy.getByTestId('submit').click(); + cy.getByTestId('not-successful').click(); + cy.getByTestId('submit').click(); - op.getObjectiveByNameAndState('A not successful objective', 'not-successful'); - }); + op.getObjectiveByNameAndState('A not successful objective', 'not-successful'); + }); - it(`Reopen Successful Objective`, () => { - const ofp: CyObjectiveFormPage = op.addObjective(); + it(`Reopen Successful Objective`, () => { + const ofp: CyObjectiveFormPage = op.addObjective(); - ofp.fillObjectiveTitle('This objective will be reopened after'); - ofp.submitObjective(); + ofp.fillObjectiveTitle('This objective will be reopened after'); + ofp.submitObjective(); - op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing') - .findByTestId('three-dot-menu') - .click(); + op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing') + .findByTestId('three-dot-menu') + .click(); - op.selectFromThreeDotMenu('Objective abschliessen'); + op.selectFromThreeDotMenu('Objective abschliessen'); - cy.getByTestId('successful').click(); - cy.getByTestId('submit').click(); + cy.getByTestId('successful').click(); + cy.getByTestId('submit').click(); - cy.wait(500); + cy.wait(500); - op.getObjectiveByNameAndState('This objective will be reopened after', 'successful') - .findByTestId('three-dot-menu') - .click(); + op.getObjectiveByNameAndState('This objective will be reopened after', 'successful') + .findByTestId('three-dot-menu') + .click(); - op.selectFromThreeDotMenu('Objective wiedereröffnen'); + op.selectFromThreeDotMenu('Objective wiedereröffnen'); - op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing').should('exist'); - }); + op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing').should('exist'); + }); - it('Ongoing objective back to draft state', () => { - onlyOn('chrome'); - const ofp: CyObjectiveFormPage = op.addObjective(); + it('Ongoing objective back to draft state', () => { + onlyOn('chrome'); + const ofp: CyObjectiveFormPage = op.addObjective(); - ofp.fillObjectiveTitle('This objective will be returned to draft state'); - ofp.submitObjective(); + ofp.fillObjectiveTitle('This objective will be returned to draft state'); + ofp.submitObjective(); - op.getObjectiveByNameAndState('This objective will be returned to draft state', 'ongoing') - .findByTestId('three-dot-menu') - .click(); - op.selectFromThreeDotMenu('Objective als Draft speichern'); + op.getObjectiveByNameAndState('This objective will be returned to draft state', 'ongoing') + .findByTestId('three-dot-menu') + .click(); + op.selectFromThreeDotMenu('Objective als Draft speichern'); - cy.contains('Objective als Draft speichern'); - cy.contains('Soll dieses Objective als Draft gespeichert werden?'); - cy.getByTestId('confirm-yes').click(); + cy.contains('Objective als Draft speichern'); + cy.contains('Soll dieses Objective als Draft gespeichert werden?'); + cy.getByTestId('confirm-yes').click(); - op.getObjectiveByNameAndState('This objective will be returned to draft state', 'draft').should('exist'); - }); + op.getObjectiveByNameAndState('This objective will be returned to draft state', 'draft').should('exist'); + }); - it(`Search for Objective`, () => { - let ofp: CyObjectiveFormPage = op.addObjective(); + it(`Search for Objective`, () => { + let ofp: CyObjectiveFormPage = op.addObjective(); - ofp.fillObjectiveTitle('Search after this objective'); - ofp.submitObjective(); + ofp.fillObjectiveTitle('Search after this objective'); + ofp.submitObjective(); - ofp = op.addObjective(); - ofp.fillObjectiveTitle('We dont want to search for this'); - ofp.submitObjective(); + ofp = op.addObjective(); + ofp.fillObjectiveTitle('We dont want to search for this'); + ofp.submitObjective(); - cy.contains('Search after this objective'); - cy.contains('We dont want to search for this'); + cy.contains('Search after this objective'); + cy.contains('We dont want to search for this'); - cy.scrollTo(0, 0); - cy.wait(500); + cy.scrollTo(0, 0); + cy.wait(500); - cy.getByTestId('objectiveSearch').first().click(); - cy.getByTestId('objectiveSearch').first().type('Search after').wait(350); + cy.getByTestId('objectiveSearch').first().click(); + cy.getByTestId('objectiveSearch').first().type('Search after').wait(350); - cy.contains('Search after this objective'); - cy.contains('We dont want to search for this').should('not.exist'); + cy.contains('Search after this objective'); + cy.contains('We dont want to search for this').should('not.exist'); - cy.getByTestId('objectiveSearch').first().clear().type('this').wait(350); + cy.getByTestId('objectiveSearch').first().clear().type('this').wait(350); - cy.contains('Search after this objective'); - cy.contains('We dont want to search for this'); + cy.contains('Search after this objective'); + cy.contains('We dont want to search for this'); - cy.getByTestId('objectiveSearch').first().clear().type('dont want to').wait(350); + cy.getByTestId('objectiveSearch').first().clear().type('dont want to').wait(350); - cy.contains('We dont want to search for this'); - cy.contains('Search after this objective').should('not.exist'); + cy.contains('We dont want to search for this'); + cy.contains('Search after this objective').should('not.exist'); - cy.getByTestId('objectiveSearch').first().clear().type('there is no objective').wait(350); + cy.getByTestId('objectiveSearch').first().clear().type('there is no objective').wait(350); - cy.contains('We dont want to search for this').should('not.exist'); - cy.contains('Search after this objective').should('not.exist'); - }); + cy.contains('We dont want to search for this').should('not.exist'); + cy.contains('Search after this objective').should('not.exist'); + }); - it(`Create Objective in other quarter`, () => { - const ofp: CyObjectiveFormPage = op.addObjective(); - ofp.fillObjectiveTitle('Objective in quarter 3'); - ofp.selectQuarter('3'); - ofp.submitObjective(); + it(`Create Objective in other quarter`, () => { + const ofp: CyObjectiveFormPage = op.addObjective(); + ofp.fillObjectiveTitle('Objective in quarter 3'); + ofp.selectQuarter('3'); + ofp.submitObjective(); - cy.contains('Objective in quarter 3').should('not.exist'); + cy.contains('Objective in quarter 3').should('not.exist'); - op.visitNextQuarter(); + op.visitNextQuarter(); - cy.contains('Objective in quarter 3'); - }); + cy.contains('Objective in quarter 3'); + }); - it(`Edit Objective and move to other quarter`, () => { - const ofp: CyObjectiveFormPage = op.addObjective(); - ofp.fillObjectiveTitle('Move to another quarter on edit'); - ofp.submitObjective(); + it(`Edit Objective and move to other quarter`, () => { + const ofp: CyObjectiveFormPage = op.addObjective(); + ofp.fillObjectiveTitle('Move to another quarter on edit'); + ofp.submitObjective(); - op.getObjectiveByNameAndState('Move to another quarter on edit', 'ongoing') - .findByTestId('three-dot-menu') - .click(); + op.getObjectiveByNameAndState('Move to another quarter on edit', 'ongoing') + .findByTestId('three-dot-menu') + .click(); - op.selectFromThreeDotMenu('Objective bearbeiten'); + op.selectFromThreeDotMenu('Objective bearbeiten'); - ofp.selectQuarter('3'); - ofp.submitObjective(); + ofp.selectQuarter('3'); + ofp.submitObjective(); - cy.contains('Move to another quarter on edit').should('not.exist'); + cy.contains('Move to another quarter on edit').should('not.exist'); - op.visitNextQuarter(); - cy.contains('Move to another quarter on edit'); - }); + op.visitNextQuarter(); + cy.contains('Move to another quarter on edit'); }); }); diff --git a/frontend/cypress/support/OverviewPage.ts b/frontend/cypress/support/OverviewPage.ts index cec135e16e..5e6df19c09 100644 --- a/frontend/cypress/support/OverviewPage.ts +++ b/frontend/cypress/support/OverviewPage.ts @@ -37,6 +37,8 @@ export default class CyOverviewPage { selectFromThreeDotMenu(optionName: string) { cy.contains(optionName).should('exist'); - cy.get('.objective-three-dot-menu').contains(optionName).should('have.class', 'objective-menu-option').click(); + const chainable = cy.get('.objective-three-dot-menu').contains(optionName).scrollIntoView(); + chainable.should('have.class', 'objective-menu-option'); + chainable.click(); } } diff --git a/frontend/package.json b/frontend/package.json index 08e2415442..3f95d8d80b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -10,7 +10,7 @@ "watch:prod": "ng build --watch", "test": "jest --silent", "cypress:open": "cypress open", - "cypress:run": "cypress run --browser chrome --headed", + "cypress:run": "cypress run --browser chrome", "cypress:open-test": "concurrently \"npm start\" \"cypress open\"", "cypress:run-test": "npm run build && concurrently \"npm run serve:dist\" \"cypress run\"", "format": "prettier --write \"./**/*.{js,ts,json,css,scss,html,md,yaml}\"",