Skip to content

Commit

Permalink
Move check-in dialog content checks to check-in dialog helper, rewrit…
Browse files Browse the repository at this point in the history
…e crud tests with new methods
  • Loading branch information
RandomTannenbaum committed Nov 15, 2024
1 parent 94ae634 commit d10e2b6
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 58 deletions.
40 changes: 9 additions & 31 deletions frontend/cypress/e2e/checkIn.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ describe('OKR Check-in e2e tests', () => {
.withMetricValues(Unit.PERCENT, '21', '51')
.fillKeyresultDescription('This is my description')
.submit();
keyresultDetailPage.visit('Very important keyresult').createCheckIn();
checkForDialogTextMetric();
CheckInDialog.do()
keyresultDetailPage
.visit('Very important keyresult')
.createCheckIn()
.checkForDialogTextMetric()
.fillMetricCheckInValue('30')
.setCheckInConfidence(6)
.fillCheckInCommentary('We bought a new house')
Expand Down Expand Up @@ -87,9 +88,10 @@ 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();
checkForDialogTextOrdinal();
CheckInDialog.do()
keyresultDetailPage
.visit('A new ordinal keyresult for our company')
.createCheckIn()
.checkForDialogTextOrdinal()
.selectOrdinalCheckInZone('commit')
.setCheckInConfidence(6)
.fillCheckInCommentary('There is a new car')
Expand Down Expand Up @@ -266,37 +268,13 @@ describe('OKR Check-in e2e tests', () => {
.fillCheckInCommentary('changeinfo')
.fillCheckInInitiatives('initiatives')
.submit();
cy.contains(`Letztes Check-in (${getCurrentDate()})`);
keyresultDetailPage.createCheckIn();
cy.contains('Letzter Wert').siblings('div').contains('10%');
});
});
});

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%) zu erreichen');
cy.contains('Abbrechen');
}

function checkForDialogTextOrdinal() {
cy.contains('A new ordinal keyresult for our company');
cy.contains('Check-in erfassen');
cy.contains('Key Result');
cy.contains('Fail:');
cy.contains('Commit / Target / Stretch noch nicht erreicht');
cy.contains('Commit:');
cy.contains('Target:');
cy.contains('Stretch:');
cy.contains('New car');
cy.contains('New house');
cy.contains('New pool');
cy.contains('Confidence um Target Zone zu erreichen');
cy.contains('Abbrechen');
}

