Skip to content

Commit

Permalink
added a cypress test for the dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Ruf committed Jan 10, 2024
1 parent 0c120d6 commit 4fb6e84
Showing 1 changed file with 79 additions and 2 deletions.
81 changes: 79 additions & 2 deletions tests/e2e/cypress/e2e/Dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,84 @@ describe('Test Dashboard View', () => {
.parent()
.parent()
.find('[data-cy="mealCheckbox"]')
.should('exist');
// cy.get('[data-cy="mealCheckbox"]').click();
.eq(0)
.then((ele) => {
// if ele has children, the meal is booked
if (ele.children().length > 0) {
// cancel meal
cy.get('h2')
.contains('Nächste Woche')
.parent()
.parent()
.find('[data-cy="mealCheckbox"]')
.eq(0)
.click();

cy.wait(1000);
cy.get('h2')
.contains('Nächste Woche')
.parent()
.parent()
.find('[data-cy="mealCheckbox"]')
.eq(0)
.children()
.should('have.length', 0)

cy.get('h2')
.contains('Nächste Woche')
.parent()
.parent()
.find('[data-cy="mealCheckbox"]')
.eq(0)
.click();

cy.wait(1000);
cy.get('h2')
.contains('Nächste Woche')
.parent()
.parent()
.find('[data-cy="mealCheckbox"]')
.eq(0)
.children()
.should('have.length', 1)
} else {
// book meal
cy.get('h2')
.contains('Nächste Woche')
.parent()
.parent()
.find('[data-cy="mealCheckbox"]')
.eq(0)
.click();

cy.wait(1000);
cy.get('h2')
.contains('Nächste Woche')
.parent()
.parent()
.find('[data-cy="mealCheckbox"]')
.eq(0)
.children()
.should('have.length', 1)

cy.get('h2')
.contains('Nächste Woche')
.parent()
.parent()
.find('[data-cy="mealCheckbox"]')
.eq(0)
.click();

cy.wait(1000);
cy.get('h2')
.contains('Nächste Woche')
.parent()
.parent()
.find('[data-cy="mealCheckbox"]')
.eq(0)
.children()
.should('have.length', 0)
}
});
});
});

0 comments on commit 4fb6e84

Please sign in to comment.