Skip to content

Commit

Permalink
Make command global and delete unused definitions of it
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelMoeri committed Jan 22, 2025
1 parent 5f3ff49 commit dd389b4
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 32 deletions.
6 changes: 3 additions & 3 deletions frontend/cypress/e2e/check-in.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,14 @@ describe('okr check-in', () => {
it('should have primary button on all check-in dialogs', () => {
keyResultDetailPage.visit('Very important keyresult')
.createCheckIn()
.checkForPrimaryButton('submit-check-in')
.run(cy.checkForPrimaryButton('submit-check-in'))
.cancel();

keyResultDetailPage
.showAllCheckIns()
.checkForPrimaryButton('closeButton')
.run(cy.checkForPrimaryButton('closeButton'))
.editLatestCheckIn()
.checkForPrimaryButton('submit-check-in')
.run(cy.checkForPrimaryButton('submit-check-in'))
.cancel();
});
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/key-result.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,13 @@ describe('okr key-result', () => {
.addKeyResult()
.fillKeyResultTitle('A keyResult for testing purposes')
.withOrdinalValues('My commit zone', 'My target zone', 'My stretch goal')
.checkForPrimaryButton('submit')
.run(cy.checkForPrimaryButton('submit'))
.submit();

keyResultDetailPage
.visit('A keyResult for testing purposes')
.editKeyResult()
.checkForPrimaryButton('submit')
.run(cy.checkForPrimaryButton('submit'))
.cancel();
});
});
19 changes: 11 additions & 8 deletions frontend/cypress/e2e/objective.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,45 +271,48 @@ describe('okr objective', () => {
overviewPage
.addObjective()
.fillObjectiveTitle('A objective for testing purposes')
.checkForPrimaryButton('save-draft')
.run(cy.checkForPrimaryButton('save-draft'))
.submit();

overviewPage
.openThreeDotMenuOfObjective('A objective for testing purposes')
.selectFromThreeDotMenu('Objective bearbeiten');
ObjectiveDialog.do()
.checkForPrimaryButton('save')
.run(cy.checkForPrimaryButton('save'))
.cancel();

overviewPage
.openThreeDotMenuOfObjective('A objective for testing purposes')
.selectFromThreeDotMenu('Objective abschliessen');
cy.getByTestId('successful')
.click();
cy.getByTestId('submit')
.should('have.attr', 'color', 'primary')
.and('have.attr', 'mat-flat-button');
cy.checkForPrimaryButton('submit');
cy.getByTestId('cancel')
.click();

overviewPage
.openThreeDotMenuOfObjective('A objective for testing purposes')
.selectFromThreeDotMenu('Objective als Draft speichern');
ConfirmDialog.do()
.checkForPrimaryButton()
.run(cy.checkForPrimaryButton('confirm-yes'))
.cancel();

overviewPage
.openThreeDotMenuOfObjective('A objective for testing purposes')
.selectFromThreeDotMenu('Objective löschen');
ConfirmDialog.do()
.checkForPrimaryButton()
.run(cy.checkForPrimaryButton('confirm-yes'))
.cancel();

overviewPage
.duplicateObjective('A objective for testing purposes')
.checkForPrimaryButton('save')
.run(cy.checkForPrimaryButton('save'))
.cancel();

overviewPage
.getObjectiveByName('A objective for testing purposes')
.click();
cy.checkForPrimaryButton('add-key-result-objective-detail');
});
});

Expand Down
10 changes: 5 additions & 5 deletions frontend/cypress/e2e/team-management.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,19 +356,19 @@ describe('okr team-management', () => {
teamManagementPage.elements.registerMember()
.click();
InviteMembersDialog.do()
.checkForPrimaryButton('invite')
.run(cy.checkForPrimaryButton('invite'))
.close();

teamManagementPage
.addTeam()
.fillName('Our newest team')
.checkForPrimaryButton('save')
.fillName('Our newest team');
cy.checkForPrimaryButton('save')
.submit();
cy.wait('@addTeam');

cy.getByTestId('editTeamButton')
.click();
checkForPrimaryButton('save');
cy.checkForPrimaryButton('save');
cy.getByTestId('cancel')
.click();

Expand All @@ -379,7 +379,7 @@ describe('okr team-management', () => {
cy.get('span')
.contains('Paco Eggimann')
.click();
checkForPrimaryButton('save');
cy.checkForPrimaryButton('save');
cy.getByTestId('close-dialog')
.click();
});
Expand Down
6 changes: 6 additions & 0 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ Cypress.Commands.add('validateScoring', (isOverview: boolean, percentage: number
validateScoring(isOverview, percentage);
});

Cypress.Commands.add('checkForPrimaryButton', (submitButtonId: string) => {
cy.getByTestId(submitButtonId)
.should('have.attr', 'color', 'primary')
.and('have.attr', 'mat-flat-button');
});

function loginWithCredentials(username: string, password: string) {
cy.visit('/');
cy.intercept('GET', '**/users/current')
Expand Down
1 change: 1 addition & 0 deletions frontend/cypress/support/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ declare global {
loginAsUser(user: any): Chainable;
logout(): void;
getByTestId(testsId: string, text?: string): Chainable;
checkForPrimaryButton(submitButtonId: string): Chainable;
findByTestId(testId: string, text?: string): Chainable;
pressUntilContains(text: string, key: keyof typeof keyCodeDefinitions): void;
tabForward(): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ export default class ConfirmDialog extends Dialog {
.click();
}

checkForPrimaryButton() {
cy.getByTestId('confirm-yes')
.should('have.attr', 'color', 'primary')
.and('have.attr', 'mat-flat-button');
return this;
}

getPage(): Chainable {
return cy.get('app-confirm-dialog');
}
Expand Down
7 changes: 0 additions & 7 deletions frontend/cypress/support/helper/dom-helper/dialogs/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ export default abstract class Dialog extends PageObjectMapperBase {
.click();
}

checkForPrimaryButton(submitButtonId: string) {
cy.getByTestId(submitButtonId)
.should('have.attr', 'color', 'primary')
.and('have.attr', 'mat-flat-button');
return this;
}

protected fillInputByTestId(testId: string, value: string) {
const elem = cy.getByTestId(testId);
this.fillInput(elem, value);
Expand Down

0 comments on commit dd389b4

Please sign in to comment.