Skip to content

Commit

Permalink
use objectiveFormPage
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Nov 8, 2024
1 parent 86b30e1 commit 0f27fa4
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 65 deletions.
135 changes: 71 additions & 64 deletions frontend/cypress/e2e/objective-backlog.cy.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,62 @@
import * as users from '../fixtures/users.json';
import { getObjectiveByNameAndState, selectFromThreeDotMenu } from '../support/objective-helper';
import CyOverviewPage from '../support/OverviewPage';
import CyObjectiveFormPage from '../support/objectiveFormPage';

describe('OKR Objective Backlog e2e tests', () => {
let op = new CyOverviewPage();

beforeEach(() => {
op = new CyOverviewPage();
cy.loginAsUser(users.gl);
cy.visit('/?quarter=2');
op.visitCurrentQuarter();
});

it(`Create Objective in backlog quarter should not have save button`, () => {
cy.getByTestId('add-objective').first().click();

cy.getByTestId('title').first().clear().type('Objective in quarter backlog');
cy.get('select#quarter').select('Backlog');
const ofp = op.addObjective().fillObjectiveTitle('Objective in quarter backlog').selectQuarter('Backlog');

cy.contains('Speichern').should('not.exist');
cy.contains('Als Draft speichern');
cy.getByTestId('safe-draft').click();
ofp.submitDraftObjective();

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

cy.visit('/?quarter=999');
op.visitBacklogQuarter();
cy.contains('Objective in quarter backlog');
});

it(`Edit Objective and move to backlog`, () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('Move to another quarter on edit', 'safe-draft', undefined, '', false);
op.addObjective().fillObjectiveTitle('Move to another quarter on edit').submitDraftObjective();

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

cy.fillOutObjective('This goes now to backlog', 'safe', 'Backlog', '', false);
CyObjectiveFormPage.with()
.fillObjectiveTitle('This goes now to backlog')
.selectQuarter('Backlog')
.submitObjective();

cy.contains('This goes now to backlog').should('not.exist');

cy.visit('/?quarter=999');
op.visitBacklogQuarter();
cy.contains('This goes now to backlog');
});

it(`Edit ongoing Objective can not choose backlog in quarter select`, () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('We can not move this to backlog', 'safe', undefined, '', false);
op.addObjective().fillObjectiveTitle('We can not move this to backlog').submitObjective();

getObjectiveByNameAndState('We can not move this to backlog', 'ongoing').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective bearbeiten');
op.getObjectiveByNameAndState('We can not move this to backlog', 'ongoing').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective bearbeiten');

cy.get('select#quarter').should('contain', 'GJ ForTests');
cy.get('select#quarter').should('not.contain', 'Backlog');
});

