Skip to content

Commit

Permalink
Use aliases to not chain from cypress commands
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomTannenbaum committed Nov 19, 2024
1 parent d5b6581 commit 842b695
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
1 change: 0 additions & 1 deletion frontend/cypress/e2e/objective.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ describe('OKR Objective e2e tests', () => {

op.getObjectiveByNameAndState('he reopening of this objective will be canceled', 'successful')
.findByTestId('three-dot-menu')
.scrollIntoView()
.click();

op.selectFromThreeDotMenu('Objective wiedereröffnen');
Expand Down
28 changes: 15 additions & 13 deletions frontend/cypress/support/helper/pom-helper/pages/overviewPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,39 +64,46 @@ export default class CyOverviewPage extends Page {
}

getObjectiveByNameAndState(objectiveName: string, state: string) {
return this.getObjectivesByNameAndState(objectiveName, state).last().scrollIntoView();
this.getObjectivesByNameAndState(objectiveName, state).last().as('objective').scrollIntoView();
return cy.get('@objective');
}

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

getObjectiveByName(objectiveName: string) {
return this.getObjectivesByName(objectiveName).last().scrollIntoView();
this.getObjectivesByName(objectiveName).last().as('objective').scrollIntoView();
return cy.get('@objective');
}

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

return cy.get('@team');
}

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

getObjectiveByState(state: string) {
return this.getObjectivesByState(state).first().scrollIntoView();
this.getObjectivesByState(state).first().as('objective').scrollIntoView();
return cy.get('@objective');
}

getObjectivesByState(state: string) {
return getObjectiveColumns().filter(filterByObjectiveState(state));
}

getKeyResultByName(keyResultName: string) {
return this.getKeyResultsByName(keyResultName).last().scrollIntoView();
this.getKeyResultsByName(keyResultName).last().as('keyResult').scrollIntoView();
return cy.get('@keyResult');
}

getKeyResultsByName(keyresultName: string) {
Expand All @@ -105,14 +112,9 @@ export default class CyOverviewPage extends Page {

selectFromThreeDotMenu(optionName: string) {
cy.contains(optionName).should('exist');
const chainable = cy
.get('.objective-three-dot-menu')
.contains(optionName)
.scrollIntoView()
.then(() => {
chainable.should('have.class', 'objective-menu-option');
chainable.click();
});
cy.get('.objective-three-dot-menu').contains(optionName).as('option').scrollIntoView();

cy.get('@option').should('have.class', 'objective-menu-option').click();
}

duplicateObjective(objectiveName: string) {
Expand Down

0 comments on commit 842b695

Please sign in to comment.