diff --git a/frontend/cypress/e2e/objective-backlog.cy.ts b/frontend/cypress/e2e/objective-backlog.cy.ts index bf3246f7b8..4f3416e303 100644 --- a/frontend/cypress/e2e/objective-backlog.cy.ts +++ b/frontend/cypress/e2e/objective-backlog.cy.ts @@ -30,10 +30,7 @@ describe('OKR Objective Backlog e2e tests', () => { op.getObjectiveByNameAndState('Move to another quarter on edit', 'draft').findByTestId('three-dot-menu').click(); op.selectFromThreeDotMenu('Objective bearbeiten'); - CyObjectiveFormPage.with() - .fillObjectiveTitle('This goes now to backlog') - .selectQuarter('Backlog') - .submitObjective(); + CyObjectiveFormPage.with().fillObjectiveTitle('This goes now to backlog').selectQuarter('Backlog').submit(); cy.contains('This goes now to backlog').should('not.exist'); @@ -42,7 +39,7 @@ describe('OKR Objective Backlog e2e tests', () => { }); it(`Edit ongoing Objective can not choose backlog in quarter select`, () => { - op.addObjective().fillObjectiveTitle('We can not move this to backlog').submitObjective(); + op.addObjective().fillObjectiveTitle('We can not move this to backlog').submit(); op.getObjectiveByNameAndState('We can not move this to backlog', 'ongoing').findByTestId('three-dot-menu').click(); op.selectFromThreeDotMenu('Objective bearbeiten'); @@ -81,7 +78,7 @@ describe('OKR Objective Backlog e2e tests', () => { op.getObjectiveByNameAndState('This is possible for edit', 'draft').findByTestId('three-dot-menu').click(); op.selectFromThreeDotMenu('Objective bearbeiten'); - CyObjectiveFormPage.with().fillObjectiveTitle('My new title').submitObjective(); + CyObjectiveFormPage.with().fillObjectiveTitle('My new title').submit(); op.getObjectiveByNameAndState('My new title', 'draft'); }); @@ -93,7 +90,7 @@ describe('OKR Objective Backlog e2e tests', () => { op.getObjectiveByNameAndState('This goes to other quarter later', 'draft').findByTestId('three-dot-menu').click(); op.selectFromThreeDotMenu('Objective bearbeiten'); - CyObjectiveFormPage.with().selectQuarter('GJ ForTests').submitObjective(); + CyObjectiveFormPage.with().selectQuarter('GJ ForTests').submit(); op.visitGJForTests(); op.getObjectiveByNameAndState('This goes to other quarter later', 'draft'); @@ -106,7 +103,7 @@ describe('OKR Objective Backlog e2e tests', () => { op.getObjectiveByNameAndState('Ready for duplicate in backlog', 'draft').findByTestId('three-dot-menu').click(); op.selectFromThreeDotMenu('Objective duplizieren'); - CyObjectiveFormPage.with().fillObjectiveTitle('This is a new duplication in backlog').submitObjective(); + CyObjectiveFormPage.with().fillObjectiveTitle('This is a new duplication in backlog').submit(); op.getObjectiveByNameAndState('Ready for duplicate in backlog', 'draft'); op.getObjectiveByNameAndState('This is a new duplication in backlog', 'draft'); @@ -120,10 +117,7 @@ describe('OKR Objective Backlog e2e tests', () => { .click(); op.selectFromThreeDotMenu('Objective duplizieren'); - CyObjectiveFormPage.with() - .fillObjectiveTitle('New duplication from backlog') - .selectQuarter('GJ ForTests') - .submitObjective(); + CyObjectiveFormPage.with().fillObjectiveTitle('New duplication from backlog').selectQuarter('GJ ForTests').submit(); op.getObjectiveByNameAndState('Ready for duplicate to another quarter', 'draft').should('exist'); // op.getObjectivesByNameAndState('New duplication from backlog', 'draft').should("have.length", 0) @@ -132,14 +126,14 @@ describe('OKR Objective Backlog e2e tests', () => { }); it(`Can duplicate ongoing Objective to backlog`, () => { - op.addObjective().fillObjectiveTitle('Possible to duplicate into backlog').submitObjective(); + op.addObjective().fillObjectiveTitle('Possible to duplicate into backlog').submit(); op.getObjectiveByNameAndState('Possible to duplicate into backlog', 'ongoing') .findByTestId('three-dot-menu') .click(); op.selectFromThreeDotMenu('Objective duplizieren'); - CyObjectiveFormPage.with().selectQuarter('Backlog').submitObjective(); + CyObjectiveFormPage.with().selectQuarter('Backlog').submit(); op.visitBacklogQuarter(); cy.contains('Possible to duplicate into backlog'); diff --git a/frontend/cypress/e2e/objective.cy.ts b/frontend/cypress/e2e/objective.cy.ts index c59c178a6a..7484008c6b 100644 --- a/frontend/cypress/e2e/objective.cy.ts +++ b/frontend/cypress/e2e/objective.cy.ts @@ -31,7 +31,7 @@ describe('OKR Objective e2e tests', () => { const ofp: CyObjectiveFormPage = op.addObjective(); ofp.fillObjectiveTitle('We want to complete this successful'); - ofp.submitObjective(); + ofp.submit(); op.getObjectiveByNameAndState('We want to complete this successful', 'ongoing') .findByTestId('three-dot-menu') @@ -55,7 +55,7 @@ describe('OKR Objective e2e tests', () => { const ofp: CyObjectiveFormPage = op.addObjective(); ofp.fillObjectiveTitle('A not successful objective'); - ofp.submitObjective(); + ofp.submit(); op.getObjectiveByNameAndState('A not successful objective', 'ongoing').findByTestId('three-dot-menu').click(); op.selectFromThreeDotMenu('Objective abschliessen'); @@ -77,7 +77,7 @@ describe('OKR Objective e2e tests', () => { const ofp: CyObjectiveFormPage = op.addObjective(); ofp.fillObjectiveTitle('This objective will be reopened after'); - ofp.submitObjective(); + ofp.submit(); op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing') .findByTestId('three-dot-menu') @@ -108,7 +108,7 @@ describe('OKR Objective e2e tests', () => { const ofp: CyObjectiveFormPage = op.addObjective(); ofp.fillObjectiveTitle('This objective will be returned to draft state'); - ofp.submitObjective(); + ofp.submit(); op.getObjectiveByNameAndState('This objective will be returned to draft state', 'ongoing') .findByTestId('three-dot-menu') @@ -126,11 +126,11 @@ describe('OKR Objective e2e tests', () => { let ofp: CyObjectiveFormPage = op.addObjective(); ofp.fillObjectiveTitle('Search after this objective'); - ofp.submitObjective(); + ofp.submit(); ofp = op.addObjective(); ofp.fillObjectiveTitle('We dont want to search for this'); - ofp.submitObjective(); + ofp.submit(); cy.contains('Search after this objective'); cy.contains('We dont want to search for this'); @@ -164,7 +164,7 @@ describe('OKR Objective e2e tests', () => { const ofp: CyObjectiveFormPage = op.addObjective(); ofp.fillObjectiveTitle('Objective in quarter 3'); ofp.selectQuarter('3'); - ofp.submitObjective(); + ofp.submit(); cy.contains('Objective in quarter 3').should('not.exist'); @@ -176,7 +176,7 @@ describe('OKR Objective e2e tests', () => { it(`Edit Objective and move to other quarter`, () => { const ofp: CyObjectiveFormPage = op.addObjective(); ofp.fillObjectiveTitle('Move to another quarter on edit'); - ofp.submitObjective(); + ofp.submit(); op.getObjectiveByNameAndState('Move to another quarter on edit', 'ongoing') .findByTestId('three-dot-menu') @@ -185,7 +185,7 @@ describe('OKR Objective e2e tests', () => { op.selectFromThreeDotMenu('Objective bearbeiten'); ofp.selectQuarter('3'); - ofp.submitObjective(); + ofp.submit(); cy.contains('Move to another quarter on edit').should('not.exist'); diff --git a/frontend/cypress/support/baseFormPage.ts b/frontend/cypress/support/baseFormPage.ts new file mode 100644 index 0000000000..c4013c5eea --- /dev/null +++ b/frontend/cypress/support/baseFormPage.ts @@ -0,0 +1,24 @@ +export default abstract class BaseFormPage { + constructor() { + this.init(); + } + + abstract init(): void; + + submit() { + cy.getByTestId('safe').click(); + } + + cancel() { + cy.getByTestId('cancel').click(); + } + + protected fillInput(testId: string, value: string) { + cy.getByTestId(testId).clear(); + cy.getByTestId(testId).type(value); + } + + static createInstance(): T { + throw new Error('Method not implemented.'); // Placeholder for enforcing implementation + } +} diff --git a/frontend/cypress/support/objectiveFormPage.ts b/frontend/cypress/support/objectiveFormPage.ts index ac2fc3e668..153c09118e 100644 --- a/frontend/cypress/support/objectiveFormPage.ts +++ b/frontend/cypress/support/objectiveFormPage.ts @@ -1,10 +1,6 @@ -import { quarter } from '../../src/app/shared/testData'; - -export default class CyObjectiveFormPage { - constructor() { - this.init(); - } +import BaseFormPage from './baseFormPage'; +export default class CyObjectiveFormPage extends BaseFormPage { init() { cy.get('app-objective-form').should('exist'); } @@ -33,23 +29,10 @@ export default class CyObjectiveFormPage { return this; } - submitObjective() { - cy.getByTestId('safe').click(); - } - submitDraftObjective() { cy.getByTestId('safe-draft').click(); } - cancelObjective() { - cy.getByTestId('cancel').click(); - } - - private fillInput(testId: string, value: string) { - cy.getByTestId(testId).clear(); - cy.getByTestId(testId).type(value); - } - static with() { return new CyObjectiveFormPage(); }