Skip to content

Commit

Permalink
Move objective and keyresult getter methods from helper to overview p…
Browse files Browse the repository at this point in the history
…age, implement missing methods for keyresult dialog, start rewriting duplicated scoring tests
  • Loading branch information
RandomTannenbaum committed Nov 11, 2024
1 parent 9cf1e7f commit 69491b0
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 16 deletions.
18 changes: 12 additions & 6 deletions frontend/cypress/e2e/duplicated-scoring.cy.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import * as users from '../fixtures/users.json';
import { onlyOn } from '@cypress/skip-test';
import { filterByObjectiveName, getObjectiveColumns, selectFromThreeDotMenu } from '../support/helper/objective-helper';
import { filterByObjectiveName, getObjectiveColumns } from '../support/helper/objective-helper';
import CyOverviewPage from '../support/helper/pom-helper/pages/overviewPage';

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

beforeEach(() => {
op = new CyOverviewPage();
cy.loginAsUser(users.gl);
onlyOn('chrome');
cy.visit('/?quarter=2');
});

it('Create ordinal checkin and validate value of scoring component', () => {
cy.intercept('POST', '**/keyresults').as('createKeyresult');
cy.createOrdinalKeyresult('stretch keyresult for testing', null);
cy.wait('@createKeyresult');
op.addKeyresult('Puzzle ITC')
.fillKeyresultTitle('stretch keyresult for testing')
.withOrdinalValues('Ex. val', 'Ex. val', 'Ex. val')
.submit();

cy.contains('stretch keyresult for testing');
cy.getByTestId('keyresult').contains('stretch keyresult for testing').last().click();
op.getKeyresultByName('stretch keyresult for testing').click();
cy.getByTestId('add-check-in').click();
cy.getByTestId(`stretch-radio`).click();
cy.getByTestId('confidence-slider').click();
Expand All @@ -25,7 +31,7 @@ describe('e2e test for scoring adjustment on objective duplicate', () => {
cy.getByTestId('close-drawer').click({ force: true });

getObjectiveColumns().first().findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective duplizieren');
op.selectFromThreeDotMenu('Objective duplizieren');
cy.fillOutObjective('A duplicated Objective for this tool', 'safe', '3');
cy.visit('/?quarter=3');

Expand Down
11 changes: 11 additions & 0 deletions frontend/cypress/support/helper/keyresult-helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function filterByKeyresultName(keyresultName: string) {
return (index: number, element: HTMLElement) => byKeyresultName(element, keyresultName);
}

const byKeyresultName = (element: HTMLElement, keyresultName: string) => {
return Cypress.$(element).find(`:contains("${keyresultName}")`).length > 0;
};

export function getKeyresults() {
return cy.get('.key-result');
}
4 changes: 0 additions & 4 deletions frontend/cypress/support/helper/objective-helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export function getObjectivesByNameAndState(objectiveName: string, state: string) {
return getObjectiveColumns().filter(filterByObjectiveName(objectiveName)).filter(filterByObjectiveState(state));
}

export function filterByObjectiveName(objectiveName: string) {
return (index: number, element: HTMLElement) => byObjectiveName(element, objectiveName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,46 @@ export default class KeyResultDialog extends Dialog {
}

withMetricValues(unit: Unit, baseline: string, stretchGoal: string) {
cy.getByTestId('metricTab').click();
cy.getByTestId('unit').select(unit);
this.fillInput('baseline', baseline);
this.fillInput('stretchGoal', stretchGoal);
return this;
}

withOrdinalValues(commitZone: string, targetZone: string, stretchGoal: string) {
cy.getByTestId('ordinalTab').click();
this.fillInput('commitZone', commitZone);
this.fillInput('targetZone', targetZone);
this.fillInput('stretchZone', stretchGoal);
return this;
}

fillOwner(owner: string) {
this.fillInput('ownerInput', owner);
return this;
}

addActionPlanElement(action: string) {
cy.getByTestId('add-action-plan-line').click();
cy.getByTestId('actionInput')
.filter((k, el) => {
return (el as HTMLInputElement).value.trim() === '';
})
.first()
.type(action);
return this;
}

override submit() {
cy.getByTestId('submit').click();
}

saveAndNew() {
cy.getByTestId('saveAndNew').click();
}

getPage(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.get('app-objective-form');
return cy.get('app-key-result-form');
}
}
41 changes: 36 additions & 5 deletions frontend/cypress/support/helper/pom-helper/pages/overviewPage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { getObjectivesByNameAndState } from '../../objective-helper';
import { filterByObjectiveName, filterByObjectiveState, getObjectiveColumns } from '../../objective-helper';
import ObjectiveDialog from '../dialogs/objectiveDialog';
import { Page } from './page';
import KeyResultDialog from '../dialogs/keyResultDialog';
import { filterByKeyresultName, getKeyresults } from '../../keyresult-helper';

export default class CyOverviewPage extends Page {
elements = {
Expand Down Expand Up @@ -37,16 +39,45 @@ export default class CyOverviewPage extends Page {
return new ObjectiveDialog();
}

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();
}
cy.getByTestId('add-keyResult').first().click();
return new KeyResultDialog();
}

getTeamByName(teamName: string) {
return cy.contains(teamName).parentsUntil('.overview').last();
return cy.contains('.team-title', teamName).parentsUntil('#overview').last();
}

getObjectiveByNameAndState(objectiveName: string, state: string) {
return getObjectivesByNameAndState(objectiveName, state).first().scrollIntoView();
return this.getObjectivesByNameAndState(objectiveName, state).first().scrollIntoView();
}

getObjectivesByNameAndState(objectiveName: string, state: string) {
return getObjectiveColumns().filter(filterByObjectiveName(objectiveName)).filter(filterByObjectiveState(state));
}

getObjectiveByName(objectiveName: string) {
return this.getObjectivesByName(objectiveName).first().scrollIntoView();
}

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

getKeyresultByName(keyResultName: string) {
return this.getKeyresultsByName(keyResultName).last().scrollIntoView();
}

getObjectivesByNameAndState(objectiveName: string, string: string) {
return getObjectivesByNameAndState(objectiveName, string);
getKeyresultsByName(keyresultName: string) {
return getKeyresults().filter(filterByKeyresultName(keyresultName));
}

selectFromThreeDotMenu(optionName: string) {
Expand Down

0 comments on commit 69491b0

Please sign in to comment.