Skip to content

Commit

Permalink
refactor objectiveFormPage
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Nov 8, 2024
1 parent b131f9c commit 72de293
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 43 deletions.
11 changes: 6 additions & 5 deletions frontend/cypress/e2e/objective-backlog.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ describe('OKR Objective Backlog e2e tests', () => {
});

it(`Create Objective in backlog quarter should not have save button`, () => {
const ofp = op.addObjective().fillObjectiveTitle('Objective in quarter backlog').selectQuarter('Backlog');

cy.contains('Speichern').should('not.exist');
cy.contains('Als Draft speichern');
ofp.submitDraftObjective();
op.addObjective()
.fillObjectiveTitle('Objective in quarter backlog')
.selectQuarter('Backlog')
.check(cy.contains('Speichern').should('not.exist'))
.check(cy.contains('Als Draft speichern'))
.submitDraftObjective();

cy.contains('Objective in quarter backlog').should('not.exist');

Expand Down
42 changes: 10 additions & 32 deletions frontend/cypress/e2e/objective.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ describe('OKR Objective e2e tests', () => {

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.addObjective().fillObjectiveTitle('A objective in state draft').submitDraftObjective();

op.getObjectiveByNameAndState('A objective in state draft', 'draft').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective veröffentlichen');
Expand All @@ -28,14 +26,12 @@ describe('OKR Objective e2e tests', () => {
});

it(`Complete Objective with Successful`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();

ofp.fillObjectiveTitle('We want to complete this successful');
ofp.submit();
op.addObjective().fillObjectiveTitle('We want to complete this successful').submit();

op.getObjectiveByNameAndState('We want to complete this successful', 'ongoing')
.findByTestId('three-dot-menu')
.click();

op.selectFromThreeDotMenu('Objective abschliessen');

cy.contains('Bewertung');
Expand All @@ -52,10 +48,7 @@ describe('OKR Objective e2e tests', () => {
});

it(`Complete Objective with Not-Successful`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();

ofp.fillObjectiveTitle('A not successful objective');
ofp.submit();
op.addObjective().fillObjectiveTitle('A not successful objective').submit();

op.getObjectiveByNameAndState('A not successful objective', 'ongoing').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective abschliessen');
Expand All @@ -74,10 +67,7 @@ describe('OKR Objective e2e tests', () => {
});

it(`Reopen Successful Objective`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();

ofp.fillObjectiveTitle('This objective will be reopened after');
ofp.submit();
op.addObjective().fillObjectiveTitle('This objective will be reopened after').submit();

op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing')
.findByTestId('three-dot-menu')
Expand Down Expand Up @@ -105,10 +95,7 @@ describe('OKR Objective e2e tests', () => {

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.submit();
op.addObjective().fillObjectiveTitle('This objective will be returned to draft state').submit();

op.getObjectiveByNameAndState('This objective will be returned to draft state', 'ongoing')
.findByTestId('three-dot-menu')
Expand All @@ -123,14 +110,9 @@ describe('OKR Objective e2e tests', () => {
});

it(`Search for Objective`, () => {
let ofp: CyObjectiveFormPage = op.addObjective();
op.addObjective().fillObjectiveTitle('Search after this objective').submit();

ofp.fillObjectiveTitle('Search after this objective');
ofp.submit();

ofp = op.addObjective();
ofp.fillObjectiveTitle('We dont want to search for this');
ofp.submit();
op.addObjective().fillObjectiveTitle('We dont want to search for this').submit();

cy.contains('Search after this objective');
cy.contains('We dont want to search for this');
Expand Down Expand Up @@ -174,18 +156,14 @@ 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.submit();
op.addObjective().fillObjectiveTitle('Move to another quarter on edit').submit();

op.getObjectiveByNameAndState('Move to another quarter on edit', 'ongoing')
.findByTestId('three-dot-menu')
.click();

op.selectFromThreeDotMenu('Objective bearbeiten');

ofp.selectQuarter('3');
ofp.submit();
CyObjectiveFormPage.with().selectQuarter('3').submit();

cy.contains('Move to another quarter on edit').should('not.exist');

Expand Down
8 changes: 6 additions & 2 deletions frontend/cypress/support/baseFormPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export default abstract class BaseFormPage {
cy.getByTestId(testId).type(value);
}

static createInstance<T extends BaseFormPage>(): T {
throw new Error('Method not implemented.'); // Placeholder for enforcing implementation
check(arg: any) {
return this;
}

static with<T extends BaseFormPage>(this: new () => T): T {
return new this();
}
}
4 changes: 0 additions & 4 deletions frontend/cypress/support/objectiveFormPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,4 @@ export default class CyObjectiveFormPage extends BaseFormPage {
submitDraftObjective() {
cy.getByTestId('safe-draft').click();
}

static with() {
return new CyObjectiveFormPage();
}
}

0 comments on commit 72de293

Please sign in to comment.