From 49e6d3cdf8eb4d1e791af4b71f08f7e058e70f31 Mon Sep 17 00:00:00 2001 From: ajuvonen Date: Fri, 9 Feb 2024 11:24:55 +0200 Subject: [PATCH] Test training rating functionality --- cypress/e2e/schedule.cy.ts | 27 ++++++++++++ src/components/TrainingRating.vue | 2 +- src/components/__tests__/TrainingCard.spec.ts | 2 + .../__tests__/TrainingRating.spec.ts | 42 +++++++++++++++++++ .../__snapshots__/TrainingRating.spec.ts.snap | 25 +++++++++++ 5 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 src/components/__tests__/TrainingRating.spec.ts create mode 100644 src/components/__tests__/__snapshots__/TrainingRating.spec.ts.snap diff --git a/cypress/e2e/schedule.cy.ts b/cypress/e2e/schedule.cy.ts index c97be9e..83c250b 100644 --- a/cypress/e2e/schedule.cy.ts +++ b/cypress/e2e/schedule.cy.ts @@ -63,4 +63,31 @@ describe('Schedule tests', () => { cy.toRoute('schedule'); cy.getByTestId('week-0').should('not.exist'); }); + + it('completes and rates trainings', () => { + cy.addTraining(); + cy.get('.training-card__action-button').click(); + cy.get('.training-card__complete-button').click(); + cy.get('.training-card__rating button:nth-child(1) i').should('have.class', 'mdi-star-outline'); + cy.get('.training-card__rating button:nth-child(2) i').should('have.class', 'mdi-star-outline'); + cy.get('.training-card__rating button:nth-child(3) i').should('have.class', 'mdi-star-outline'); + cy.get('.training-card__rating button:nth-child(4) i').should('have.class', 'mdi-star-outline'); + cy.get('.training-card__rating button:nth-child(5) i').should('have.class', 'mdi-star-outline'); + cy.get('.training-card__rating button').eq(0).click(); + cy.get('.training-card__rating button:nth-child(1) i').should('have.class', 'mdi-star'); + cy.get('.training-card__rating button').eq(1).click(); + cy.get('.training-card__rating button:nth-child(2) i').should('have.class', 'mdi-star'); + cy.get('.training-card__rating button').eq(2).click(); + cy.get('.training-card__rating button:nth-child(3) i').should('have.class', 'mdi-star'); + cy.get('.training-card__rating button').eq(3).click(); + cy.get('.training-card__rating button:nth-child(4) i').should('have.class', 'mdi-star'); + cy.get('.training-card__rating button').eq(4).click(); + cy.get('.training-card__rating button:nth-child(5) i').should('have.class', 'mdi-star'); + cy.get('.training-card__rating button').eq(4).click(); + cy.get('.training-card__rating button:nth-child(1) i').should('have.class', 'mdi-star-outline'); + cy.get('.training-card__rating button:nth-child(2) i').should('have.class', 'mdi-star-outline'); + cy.get('.training-card__rating button:nth-child(3) i').should('have.class', 'mdi-star-outline'); + cy.get('.training-card__rating button:nth-child(4) i').should('have.class', 'mdi-star-outline'); + cy.get('.training-card__rating button:nth-child(5) i').should('have.class', 'mdi-star-outline'); + }); }); diff --git a/src/components/TrainingRating.vue b/src/components/TrainingRating.vue index f8dce97..e1e61a7 100644 --- a/src/components/TrainingRating.vue +++ b/src/components/TrainingRating.vue @@ -20,7 +20,7 @@ const baseAttributes = computed(() => (rating: Rating) => ({ }));