From f2361523416d1b2db3e7c12ee3870bfbea11045d Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Fri, 8 Nov 2024 13:13:07 +0100 Subject: [PATCH] use improved syntax for gen new object --- frontend/cypress/e2e/objective.cy.ts | 35 ++++++++++-------------- frontend/cypress/support/OverviewPage.ts | 4 ++- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/frontend/cypress/e2e/objective.cy.ts b/frontend/cypress/e2e/objective.cy.ts index c25f065cbb..230c3269b5 100644 --- a/frontend/cypress/e2e/objective.cy.ts +++ b/frontend/cypress/e2e/objective.cy.ts @@ -14,8 +14,7 @@ describe('OKR Objective e2e tests', () => { }); it(`Release Objective from Draft to Ongoing`, () => { - op.addObjective(); - const ofp = new CyObjectiveFormPage(); + const ofp: CyObjectiveFormPage = op.addObjective(); ofp.fillObjectiveTitle('A objective in state draft'); ofp.submitDraftObjective(); @@ -30,8 +29,8 @@ describe('OKR Objective e2e tests', () => { }); it(`Complete Objective with Successful`, () => { - op.addObjective(); - const ofp = new CyObjectiveFormPage(); + const ofp: CyObjectiveFormPage = op.addObjective(); + ofp.fillObjectiveTitle('We want to complete this successful'); ofp.submitObjective(); @@ -54,9 +53,8 @@ describe('OKR Objective e2e tests', () => { }); it(`Complete Objective with Not-Successful`, () => { - op.addObjective(); + const ofp: CyObjectiveFormPage = op.addObjective(); - const ofp = new CyObjectiveFormPage(); ofp.fillObjectiveTitle('A not successful objective'); ofp.submitObjective(); @@ -77,8 +75,8 @@ describe('OKR Objective e2e tests', () => { }); it(`Reopen Successful Objective`, () => { - op.addObjective(); - const ofp = new CyObjectiveFormPage(); + const ofp: CyObjectiveFormPage = op.addObjective(); + ofp.fillObjectiveTitle('This objective will be reopened after'); ofp.submitObjective(); @@ -104,8 +102,8 @@ describe('OKR Objective e2e tests', () => { it('Ongoing objective back to draft state', () => { onlyOn('chrome'); - op.addObjective(); - const ofp = new CyObjectiveFormPage(); + const ofp: CyObjectiveFormPage = op.addObjective(); + ofp.fillObjectiveTitle('This objective will be returned to draft state'); ofp.submitObjective(); @@ -122,15 +120,14 @@ describe('OKR Objective e2e tests', () => { }); it(`Search for Objective`, () => { - op.addObjective(); - const ofp = new CyObjectiveFormPage(); + let ofp: CyObjectiveFormPage = op.addObjective(); + ofp.fillObjectiveTitle('Search after this objective'); ofp.submitObjective(); - op.addObjective(); - const ofp2 = new CyObjectiveFormPage(); - ofp2.fillObjectiveTitle('We dont want to search for this'); - ofp2.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'); @@ -161,8 +158,7 @@ describe('OKR Objective e2e tests', () => { }); it(`Create Objective in other quarter`, () => { - op.addObjective(); - const ofp = new CyObjectiveFormPage(); + const ofp: CyObjectiveFormPage = op.addObjective(); ofp.fillObjectiveTitle('Objective in quarter 3'); ofp.selectQuarter('3'); ofp.submitObjective(); @@ -175,8 +171,7 @@ describe('OKR Objective e2e tests', () => { }); it(`Edit Objective and move to other quarter`, () => { - op.addObjective(); - const ofp = new CyObjectiveFormPage(); + const ofp: CyObjectiveFormPage = op.addObjective(); ofp.fillObjectiveTitle('Move to another quarter on edit'); ofp.submitObjective(); diff --git a/frontend/cypress/support/OverviewPage.ts b/frontend/cypress/support/OverviewPage.ts index b3b8d6a690..cec135e16e 100644 --- a/frontend/cypress/support/OverviewPage.ts +++ b/frontend/cypress/support/OverviewPage.ts @@ -1,4 +1,5 @@ import { getObjectivesByNameAndState } from './objective-helper'; +import CyObjectiveFormPage from './objectiveFormPage'; export default class CyOverviewPage { visit() { @@ -20,9 +21,10 @@ export default class CyOverviewPage { addObjective(teamName?: string) { if (teamName) { this.getTeamByName(teamName).find('.add-objective').first().click(); - return; + return new CyObjectiveFormPage(); } cy.getByTestId('add-objective').first().click(); + return new CyObjectiveFormPage(); } getTeamByName(teamName: string) {