Skip to content

Commit

Permalink
Refactor last checkin tests and add method to overview page to find o…
Browse files Browse the repository at this point in the history
…bjective by team and name
  • Loading branch information
RandomTannenbaum committed Nov 15, 2024
1 parent b49fd13 commit 219f4f8
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 99 deletions.
142 changes: 51 additions & 91 deletions frontend/cypress/e2e/checkIn.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { uniqueSuffix } from '../support/helper/utils';
import CyOverviewPage from '../support/helper/pom-helper/pages/overviewPage';
import { Unit } from '../../src/app/shared/types/enums/Unit';
import KeyresultDetailPage from '../support/helper/pom-helper/pages/keyresultDetailPage';
import Chainable = Cypress.Chainable;
import CheckInDialog from '../support/helper/pom-helper/dialogs/checkInDialog';
import CheckInHistoryDialog from '../support/helper/pom-helper/dialogs/checkInHistoryDialog';
import ConfirmDialog from '../support/helper/pom-helper/dialogs/confirmDialog';

describe('OKR Check-in e2e tests', () => {
describe('tests via click', () => {
Expand All @@ -27,9 +27,9 @@ describe('OKR Check-in e2e tests', () => {
.withMetricValues(Unit.PERCENT, '21', '51')
.fillKeyresultDescription('This is my description')
.submit();
keyresultDetailPage
.visit('Very important keyresult')
.createCheckIn()
keyresultDetailPage.visit('Very important keyresult').createCheckIn();
checkForDialogTextMetric();
CheckInDialog.do()
.fillMetricCheckInValue('30')
.setCheckInConfidence(6)
.fillCheckInCommentary('We bought a new house')
Expand Down Expand Up @@ -87,9 +87,9 @@ describe('OKR Check-in e2e tests', () => {
.withOrdinalValues('New house', 'New car', 'New pool')
.fillKeyresultDescription('This is my description')
.submit();
keyresultDetailPage
.visit('A new ordinal keyresult for our company')
.createCheckIn()
keyresultDetailPage.visit('A new ordinal keyresult for our company').createCheckIn();
checkForDialogTextOrdinal();
CheckInDialog.do()
.selectOrdinalCheckInZone('commit')
.setCheckInConfidence(6)
.fillCheckInCommentary('There is a new car')
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('OKR Check-in e2e tests', () => {
cy.contains('We bought a new sheep');
});

it.only('Should generate right labels in checkin history list', () => {
it('Should generate right labels in checkin history list', () => {
op.addKeyresult()
.fillKeyresultTitle('A new KeyResult for checking checkin list')
.withMetricValues(Unit.EUR, '10', '300')
Expand Down Expand Up @@ -207,117 +207,77 @@ describe('OKR Check-in e2e tests', () => {
});

it('Edit ordinal checkin', () => {
cy.getByTestId('objective').first().getByTestId('add-keyResult').first().click();
cy.getByTestId('submit').should('be.disabled');

cy.getByTestId('titleInput').type('Title');
cy.getByTestId('ordinalTab').click();

cy.fillOutKeyResult(
'For editing ordinal checkin',
null,
null,
null,
'New house',
'New car',
'New pool',
null,
'This is my description',
);
cy.getByTestId('submit').click();

cy.getByTestId('keyresult').contains('For editing ordinal checkin').click();
cy.getByTestId('add-check-in').first().click();
cy.fillOutCheckInOrdinal(0, 6, 'There is a new car', 'Buy now a new pool');
cy.getByTestId('show-all-checkins').click();

cy.wait(500);
cy.contains('Check-in History');
cy.getByTestId('edit-check-in').first().click();
op.addKeyresult()
.fillKeyresultTitle('For editing ordinal checkin')
.withOrdinalValues('New house', 'New car', 'New pool')
.fillKeyresultDescription('This is my description')
.submit();
keyresultDetailPage
.visit('For editing ordinal checkin')
.createCheckIn()
.selectOrdinalCheckInZone('fail')
.setCheckInConfidence(6)
.fillCheckInCommentary('There is a new car')
.fillCheckInInitiatives('Buy now a new pool')
.submit();
keyresultDetailPage.showAllCheckins().editLatestCheckIn();
cy.contains('For editing ordinal checkin');
cy.contains('Confidence um Target Zone zu erreichen');
cy.contains('6/10');
cy.getByTestId('stretch-radio').click();
cy.getByTestId('confidence-slider').realMouseDown();
cy.contains('There is a new car');
cy.contains('Buy now a new pool');
cy.getByTestId('changeInfo').clear().type('We bought a new dog');
cy.getByTestId('submit-check-in').click();

cy.wait(200);
CheckInDialog.do().selectOrdinalCheckInZone('stretch').fillCheckInCommentary('We bought a new dog').submit();
cy.contains('We bought a new dog');
cy.contains('Buy now a new pool');
cy.contains('STRETCH');
});

it(`Should display confirm dialog when creating checkin on draft objective`, () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('draft objective title', 'safe-draft', '3');
cy.visit('/?quarter=3');
cy.contains('draft objective title').first().parentsUntil('#objective-column').last().focus();

cy.tabForwardUntil('[data-testId="add-keyResult"]');
cy.focused().contains('Key Result hinzufügen');
cy.realPress('Enter');

cy.fillOutKeyResult(
'I am a metric keyresult for testing',
'PERCENT',
'21',
'52',
null,
null,
null,
null,
'This is my description',
op.addObjective().fillObjectiveTitle('draft objective title').selectQuarter('3').submitDraftObjective();
op.visitNextQuarter();
op.addKeyresult(undefined, 'draft objective title')
.fillKeyresultTitle('I am a metric keyresult for testing')
.withMetricValues(Unit.PERCENT, '21', '52')
.fillKeyresultDescription('This is my description')
.submit();
keyresultDetailPage.visit('I am a metric keyresult for testing');
keyresultDetailPage.elements.addCheckin().click();
ConfirmDialog.do().checkTitle('Check-in im Draft-Status');
ConfirmDialog.do().checkDescription(
'Dein Objective befindet sich noch im DRAFT Status. Möchtest du das Check-in trotzdem erfassen?',
);
cy.getByTestId('submit').click();

cy.getByTestId('keyresult').contains('I am a metric keyresult for testing').click();

cy.tabForwardUntil('[data-testId="add-check-in"]');
cy.focused().contains('Check-in erfassen').click();
cy.contains('Check-in im Draft-Status');
cy.contains('Dein Objective befindet sich noch im DRAFT Status. Möchtest du das Check-in trotzdem erfassen?');
});

it(`Should only display last value div if last checkin is present`, () => {
const objectiveName = uniqueSuffix('new objective');
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective(objectiveName, 'safe', '3');
cy.visit('/?quarter=3');
getObjectiveContainerByName(objectiveName).focus();

cy.tabForwardUntil('[data-testId="add-keyResult"]');
cy.focused().contains('Key Result hinzufügen');
cy.realPress('Enter');

cy.fillOutKeyResult('I am a keyresult metric', 'PERCENT', '45', '60', null, null, null, null, 'Description');
cy.getByTestId('submit').click();
getObjectiveContainerByName(objectiveName).getByTestId('keyresult').contains('I am a keyresult metric').click();

cy.intercept('**/keyresults/*').as('getKeyResultsAfterSave');
cy.getByTestId('add-check-in').first().click();
op.addObjective().fillObjectiveTitle(objectiveName).selectQuarter('3').submit();
op.visitNextQuarter();
op.addKeyresult(undefined, objectiveName)
.fillKeyresultTitle('I am a keyresult metric')
.withMetricValues(Unit.PERCENT, '45', '60')
.fillKeyresultDescription('Description')
.submit();
keyresultDetailPage.visit('I am a keyresult metric').createCheckIn();
cy.getByTestId('old-checkin-value').should('not.exist');
cy.fillOutCheckInMetric(10, 0, 'changeinfo', 'initiatives');
cy.wait('@getKeyResultsAfterSave');

cy.getByTestId('add-check-in').first().click();
CheckInDialog.do()
.fillMetricCheckInValue('10')
.setCheckInConfidence(0)
.fillCheckInCommentary('changeinfo')
.fillCheckInInitiatives('initiatives')
.submit();
keyresultDetailPage.createCheckIn();
cy.contains('Letzter Wert').siblings('div').contains('10%');
});
});
});

function getObjectiveContainerByName(name: string): Chainable {
return cy.contains(name).first().parentsUntil('#objective-column').last();
}

function checkForDialogTextMetric() {
cy.contains('Very important keyresult');
cy.contains('Check-in erfassen');
cy.contains('Key Result');
cy.contains('Neuer Wert');
cy.contains('Confidence um Target Zone (42.7%) zu erreichen');
cy.contains('Confidence um Target Zone (42%) zu erreichen');
cy.contains('Abbrechen');
}

Expand Down
25 changes: 17 additions & 8 deletions frontend/cypress/support/helper/pom-helper/pages/overviewPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ export default class CyOverviewPage extends Page {
}

addKeyresult(teamName?: string, objectiveName?: string) {
if (teamName) {
if (objectiveName) {
this.getObjectiveByName(objectiveName).findByTestId('add-keyResult').first().click();
} else {
this.getTeamByName(teamName).findByTestId('add-keyResult').first().click();
}
return new KeyResultDialog();
if (teamName && objectiveName) {
this.getObjectiveByTeamAndName(teamName, objectiveName).findByTestId('add-keyResult').first().click();
} else if (teamName) {
this.getTeamByName(teamName).findByTestId('add-keyResult').first().click();
} else if (objectiveName) {
this.getObjectiveByName(objectiveName).findByTestId('add-keyResult').first().click();
} else {
cy.getByTestId('add-keyResult').first().click();
}
cy.getByTestId('add-keyResult').first().click();

return new KeyResultDialog();
}

Expand All @@ -68,6 +69,14 @@ export default class CyOverviewPage extends Page {
return this.getObjectivesByName(objectiveName).last().scrollIntoView();
}

getObjectiveByTeamAndName(teamName: string, objectiveName: string) {
return this.getTeamByName(teamName)
.find('.objective')
.filter(filterByObjectiveName(objectiveName))
.last()
.scrollIntoView();
}

getObjectivesByName(objectiveName: string) {
return getObjectiveColumns().filter(filterByObjectiveName(objectiveName));
}
Expand Down

0 comments on commit 219f4f8

Please sign in to comment.