Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/552 e2e scoring #575

Merged
merged 28 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c8ea871
create new cypress test file for scoring component, move methods to c…
RandomTannenbaum Nov 10, 2023
b3c0c08
start writing test and make it create metric keyresult incl. checkin …
RandomTannenbaum Nov 10, 2023
27ca6fd
fix selecting of correct keyresult on overview in scoring component test
RandomTannenbaum Nov 10, 2023
0e4914f
get width of fail zone in test and add test-id to all three scoring c…
RandomTannenbaum Nov 10, 2023
89e97de
correct wrong placement of test ids and temporary remove unwanted tes…
RandomTannenbaum Nov 10, 2023
1a061f2
move submitting of keyresult form to new method
RandomTannenbaum Nov 10, 2023
4169394
move submitting of keyresult dialog back to cypress methods and creat…
RandomTannenbaum Nov 10, 2023
229bb55
use new checkForDialogText method in createMetricKeyresult
RandomTannenbaum Nov 10, 2023
3e7eda4
bring back testing of labels to keyresult dialog e2e tests
RandomTannenbaum Nov 10, 2023
b671ad6
make test in scoring component tests create ordinal keyresult
RandomTannenbaum Nov 10, 2023
ccb659d
add test id to keyresult detail close button and return to overview a…
RandomTannenbaum Nov 10, 2023
9266714
remove unnecessary tabbing in e2e test
RandomTannenbaum Nov 14, 2023
e801e12
remove all occurences of tabbing in scoring component tests and add t…
RandomTannenbaum Nov 14, 2023
e7fce90
modify createMetricKeyresult command, so now the baseline, commit zon…
RandomTannenbaum Nov 14, 2023
f96463d
change falsy check to undefined check
RandomTannenbaum Nov 14, 2023
95bc731
move setting of rgb value to method in scoring component tests
RandomTannenbaum Nov 14, 2023
cd7d019
add boolean to method that checks scoring component state, that says …
RandomTannenbaum Nov 14, 2023
fac9f3c
move code to validate scoring width and scoring color to new methods
RandomTannenbaum Nov 14, 2023
af87ae1
fix checking of background-color on moonshot
RandomTannenbaum Nov 14, 2023
933ef41
rename method from validateScoringWidthsAndColor to validateMetricSco…
RandomTannenbaum Nov 14, 2023
d132713
move test over methods in scoring e2e tests
RandomTannenbaum Nov 14, 2023
25eb76e
implement ordinal tests
kcinay055679 Nov 16, 2023
0b18f78
check for strech image and filled start
kcinay055679 Nov 16, 2023
2a47709
outsource method to cypress methods
kcinay055679 Nov 16, 2023
a86a713
run tests only on chorm e
kcinay055679 Nov 16, 2023
7b6e31d
fix failing e2e tests
kcinay055679 Nov 16, 2023
5d6d16e
clean up
kcinay055679 Nov 16, 2023
f0148ed
update conifg
kcinay055679 Nov 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .run/OkrApplication-Dev.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="OkrApplication-Dev" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="ACTIVE_PROFILES" value="dev" />
<option name="ALTERNATIVE_JRE_PATH" value="azul-17" />
<option name="ALTERNATIVE_JRE_PATH" value="17" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<module name="backend" />
<option name="SPRING_BOOT_MAIN_CLASS" value="ch.puzzle.okr.OkrApplication" />
Expand Down
2 changes: 1 addition & 1 deletion .run/OkrApplication-E2E.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="OkrApplication-E2E" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="ACTIVE_PROFILES" value="integration-test" />
<option name="ALTERNATIVE_JRE_PATH" value="azul-17" />
<option name="ALTERNATIVE_JRE_PATH" value="17" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<module name="backend" />
<option name="SPRING_BOOT_MAIN_CLASS" value="ch.puzzle.okr.OkrApplication" />
Expand Down
1 change: 1 addition & 0 deletions frontend/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:4200',
experimentalMemoryManagement: true,
},
env: {
login_url: 'https://idp-mock-okr.ocp-internal.cloudscale.puzzle.ch',
Expand Down
8 changes: 4 additions & 4 deletions frontend/cypress/e2e/checkIn.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ describe('OKR Check-in e2e tests', () => {
it('Edit metric checkin', () => {
cy.getByTestId('objective').first().getByTestId('add-keyResult').first().click();
cy.getByTestId('submit').should('be.disabled');

cy.fillOutKeyResult(
'Here we edit a metric checkin',
'CHF',
Expand All @@ -155,6 +154,7 @@ describe('OKR Check-in e2e tests', () => {
null,
'This is my description',
);

cy.getByTestId('submit').click();

cy.getByTestId('keyresult').contains('Here we edit a metric checkin').click();
Expand All @@ -166,7 +166,7 @@ describe('OKR Check-in e2e tests', () => {

cy.wait(500);
cy.contains('Check-in History');
cy.getByTestId('edit-check-in').click();
cy.getByTestId('edit-check-in').first().click();
cy.contains('Here we edit a metric checkin');
cy.contains('CHF 30.-');
cy.contains('Confidence um Target (CHF 213.-) zu erreichen');
Expand Down Expand Up @@ -211,11 +211,11 @@ describe('OKR Check-in e2e tests', () => {

cy.wait(500);
cy.contains('Check-in History');
cy.getByTestId('edit-check-in').click();
cy.getByTestId('edit-check-in').first().click();
cy.contains('For editing ordinal checkin');
cy.contains('Confidence um Target zu erreichen');
cy.contains('6/10');
cy.getByTestId('stretchZone').click();
cy.getByTestId('stretch-radio').click();
cy.getByTestId('confidence-slider').realMouseDown();
cy.getByTestId('check-in-next').click();
cy.contains('There is a new car');
Expand Down
75 changes: 8 additions & 67 deletions frontend/cypress/e2e/keyresult.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,7 @@ describe('OKR Overview', () => {
});

it('Create new metric KeyResult', () => {
cy.getByTestId('objective').first().getByTestId('add-keyResult').first().click();
cy.getByTestId('submit').should('be.disabled');
cy.contains('Key Result erfassen');
cy.contains('Jaya Norris');
checkForDialogText();

cy.fillOutKeyResult(
'I am a metric keyresult',
'PERCENT',
'21',
'52',
null,
null,
null,
'Pac',
'This is my description',
);
cy.getByTestId('submit').should('not.be.disabled');
cy.getByTestId('submit').click();
cy.createMetricKeyresult(null, null, null);

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

Expand All @@ -43,7 +25,7 @@ describe('OKR Overview', () => {
});

it('Create new ordinal KeyResult', () => {
createOrdinalKeyResult(null, 'Pac');
cy.createOrdinalKeyresult(null, 'Pac');

cy.getByTestId('keyresult').contains('I am a ordinal keyresult').click();
cy.contains('I am a ordinal keyresult');
Expand All @@ -68,7 +50,7 @@ describe('OKR Overview', () => {
cy.getByTestId('submit').should('be.disabled');
cy.contains('Key Result erfassen');
cy.contains('Jaya Norris');
checkForDialogText();
cy.checkForDialogText();

cy.fillOutKeyResult(
'I am a metric keyresult with a new one',
Expand All @@ -87,7 +69,7 @@ describe('OKR Overview', () => {
cy.getByTestId('submit').should('be.disabled');
cy.contains('Key Result erfassen');
cy.contains('Jaya Norris');
checkForDialogText();
cy.checkForDialogText();
});

it('Create and edit KeyResult with Action Plan', () => {
Expand Down Expand Up @@ -139,7 +121,7 @@ describe('OKR Overview', () => {
});

it('Edit a KeyResult without type change', () => {
createOrdinalKeyResult('We want not to change keyresult title');
cy.createOrdinalKeyresult('We want not to change keyresult title', null);

cy.getByTestId('keyresult').contains('We want not to change keyresult title').last().click();
cy.getByTestId('edit-keyResult').click();
Expand Down Expand Up @@ -176,7 +158,7 @@ describe('OKR Overview', () => {
});

it('Edit a KeyResult with type change', () => {
createOrdinalKeyResult('Here we want to change keyresult title');
cy.createOrdinalKeyresult('Here we want to change keyresult title', null);

cy.getByTestId('keyresult').contains('Here we want to change keyresult title').last().click();
cy.getByTestId('edit-keyResult').click();
Expand Down Expand Up @@ -220,7 +202,7 @@ describe('OKR Overview', () => {
cy.getByTestId('objective').first().getByTestId('add-keyResult').first().click();
cy.getByTestId('submit').should('be.disabled');
cy.contains('Key Result erfassen');
checkForDialogText();
cy.checkForDialogText();

cy.fillOutKeyResult(
'I am a metric keyresult',
Expand Down Expand Up @@ -304,7 +286,7 @@ describe('OKR Overview', () => {
});

it('Delete existing keyresult', () => {
createOrdinalKeyResult('A keyresult to delete');
cy.createOrdinalKeyresult('A keyresult to delete', null);

cy.getByTestId('keyresult').contains('A keyresult to delete').last().click();

Expand All @@ -317,44 +299,3 @@ describe('OKR Overview', () => {
cy.get('A keyresult to delete').should('not.exist');
});
});

function createOrdinalKeyResult(title: string | null = null, owner: string | null = null) {
cy.getByTestId('objective').first().getByTestId('add-keyResult').first().click();
cy.getByTestId('submit').should('be.disabled');
cy.contains('Key Result erfassen');
cy.contains('Jaya Norris');
checkForDialogText();
cy.getByTestId('titleInput').type('Title');

cy.getByTestId('ordinalTab').click();

cy.fillOutKeyResult(
title == null ? 'I am a ordinal keyresult' : title,
null,
null,
null,
'My commit zone',
'My target zone',
'My stretch zone',
owner,
'This is my description',
);

cy.getByTestId('submit').should('not.be.disabled');
cy.getByTestId('submit').click();
}

function checkForDialogText() {
cy.contains('Titel');
cy.contains('Metrisch');
cy.contains('Ordinal');
cy.contains('Einheit');
cy.contains('Baseline');
cy.contains('Stretch Goal');
cy.contains('Owner');
cy.contains('Beschreibung (optional)');
cy.contains('Action Plan (optional)');
cy.contains('Weitere Action hinzufügen');
cy.contains('Speichern');
cy.contains('Abbrechen');
}
54 changes: 54 additions & 0 deletions frontend/cypress/e2e/scoring.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import * as users from '../fixtures/users.json';
import { getPercentageMetric, getPercentageOrdinal } from 'cypress/support/scoringSupport';
import { onlyOn } from '@cypress/skip-test';

describe('Scoring component e2e tests', () => {
beforeEach(() => {
cy.loginAsUser(users.gl);
onlyOn('chrome');
cy.visit('/?quarter=2');
});

[
[0, 100, 10],
[0, 100, 31],
[0, 100, 71],
[0, 100, 100],
].forEach(([baseline, stretchgoal, value]) => {
it('Create metric checkin and validate value of scoring component', () => {
cy.createMetricKeyresult('Metric scoring keyresult', String(baseline), String(stretchgoal));
cy.getByTestId('keyresult').get(':contains("Metric scoring keyresult")').last().click();
cy.getByTestId('add-check-in').click();
cy.getByTestId('key-result-metric-value').clear().type(String(value));
cy.getByTestId('confidence-slider').click();
cy.realPress('{rightarrow}').realPress('{rightarrow}').realPress('{rightarrow}');
cy.getByTestId('check-in-next').click();
cy.getByTestId('changeInfo').click().type('Testveränderungen');
cy.getByTestId('initiatives').click().type('Testmassnahmen');
cy.getByTestId('create-checkin').click();
const percentage = getPercentageMetric(baseline, stretchgoal, value);
cy.validateScoring(false, percentage);
cy.getByTestId('close-drawer').click();
cy.validateScoring(true, percentage);
});
});

[['fail'], ['commit'], ['target'], ['stretch']].forEach(([zoneName]) => {
it('Create ordinal checkin and validate value of scoring component', () => {
cy.createOrdinalKeyresult('Ordinal scoring keyresult', null);
cy.getByTestId('keyresult').get(':contains("Ordinal scoring keyresult")').last().click();
cy.getByTestId('add-check-in').click();
cy.getByTestId(`${zoneName}-radio`).click();
cy.getByTestId('confidence-slider').click();
cy.realPress('{rightarrow}').realPress('{rightarrow}').realPress('{rightarrow}');
cy.getByTestId('check-in-next').click();
cy.getByTestId('changeInfo').click().type('Testveränderungen');
cy.getByTestId('initiatives').click().type('Testmassnahmen');
cy.getByTestId('create-checkin').click();
const percentage = getPercentageOrdinal(zoneName);
cy.validateScoring(false, percentage);
cy.getByTestId('close-drawer').click();
cy.validateScoring(true, percentage);
});
});
});
94 changes: 90 additions & 4 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { validateScoring } from './scoringSupport';

Cypress.Commands.add('loginAsUser', (user: any) => {
loginWithCredentials(user.username, user.password);
overviewIsLoaded();
Expand All @@ -10,6 +12,14 @@ Cypress.Commands.add('getByTestId', { prevSubject: 'optional' }, (subject: any,
return cy.get(`[data-testId=${testId}]`);
});

Cypress.Commands.add('getZone', (zone: string, onOverview: boolean) => {
return (onOverview ? cy.focused() : cy.getByTestId('side-panel')).getByTestId(zone);
});

Cypress.Commands.add('validateScoring', (isOverview: boolean, percentage: number) => {
validateScoring(isOverview, percentage);
});

Cypress.Commands.add(
'fillOutObjective',
(
Expand Down Expand Up @@ -60,16 +70,16 @@ Cypress.Commands.add(
) => {
switch (currentZoneIndex) {
case 0:
cy.getByTestId('failZone').click();
cy.getByTestId('fail-radio').click();
break;
case 1:
cy.getByTestId('commitZone').click();
cy.getByTestId('commit-radio').click();
break;
case 2:
cy.getByTestId('targetZone').click();
cy.getByTestId('target-radio').click();
break;
case 3:
cy.getByTestId('stretchZone').click();
cy.getByTestId('stretch-radio').click();
break;
}
changeConfidence(shouldChangeConfidence);
Expand Down Expand Up @@ -100,6 +110,82 @@ Cypress.Commands.add('tabBackwardUntil', (selector: string, limit?: number) => {
doUntil(selector, cy.tabBackward, limit);
});

Cypress.Commands.add('createOrdinalKeyresult', (title: string | null = null, owner: string | null = null) => {
cy.getByTestId('objective').first().getByTestId('add-keyResult').first().click();
cy.getByTestId('submit').should('be.disabled');
cy.contains('Key Result erfassen');
cy.contains('Jaya Norris');
cy.contains('Titel');
cy.getByTestId('titleInput').type('Title');
cy.getByTestId('ordinalTab').click();
cy.contains('Metrisch');
cy.contains('Ordinal');
cy.contains('Commit Zone');
cy.contains('Target Zone');
cy.contains('Stretch Zone');
cy.contains('Owner');
cy.contains('Beschreibung (optional)');
cy.contains('Action Plan (optional)');
cy.contains('Weitere Action hinzufügen');
cy.contains('Speichern');
cy.contains('Abbrechen');

cy.fillOutKeyResult(
title == null ? 'I am a ordinal keyresult' : title,
null,
null,
null,
'My commit zone',
'My target zone',
'My stretch zone',
owner,
'This is my description',
);

cy.getByTestId('submit').should('not.be.disabled');
cy.getByTestId('submit').click();
});

Cypress.Commands.add(
'createMetricKeyresult',
(title: string | null, baseline: string | null, stretchGoal: string | null) => {
cy.getByTestId('objective').first().getByTestId('add-keyResult').first().click();
cy.getByTestId('submit').should('be.disabled');
cy.contains('Key Result erfassen');
cy.contains('Jaya Norris');
cy.checkForDialogText();

cy.fillOutKeyResult(
title == null ? 'I am a metric keyresult' : title,
'PERCENT',
baseline === null ? '21' : baseline,
stretchGoal === null ? '52' : stretchGoal,
null,
null,
null,
'Pac',
'This is my description',
);
cy.getByTestId('submit').should('not.be.disabled');
cy.getByTestId('submit').click();
},
);

Cypress.Commands.add('checkForDialogText', () => {
cy.contains('Titel');
cy.contains('Metrisch');
cy.contains('Ordinal');
cy.contains('Einheit');
cy.contains('Baseline');
cy.contains('Stretch Goal');
cy.contains('Owner');
cy.contains('Beschreibung (optional)');
cy.contains('Action Plan (optional)');
cy.contains('Weitere Action hinzufügen');
cy.contains('Speichern');
cy.contains('Abbrechen');
});

Cypress.Commands.add(
'fillOutKeyResult',
(
Expand Down
5 changes: 5 additions & 0 deletions frontend/cypress/support/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ declare global {
tabBackward(): void;
tabForwardUntil(selector: string, limit?: number): void;
tabBackwardUntil(selector: string, limit?: number): void;
createOrdinalKeyresult(title: string | null, owner: string | null): void;
createMetricKeyresult(title: string | null, baseline: string | null, stretchGoal: string | null): void;
getZone(zone: string, onOverview: boolean): Chainable;
validateScoring(isOverview: boolean, percentage: number): Chainable;
checkForDialogText(): void;
fillOutObjective(
objectiveTitle: string,
button: string,
Expand Down
Loading
Loading