Skip to content

Commit

Permalink
Finish e2e tests for duplicating
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelMoeri committed Dec 4, 2024
1 parent 99d3a0e commit 557b08d
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 94 deletions.
192 changes: 99 additions & 93 deletions frontend/cypress/e2e/duplicate-objective.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,111 +10,117 @@ beforeEach(() => {
cy.loginAsUser(users.gl);
});

describe('Functionality of duplicating objectives and their belonging keyresults', () => {
it('Should be able to duplicate a objective into this quarter, including all keyresults', () => {
describe('Functionality of duplicating objectives and their belonging keyResults', () => {
const firstKeyResultName = 'New structure that rewards funny guys and innovation before the end of Q1.';
const secondKeyResultName = 'Monthly town halls between our people and leadership teams over the next four months.';
const thirdKeyResultName = 'High employee satisfaction scores (80%+) throughout the year.';

it('Should be able to duplicate a objective into this quarter, including all keyResults', () => {
const duplicatedTitle = 'This is a duplicated objective with all keyResults';

overviewPage
.getObjectiveByName('Build a company culture that kills the competition.')
.findByTestId('three-dot-menu')
.click();
overviewPage.selectFromThreeDotMenu('Objective duplizieren');
ObjectiveDialog.do().fillObjectiveTitle(duplicatedTitle).submit();
.duplicateObjective('Build a company culture that kills the competition.')
.fillObjectiveTitle(duplicatedTitle)
.submit();

cy.contains(duplicatedTitle);
overviewPage.getKeyResultOfObjective(duplicatedTitle, firstKeyResultName).should('exist');
overviewPage.getKeyResultOfObjective(duplicatedTitle, secondKeyResultName).should('exist');
overviewPage.getKeyResultOfObjective(duplicatedTitle, thirdKeyResultName).should('exist');
});

it('Should be able to duplicate a objective into this quarter, only including one keyResult', () => {
const duplicatedTitle = 'This is a duplicated objective with one keyResult';

cy.contains('This is a default duplicated objective');
overviewPage
.getKeyresultOfObjective(
'This is a duplicated objective with all keyResults',
'New structure that rewards funny guys and innovation before the end of Q1.',
)
.should('exist');
.duplicateObjective('Build a company culture that kills the competition.')
.fillObjectiveTitle(duplicatedTitle)
.excludeKeyResults([secondKeyResultName, thirdKeyResultName])
.submit();

overviewPage.getKeyResultOfObjective(duplicatedTitle, firstKeyResultName);

overviewPage
.getKeyresultOfObjective(
'This is a duplicated objective with all keyResults',
'Monthly town halls between our people and leadership teams over the next four months.',
)
.should('exist');
.getAllKeyResultsOfObjective(duplicatedTitle)
.should('not.contain', secondKeyResultName)
.should('not.contain', thirdKeyResultName);
});

it('Should be able to duplicate a objective into the next quarter, including all keyResults', () => {
const duplicatedTitle = 'This is a default objective with all keyResults in quarter 3!';

overviewPage
.getKeyresultOfObjective(
'This is a duplicated objective with all keyResults',
'High employee satisfaction scores (80%+) throughout the year.',
)
.should('exist');
.duplicateObjective('Build a company culture that kills the competition.')
.fillObjectiveTitle(duplicatedTitle)
.selectQuarter('3')
.submit();

overviewPage.visitNextQuarter();

cy.contains(duplicatedTitle);
overviewPage.getKeyResultOfObjective(duplicatedTitle, firstKeyResultName).should('exist');
overviewPage.getKeyResultOfObjective(duplicatedTitle, secondKeyResultName).should('exist');
overviewPage.getKeyResultOfObjective(duplicatedTitle, thirdKeyResultName).should('exist');
});

it('Should be able to duplicate a objective into this quarter, only including one keyresult', () => {
const duplicatedTitle = 'This is a duplicated objective with one keyResult';
it('Should not duplicate objective when cancel button is clicked', () => {
const duplicatedTitle = 'This is a never existing objective';

overviewPage
.getObjectiveByName('Build a company culture that kills the competition.')
.findByTestId('three-dot-menu')
.click();
overviewPage.selectFromThreeDotMenu('Objective duplizieren');
ObjectiveDialog.do().fillObjectiveTitle(duplicatedTitle).submit();
.duplicateObjective('Build a company culture that kills the competition.')
.fillObjectiveTitle(duplicatedTitle)
.fillObjectiveDescription('Wow this is a very nice description!')
.cancel();

cy.contains(duplicatedTitle).should('not.exist');
});
});

cy.contains('This is a duplicated objective with one keyResult');
describe('e2e test for scoring adjustment on duplicate objective', () => {
let keyresultDetailPage = new KeyResultDetailPage();

it('Duplicate ordinal checkin and validate value of scoring component', () => {
overviewPage
.getKeyresultOfObjective(
'This is a duplicated objective with one keyResult',
'New structure that rewards funny guys and innovation before the end of Q1.',
)
.should('exist');
.addKeyResult('Puzzle ITC', 'Wir wollen die Kundenzufriedenheit steigern')
.fillKeyResultTitle('stretch keyresult for testing')
.withOrdinalValues('Ex. val', 'Ex. val', 'Ex. val')
.submit();

cy.contains('stretch keyresult for testing');
keyresultDetailPage
.visit('stretch keyresult for testing')
.createCheckIn()
.selectOrdinalCheckInZone('stretch')
.setCheckInConfidence(8)
.fillCheckInCommentary('Testveränderungen')
.fillCheckInInitiatives('Testmassnahmen')
.submit();

cy.intercept('GET', '**/overview?*').as('indexPage');
keyresultDetailPage.close();
cy.wait('@indexPage');

overviewPage
.getKeyresultOfObjective(
'This is a duplicated objective with one keyResult',
'Monthly town halls between our people and leadership teams over the next four months.',
)
.should('not.exist');
.duplicateObjective('Wir wollen die Kundenzufriedenheit steigern')
.fillObjectiveTitle('A duplicated Objective for this tool')
.selectQuarter('3')
.submit();

overviewPage.checkForToaster('Das Objective wurde erfolgreich erstellt.', 'success');

overviewPage.visitNextQuarter();

overviewPage
.getKeyresultOfObjective(
'This is a duplicated objective with one keyResult',
'High employee satisfaction scores (80%+) throughout the year.',
)
.should('not.exist');
.getKeyResultByName('stretch keyresult for testing')
.findByTestId('scoring-component')
.findByTestId('fail')
.as('fail-area');

cy.get('@fail-area').should(($fail) => {
expect($fail).not.to.have.css('score-red');
expect($fail).not.to.have.css('score-yellow');
expect($fail).not.to.have.css('score-green');
expect($fail).not.to.have.css('score-stretch');
});
});
});

// describe('e2e test for scoring adjustment on duplicate objective', () => {
// it('Duplicate ordinal checkin and validate value of scoring component', () => {
// overviewPage
// .addKeyResult('Puzzle ITC', 'Wir wollen die Kundenzufriedenheit steigern')
// .fillKeyResultTitle('stretch keyresult for testing')
// .withOrdinalValues('Ex. val', 'Ex. val', 'Ex. val')
// .submit();
//
// cy.contains('stretch keyresult for testing');
// keyresultDetailPage
// .visit('stretch keyresult for testing')
// .createCheckIn()
// .selectOrdinalCheckInZone('stretch')
// .setCheckInConfidence(8)
// .fillCheckInCommentary('Testveränderungen')
// .fillCheckInInitiatives('Testmassnahmen')
// .submit();
//
// cy.intercept('GET', '**/overview?*').as('indexPage');
// keyresultDetailPage.close();
// cy.wait('@indexPage');
//
// overviewPage
// .duplicateObjective('Wir wollen die Kundenzufriedenheit steigern')
// .fillObjectiveTitle('A duplicated Objective for this tool')
// .selectQuarter('3')
// .submit();
//
// overviewPage.checkForToaster('Das Objective wurde erfolgreich erstellt.', 'success');
//
// overviewPage.visitNextQuarter();
//
// overviewPage
// .getKeyResultByName('stretch keyresult for testing')
// .findByTestId('scoring-component')
// .findByTestId('fail')
// .as('fail-area');
//
// cy.get('@fail-area').should(($fail) => {
// expect($fail).not.to.have.css('score-red');
// expect($fail).not.to.have.css('score-yellow');
// expect($fail).not.to.have.css('score-green');
// expect($fail).not.to.have.css('score-stretch');
// });
// });
// });
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export default class ObjectiveDialog extends Dialog {
cy.getByTestId('save-draft').click();
}

excludeKeyResults(keyResults: string[]) {
keyResults.forEach((keyResult) => {
cy.get('label').contains(keyResult.slice(0, 15)).click();
});
return this;
}

getPage(): Chainable {
return cy.get('app-objective-form').should('exist');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,18 @@ export default class CyOverviewPage extends Page {
return cy.get('@team');
}

getKeyresultOfObjective(objectiveName: string, keyResultName: string) {
getKeyResultOfObjective(objectiveName: string, keyResultName: string) {
return this.getObjectiveByName(objectiveName)
.last()
.find('.key-result')
.filter(filterByKeyResultName(keyResultName))
.last();
}

getAllKeyResultsOfObjective(objectiveName: string) {
return this.getObjectiveByName(objectiveName).find('.key-result');
}

getObjectivesByName(objectiveName: string) {
return getObjectiveColumns().filter(filterByObjectiveName(objectiveName));
}
Expand Down Expand Up @@ -130,8 +134,10 @@ export default class CyOverviewPage extends Page {
}

duplicateObjective(objectiveName: string) {
cy.intercept('GET', '**/objectives/*/keyResults').as('keyResults');
this.getObjectiveByName(objectiveName).findByTestId('three-dot-menu').click();
this.selectFromThreeDotMenu('Objective duplizieren');
cy.wait('@keyResults');
return new ObjectiveDialog();
}

Expand Down

0 comments on commit 557b08d

Please sign in to comment.