Skip to content

Commit

Permalink
Cleanup e2e tests (#1199)
Browse files Browse the repository at this point in the history
* Clean up cypress tests

* Check if Alle option is not selected before toggling it in overview e2e test

* Replace direct call to .createCheckIn with manual click
  • Loading branch information
RandomTannenbaum authored Nov 22, 2024
1 parent 77656a2 commit ff07273
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 162 deletions.
65 changes: 36 additions & 29 deletions frontend/cypress/e2e/check-in.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as users from '../fixtures/users.json';
import { onlyOn } from '@cypress/skip-test';
import { uniqueSuffix } from '../support/helper/utils';
import CyOverviewPage from '../support/helper/dom-helper/pages/overviewPage';
import { Unit } from '../../src/app/shared/types/enums/Unit';
Expand All @@ -10,17 +9,18 @@ import ConfirmDialog from '../support/helper/dom-helper/dialogs/confirmDialog';

describe('OKR Check-in e2e tests', () => {
describe('tests via click', () => {
let op = new CyOverviewPage();
let overviewPage = new CyOverviewPage();
let keyresultDetailPage = new KeyResultDetailPage();

beforeEach(() => {
op = new CyOverviewPage();
overviewPage = new CyOverviewPage();
keyresultDetailPage = new KeyResultDetailPage();
cy.loginAsUser(users.gl);
});

it(`Create checkin metric`, () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('Very important keyresult')
.withMetricValues(Unit.PERCENT, '21', '51')
.fillKeyResultDescription('This is my description')
Expand All @@ -41,7 +41,8 @@ describe('OKR Check-in e2e tests', () => {
});

it(`Create checkin metric with confidence 0`, () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('Very important keyresult')
.withMetricValues(Unit.PERCENT, '21', '51')
.fillKeyResultDescription('This is my description')
Expand All @@ -62,7 +63,8 @@ describe('OKR Check-in e2e tests', () => {
});

it(`Create checkin metric with value below baseline`, () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('This will not be good')
.withMetricValues(Unit.PERCENT, '21', '52')
.fillKeyResultDescription('This is my description')
Expand All @@ -81,7 +83,8 @@ describe('OKR Check-in e2e tests', () => {
});

it('Create checkin ordinal', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('A new ordinal keyresult for our company')
.withOrdinalValues('New house', 'New car', 'New pool')
.fillKeyResultDescription('This is my description')
Expand All @@ -102,7 +105,8 @@ describe('OKR Check-in e2e tests', () => {
});

it('Should generate checkin list', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('This will give a checkin list')
.withMetricValues(Unit.PERCENT, '21', '52')
.fillKeyResultDescription('This is my description')
Expand All @@ -122,22 +126,24 @@ describe('OKR Check-in e2e tests', () => {
.fillCheckInCommentary('This was a good idea')
.fillCheckInInitiatives('Will be difficult')
.submit();
keyresultDetailPage.showAllCheckins();
keyresultDetailPage
.showAllCheckins()
.checkForAttribute('Confidence:', '5 / 10')
.checkForAttribute('Confidence:', '6 / 10')
.checkForAttribute('Veränderungen:', 'We bought a new house')
.checkForAttribute('Veränderungen:', 'This was a good idea')
.checkForAttribute('Massnahmen:', 'We have to buy more PCs')
.checkForAttribute('Massnahmen:', 'Will be difficult');

cy.contains('Check-in History');
cy.contains(getCurrentDate());
cy.contains('Wert: 30%');
cy.contains('Wert: 50%');
checkForAttribute('Confidence:', '5 / 10');
checkForAttribute('Confidence:', '6 / 10');
checkForAttribute('Veränderungen:', 'We bought a new house');
checkForAttribute('Veränderungen:', 'This was a good idea');
checkForAttribute('Massnahmen:', 'We have to buy more PCs');
checkForAttribute('Massnahmen:', 'Will be difficult');
});

it('Edit metric checkin', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('Here we edit a metric checkin')
.withMetricValues(Unit.CHF, '10', '300')
.fillKeyResultDescription('This is my description')
Expand Down Expand Up @@ -167,7 +173,8 @@ describe('OKR Check-in e2e tests', () => {
});

it('Should generate right labels in checkin history list', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('A new KeyResult for checking checkin list')
.withMetricValues(Unit.EUR, '10', '300')
.fillKeyResultDescription('This is my description')
Expand All @@ -187,7 +194,8 @@ describe('OKR Check-in e2e tests', () => {
CheckInHistoryDialog.do().close();
keyresultDetailPage.close();

op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('There is another kr with fte')
.withMetricValues(Unit.FTE, '10', '300')
.fillKeyResultDescription('This is my description')
Expand All @@ -207,7 +215,8 @@ describe('OKR Check-in e2e tests', () => {
});

it('Edit ordinal checkin', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('For editing ordinal checkin')
.withOrdinalValues('New house', 'New car', 'New pool')
.fillKeyResultDescription('This is my description')
Expand All @@ -233,9 +242,10 @@ describe('OKR Check-in e2e tests', () => {
});

it(`Should display confirm dialog when creating checkin on draft objective`, () => {
op.addObjective().fillObjectiveTitle('draft objective title').selectQuarter('3').submitDraftObjective();
op.visitNextQuarter();
op.addKeyResult(undefined, 'draft objective title')
overviewPage.addObjective().fillObjectiveTitle('draft objective title').selectQuarter('3').submitDraftObjective();
overviewPage.visitNextQuarter();
overviewPage
.addKeyResult(undefined, 'draft objective title')
.fillKeyResultTitle('I am a metric keyresult for testing')
.withMetricValues(Unit.PERCENT, '21', '52')
.fillKeyResultDescription('This is my description')
Expand All @@ -251,9 +261,10 @@ describe('OKR Check-in e2e tests', () => {
it(`Should only display last value div if last checkin is present`, () => {
const objectiveName = uniqueSuffix('new objective');

op.addObjective().fillObjectiveTitle(objectiveName).selectQuarter('3').submit();
op.visitNextQuarter();
op.addKeyResult(undefined, objectiveName)
overviewPage.addObjective().fillObjectiveTitle(objectiveName).selectQuarter('3').submit();
overviewPage.visitNextQuarter();
overviewPage
.addKeyResult(undefined, objectiveName)
.fillKeyResultTitle('I am a keyresult metric')
.withMetricValues(Unit.PERCENT, '45', '60')
.fillKeyResultDescription('Description')
Expand Down Expand Up @@ -286,7 +297,3 @@ function getCurrentDate() {

return dd_str + '.' + mm_str + '.' + yyyy;
}

function checkForAttribute(title: string, value: string) {
cy.get('mat-dialog-container').contains(value).parent().should('contain', title);
}
17 changes: 10 additions & 7 deletions frontend/cypress/e2e/duplicated-scoring.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ import CyOverviewPage from '../support/helper/dom-helper/pages/overviewPage';
import KeyResultDetailPage from '../support/helper/dom-helper/pages/keyResultDetailPage';

describe('e2e test for scoring adjustment on objective duplicate', () => {
let op = new CyOverviewPage();
let overviewPage = new CyOverviewPage();
let keyresultDetailPage = new KeyResultDetailPage();

beforeEach(() => {
op = new CyOverviewPage();
overviewPage = new CyOverviewPage();
keyresultDetailPage = new KeyResultDetailPage();
cy.loginAsUser(users.gl);
});

it('Duplicate ordinal checkin and validate value of scoring component', () => {
op.addKeyResult('Puzzle ITC', 'Wir wollen die Kundenzufriedenheit steigern')
overviewPage
.addKeyResult('Puzzle ITC', 'Wir wollen die Kundenzufriedenheit steigern')
.fillKeyResultTitle('stretch keyresult for testing')
.withOrdinalValues('Ex. val', 'Ex. val', 'Ex. val')
.submit();
Expand All @@ -32,16 +33,18 @@ describe('e2e test for scoring adjustment on objective duplicate', () => {
keyresultDetailPage.close();
cy.wait('@indexPage');

op.duplicateObjective('Wir wollen die Kundenzufriedenheit steigern')
overviewPage
.duplicateObjective('Wir wollen die Kundenzufriedenheit steigern')
.fillObjectiveTitle('A duplicated Objective for this tool')
.selectQuarter('3')
.submit();

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

cy.visit('/?quarter=3');
overviewPage.visitNextQuarter();

op.getKeyResultByName('stretch keyresult for testing')
overviewPage
.getKeyResultByName('stretch keyresult for testing')
.findByTestId('scoring-component')
.findByTestId('fail')
.as('fail-area');
Expand Down
27 changes: 17 additions & 10 deletions frontend/cypress/e2e/key-result.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import { Unit } from '../../src/app/shared/types/enums/Unit';
import KeyResultDialog from '../support/helper/dom-helper/dialogs/keyResultDialog';

describe('OKR Overview', () => {
let op = new CyOverviewPage();
let overviewPage = new CyOverviewPage();
let keyResultDetailPage = new KeyResultDetailPage();

beforeEach(() => {
op = new CyOverviewPage();
overviewPage = new CyOverviewPage();
keyResultDetailPage = new KeyResultDetailPage();
cy.loginAsUser(users.gl);
});

it('Create new metric KeyResult', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.checkForDialogTextMetric()
.fillKeyResultTitle('I am a metric keyresult')
.withMetricValues(Unit.PERCENT, '21', '52')
Expand All @@ -38,7 +39,8 @@ describe('OKR Overview', () => {
});

it('Create new ordinal KeyResult', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('I am a ordinal keyresult')
.withOrdinalValues('My commit zone', 'My target zone', 'My stretch goal')
.checkForDialogTextOrdinal()
Expand All @@ -65,7 +67,8 @@ describe('OKR Overview', () => {
});

it('Create new KeyResult and Save and New', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.checkForDialogTextMetric()
.fillKeyResultTitle('I am a metric keyresult with a new one')
.withMetricValues(Unit.PERCENT, '21', '52')
Expand All @@ -77,7 +80,8 @@ describe('OKR Overview', () => {
});

it('Create and edit KeyResult with Action Plan', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('This is a keyresult with an action plan')
.withOrdinalValues('My commit zone', 'My target zone', 'My stretch goal')
.fillOwner('Bob Baumeister')
Expand All @@ -103,7 +107,8 @@ describe('OKR Overview', () => {
});

it('Edit a KeyResult without type change', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('We want not to change keyresult title')
.withOrdinalValues('My commit zone', 'My target zone', 'My stretch goal')
.checkForDialogTextOrdinal()
Expand Down Expand Up @@ -135,7 +140,8 @@ describe('OKR Overview', () => {
});

it('Edit a KeyResult with type change', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('Here we want to change keyresult title')
.withOrdinalValues('My commit zone', 'My target zone', 'My stretch goal')
.checkForDialogTextOrdinal()
Expand Down Expand Up @@ -167,7 +173,7 @@ describe('OKR Overview', () => {
});

it('Check validation in keyresult dialog', () => {
op.addKeyResult().checkForDialogTextMetric();
overviewPage.addKeyResult().checkForDialogTextMetric();
cy.getByTestId('submit').should('be.disabled');
KeyResultDialog.do()
.fillKeyResultTitle('I am a metric keyresult')
Expand Down Expand Up @@ -240,7 +246,8 @@ describe('OKR Overview', () => {
});

it('Delete existing keyresult', () => {
op.addKeyResult()
overviewPage
.addKeyResult()
.fillKeyResultTitle('A keyresult to delete')
.withOrdinalValues('My commit zone', 'My target zone', 'My stretch goal')
.checkForDialogTextOrdinal()
Expand Down
Loading

0 comments on commit ff07273

Please sign in to comment.