Skip to content

Commit

Permalink
add test to test delete action
Browse files Browse the repository at this point in the history
  • Loading branch information
nevio18324 committed Nov 7, 2024
1 parent 4f75641 commit 518efb8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
3 changes: 1 addition & 2 deletions frontend/cypress/e2e/crud.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ describe('CRUD operations', () => {

it(`Delete existing objective`, () => {
cy.get('.objective').first().getByTestId('three-dot-menu').click();
cy.get('.mat-mdc-menu-content').contains('Objective bearbeiten').click();
cy.getByTestId('delete').click();
cy.get('.mat-mdc-menu-content').contains('Objective löschen').click();
cy.get("button[type='submit']").contains('Ja').click();
});

Expand Down
18 changes: 18 additions & 0 deletions frontend/cypress/e2e/objective.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ describe('OKR Objective e2e tests', () => {
.getByTestId('objective-state')
.should('have.attr', 'src', `assets/icons/successful-icon.svg`);
});
it.only('delete objective with success', () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('We want to delete this objective', 'safe', undefined, '', false);
cy.getByTestId('objective')
.filter(':contains("We want to delete this objective")')
.last()
.getByTestId('three-dot-menu')
.click()
.get('.objective-menu-option')
.contains('Objective löschen')
.click();
cy.contains('Objective löschen').should('exist');
cy.contains(
'Möchtest du dieses Objective wirklich löschen? Zugehörige Key Results werden dadurch ebenfalls gelöscht!',
);
cy.getByTestId('confirm-yes').click();
cy.get('We want to delete this objective').should('not.exist');
});

it(`Complete Objective with Not-Successful`, () => {
cy.getByTestId('add-objective').first().click();
Expand Down
22 changes: 8 additions & 14 deletions frontend/cypress/e2e/tab.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,19 @@ describe('Tab workflow tests', () => {
createNewObjectiveWithTab();
});

it('Delete objective with tab', () => {
it.only('Delete objective with tab', () => {
createNewObjectiveWithTab();
cy.wait(500);
cy.get('.objective').last().focus();
cy.tabForwardUntil('[data-testId="three-dot-menu"]');
cy.focused().realPress('Enter');
cy.focused().contains('Objective bearbeiten');
cy.realPress('ArrowDown');
cy.realPress('ArrowDown');
cy.realPress('ArrowDown');
cy.realPress('ArrowDown');
cy.focused().contains('Objective löschen');
cy.realPress('Enter');
cy.contains('bearbeiten');
cy.tabForwardUntil('[data-testId="delete"]');
cy.focused().contains('Objective Löschen');
cy.realPress('Enter');
cy.wait(500);
cy.tabForward();
cy.contains('Objective löschen');
cy.focused().contains('Ja');
cy.tabForwardUntil('[data-testId="confirm-yes"]');
cy.realPress('Enter');
});

Expand Down Expand Up @@ -328,10 +325,7 @@ describe('Tab workflow tests', () => {
cy.wait(500);
cy.tabForwardUntil('[data-testId="edit-keyResult"]');
cy.focused().contains('Key Result bearbeiten');
cy.realPress('Enter');
cy.wait(500);
cy.tabForwardUntil('[data-testId="delete-keyResult"]');
cy.focused().contains('Key Result löschen');

cy.realPress('Enter');
cy.wait(500);
cy.tabForward();
Expand Down

0 comments on commit 518efb8

Please sign in to comment.