it(`Can release Objective to another quarter from backlog`, () => {
cy.visit('/?quarter=999');
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('We can not release this', 'safe-draft', 'Backlog', '', false);
op.visitBacklogQuarter();
op.addObjective().fillObjectiveTitle('We can not release this').submitDraftObjective();

getObjectiveByNameAndState('We can not release this', 'draft').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective veröffentlichen');
op.getObjectiveByNameAndState('We can not release this', 'draft').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective veröffentlichen');

cy.contains('Objective veröffentlichen');
cy.getByTestId('title').first().clear().type('This is our first released objective');
Expand All @@ -69,72 +70,78 @@ describe('OKR Objective Backlog e2e tests', () => {

cy.contains('This is our first released objective').should('not.exist');

cy.visit('/?quarter=998');
op.visitGJForTests();
cy.contains('This is our first released objective');
});

it(`Can edit Objective title in backlog`, () => {
cy.visit('/?quarter=999');
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('This is possible for edit', 'safe-draft', undefined, '', false);
op.visitBacklogQuarter();
op.addObjective().fillObjectiveTitle('This is possible for edit').submitDraftObjective();

cy.contains('This is possible for edit');
op.getObjectiveByNameAndState('This is possible for edit', 'draft').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective bearbeiten');

getObjectiveByNameAndState('This is possible for edit', 'draft').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective bearbeiten');
CyObjectiveFormPage.with().fillObjectiveTitle('My new title').submitObjective();

cy.fillOutObjective('My new title', 'safe', undefined, '', false);
cy.contains('My new title');
op.getObjectiveByNameAndState('My new title', 'draft');
});

it(`Can edit Objective in backlog and change quarter`, () => {
cy.visit('/?quarter=999');
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('This goes to other quarter later', 'safe-draft', undefined, '', false);
op.visitBacklogQuarter();
op.addObjective().fillObjectiveTitle('This goes to other quarter later').submitDraftObjective();

getObjectiveByNameAndState('This goes to other quarter later', 'draft').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective bearbeiten');
op.getObjectiveByNameAndState('This goes to other quarter later', 'draft').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective bearbeiten');

cy.get('select#quarter').select('GJ ForTests');
cy.getByTestId('safe').first().click();
CyObjectiveFormPage.with().selectQuarter('GJ ForTests').submitObjective();

cy.visit('/?quarter=998');
cy.contains('This goes to other quarter later');
op.visitGJForTests();
op.getObjectiveByNameAndState('This goes to other quarter later', 'draft');
});

it(`Can duplicate from backlog`, () => {
cy.visit('/?quarter=998');
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('Ready for duplicate', 'safe-draft', undefined, '', false);
it(`Can duplicate in backlog`, () => {
op.visitBacklogQuarter();
op.addObjective().fillObjectiveTitle('Ready for duplicate in backlog').submitDraftObjective();

getObjectiveByNameAndState('Ready for duplicate', 'draft').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective duplizieren');
op.getObjectiveByNameAndState('Ready for duplicate in backlog', 'draft').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective duplizieren');

cy.fillOutObjective('This is a new duplication', 'safe', undefined, '', false);
CyObjectiveFormPage.with().fillObjectiveTitle('This is a new duplication in backlog').submitObjective();

cy.contains('Ready for duplicate');
cy.contains('This is a new duplication');

getObjectiveByNameAndState('Ready for duplicate', 'draft').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective duplizieren');

cy.fillOutObjective('New duplication for other quarter', 'safe', 'GJ ForTests', '', false);
cy.get('New duplication for other quarter').should('not.exist');
op.getObjectiveByNameAndState('Ready for duplicate in backlog', 'draft');
op.getObjectiveByNameAndState('This is a new duplication in backlog', 'draft');
});

cy.contains('New duplication for other quarter');
it('should duplicate from backlog', () => {
op.visitBacklogQuarter();
op.addObjective().fillObjectiveTitle('Ready for duplicate to another quarter').submitDraftObjective();
op.getObjectiveByNameAndState('Ready for duplicate to another quarter', 'draft')
.findByTestId('three-dot-menu')
.click();
op.selectFromThreeDotMenu('Objective duplizieren');

CyObjectiveFormPage.with()
.fillObjectiveTitle('New duplication from backlog')
.selectQuarter('GJ ForTests')
.submitObjective();

op.getObjectiveByNameAndState('Ready for duplicate to another quarter', 'draft').should('exist');
// op.getObjectivesByNameAndState('New duplication from backlog', 'draft').should("have.length", 0)
op.visitGJForTests();
op.getObjectiveByNameAndState('New duplication from backlog', 'draft').should('exist');
});

it(`Can duplicate ongoing Objective to backlog`, () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('Possible to duplicate into backlog', 'safe', undefined, '', false);
op.addObjective().fillObjectiveTitle('Possible to duplicate into backlog').submitObjective();

getObjectiveByNameAndState('Possible to duplicate into backlog', 'ongoing').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective duplizieren');
op.getObjectiveByNameAndState('Possible to duplicate into backlog', 'ongoing')
.findByTestId('three-dot-menu')
.click();
op.selectFromThreeDotMenu('Objective duplizieren');

cy.get('select#quarter').select('Backlog');
cy.getByTestId('safe').first().click();
CyObjectiveFormPage.with().selectQuarter('Backlog').submitObjective();

cy.visit('/?quarter=999');
op.visitBacklogQuarter();
cy.contains('Possible to duplicate into backlog');
});
});
4 changes: 4 additions & 0 deletions frontend/cypress/e2e/objective.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ describe('OKR Objective e2e tests', () => {

op.selectFromThreeDotMenu('Objective wiedereröffnen');

cy.contains('Objective wiedereröffnen');
cy.contains('Soll dieses Objective wiedereröffnet werden?');
cy.getByTestId('confirm-yes').click();

op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing').should('exist');
});

Expand Down
14 changes: 13 additions & 1 deletion frontend/cypress/support/OverviewPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ export default class CyOverviewPage {
cy.visit(`/?quarter=${quarter}`);
}

visitGJForTests() {
cy.visit('/?quarter=998');
}

visitBacklogQuarter() {
cy.visit(`/?quarter=999`);
}

visitCurrentQuarter() {
cy.visit(`/?quarter=2`);
}
Expand All @@ -32,7 +40,11 @@ export default class CyOverviewPage {
}

getObjectiveByNameAndState(objectiveName: string, state: string) {
return getObjectivesByNameAndState(objectiveName, state).first().scrollIntoView().should('exist');
return getObjectivesByNameAndState(objectiveName, state).first().scrollIntoView();
}

getObjectivesByNameAndState(objectiveName: string, string: string) {
return getObjectivesByNameAndState(objectiveName, string);
}

selectFromThreeDotMenu(optionName: string) {
Expand Down
13 changes: 13 additions & 0 deletions frontend/cypress/support/objectiveFormPage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { quarter } from '../../src/app/shared/testData';

export default class CyObjectiveFormPage {
constructor() {
this.init();
}

init() {
cy.get('app-objective-form').should('exist');
}
Expand All @@ -11,23 +15,28 @@ export default class CyObjectiveFormPage {

fillObjectiveTitle(title: string) {
this.fillInput('title', title);
return this;
}

fillObjectiveDescription(description: string) {
this.fillInput('description', description);
return this;
}

selectQuarter(quarter: string) {
cy.get('select#quarter').select(quarter);
return this;
}

toggleCreateKeyResults() {
cy.getByTestId('keyResult-checkbox').find("[type='checkbox']").check();
return this;
}

submitObjective() {
cy.getByTestId('safe').click();
}

submitDraftObjective() {
cy.getByTestId('safe-draft').click();
}
Expand All @@ -40,4 +49,8 @@ export default class CyObjectiveFormPage {
cy.getByTestId(testId).clear();
cy.getByTestId(testId).type(value);
}

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

0 comments on commit 0f27fa4

Please sign in to comment.