function getCurrentDate() {
const today = new Date();
const yyyy = today.getFullYear();
Expand Down
52 changes: 25 additions & 27 deletions frontend/cypress/e2e/crud.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import * as users from '../fixtures/users.json';
import CyOverviewPage from '../support/helper/pom-helper/pages/overviewPage';
import ObjectiveDialog from '../support/helper/pom-helper/dialogs/objectiveDialog';

describe('CRUD operations', () => {
let op = new CyOverviewPage();

beforeEach(() => {
op = new CyOverviewPage();
cy.loginAsUser(users.gl);
cy.visit('/?quarter=2');
});
Expand All @@ -11,28 +16,17 @@ describe('CRUD operations', () => {
['draft objective title', 'safe-draft', 'draft-icon.svg'],
].forEach(([objectiveTitle, buttonTestId, icon]) => {
it(`Create objective, no keyresults`, () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective(objectiveTitle, buttonTestId, '3');
op.addObjective().fillObjectiveTitle(objectiveTitle).selectQuarter('3');
cy.getByTestId(buttonTestId).click();
cy.visit('/?quarter=3');
const objective = cy.contains(objectiveTitle).first().parentsUntil('#objective-column').last();
const objective = op.getObjectiveByName(objectiveTitle);
objective.findByTestId('objective-state').should('have.attr', 'src', `assets/icons/${icon}`);
});
});

[
['ongoing objective title', 'safe', 'ongoing-icon.svg'],
['draft objective title', 'safe-draft', 'draft-icon.svg'],
].forEach(([objectiveTitle, buttonTestId, icon]) => {
it(`Create objective, no keyresults`, () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective(objectiveTitle, buttonTestId, '3', '', true);
cy.contains('Key Result erfassen');
});
});

it(`Create objective, should display error message`, () => {
cy.getByTestId('add-objective').first().click();
cy.getByTestId('title').first().type('description').clear();
op.addObjective();
cy.getByTestId('title').first().type('title').clear();
cy.contains('Titel muss folgende Länge haben: 2-250 Zeichen');
cy.getByTestId('safe').should('be.disabled');
cy.getByTestId('safe-draft').should('be.disabled');
Expand All @@ -41,17 +35,21 @@ describe('CRUD operations', () => {

it(`Create objective, cancel`, () => {
const objectiveTitle = 'this is a canceled objective';
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective(objectiveTitle, 'cancel', '3');
op.addObjective().selectQuarter('3').cancel();
cy.visit('/?quarter=3');
cy.contains(objectiveTitle).should('not.exist');
});

it(`Delete existing objective`, () => {
cy.get('.objective').first().findByTestId('three-dot-menu').click();
cy.get('.mat-mdc-menu-content').contains('Objective bearbeiten').click();
cy.getByTestId('delete').click();
cy.get("button[type='submit']").contains('Ja').click();
op.selectFromThreeDotMenu('Objective bearbeiten');
ObjectiveDialog.do()
.deleteObjective()
.checkTitle('Objective löschen')
.checkDescription(
'Möchtest du dieses Objective wirklich löschen? Zugehörige Key Results werden dadurch ebenfalls gelöscht!',
)
.submit();
});

it(`Open objective aside via click`, () => {
Expand All @@ -62,16 +60,16 @@ describe('CRUD operations', () => {
it(`update objective`, () => {
const updatedTitle = 'This is an updated title';
cy.get('.objective').first().findByTestId('three-dot-menu').click();
cy.get('.mat-mdc-menu-content').contains('Objective bearbeiten').click();
cy.fillOutObjective(updatedTitle, 'safe');
cy.contains(updatedTitle).first();
op.selectFromThreeDotMenu('Objective bearbeiten');
ObjectiveDialog.do().fillObjectiveTitle(updatedTitle).submit();
cy.contains(updatedTitle).should('exist');
});

it(`Duplicate objective`, () => {
const duplicatedTitle = 'This is a duplicated objective';
cy.get('.objective').first().findByTestId('three-dot-menu').click();
cy.get('.mat-mdc-menu-content').contains('Objective duplizieren').click();
cy.fillOutObjective(duplicatedTitle, 'safe');
cy.contains(duplicatedTitle).first();
op.selectFromThreeDotMenu('Objective duplizieren');
ObjectiveDialog.do().fillObjectiveTitle(duplicatedTitle).submit();
cy.contains(duplicatedTitle).should('exist');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,33 @@ export default class CheckInDialog extends Dialog {
return this;
}

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%) zu erreichen');
cy.contains('Abbrechen');
return this;
}

checkForDialogTextOrdinal() {
cy.contains('A new ordinal keyresult for our company');
cy.contains('Check-in erfassen');
cy.contains('Key Result');
cy.contains('Fail:');
cy.contains('Commit / Target / Stretch noch nicht erreicht');
cy.contains('Commit:');
cy.contains('Target:');
cy.contains('Stretch:');
cy.contains('New car');
cy.contains('New house');
cy.contains('New pool');
cy.contains('Confidence um Target Zone zu erreichen');
cy.contains('Abbrechen');
return this;
}

override submit() {
cy.getByTestId('submit-check-in').click();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Dialog from './dialog';
import ConfirmDialog from './confirmDialog';

export default class ObjectiveDialog extends Dialog {
fillObjectiveTitle(title: string) {
Expand All @@ -21,6 +22,11 @@ export default class ObjectiveDialog extends Dialog {
return this;
}

deleteObjective() {
cy.getByTestId('delete').click();
return new ConfirmDialog();
}

submitDraftObjective() {
cy.getByTestId('safe-draft').click();
}
Expand Down

0 comments on commit d10e2b6

Please sign in to comment.