From b6a242bc15e5ea79b10b7db45448716ef8433dc4 Mon Sep 17 00:00:00 2001 From: ajuvonen Date: Tue, 11 Jun 2024 17:00:56 +0300 Subject: [PATCH] Add possibility to copy and move to new week --- cypress/e2e/schedule.cy.ts | 23 +++++++++---- cypress/support/commands.ts | 1 + .../TrainingCardActionsMenuGroup.vue | 33 +++++++++++++++---- .../__snapshots__/ScheduleView.spec.ts.snap | 2 +- .../__tests__/scheduleStore.spec.ts | 15 +++++++++ src/i18n/en.json | 1 + src/i18n/fi.json | 1 + src/stores/schedule.ts | 7 ++-- src/views/ScheduleView.vue | 12 ++----- 9 files changed, 69 insertions(+), 26 deletions(-) diff --git a/cypress/e2e/schedule.cy.ts b/cypress/e2e/schedule.cy.ts index 034ad57..eae897c 100644 --- a/cypress/e2e/schedule.cy.ts +++ b/cypress/e2e/schedule.cy.ts @@ -17,6 +17,7 @@ describe('Schedule tests', () => { cy.getByTestId('week-1-day-1').find('.training-card').should('exist'); cy.getByTestId('week-0').click(); cy.getByTestId('week-0-delete-button').click(); + cy.getByTestId('week-0').click(); cy.getByTestId('week-0-delete-button').click(); cy.getByTestId('confirm-dialog-confirm-button').click(); cy.getByTestId('schedule').should('not.exist'); @@ -25,17 +26,25 @@ describe('Schedule tests', () => { it('copies and moves trainings', () => { cy.addTraining(); cy.get('.training-card__action-button').click(); - cy.get('.training-card__copy-button').click(); - cy.get('.training-card__copy-button + .v-list-group__items').click(); - cy.get('.training-card__copy-button + .v-list-group__items .v-list-item').eq(2).click(); - cy.get('.training-card__move-button').click(); - cy.get('.training-card__move-button + .v-list-group__items').click(); - cy.get('.training-card__move-button + .v-list-group__items .v-list-item').eq(3).click(); + cy.get('.training-card-actions__copy').contains('Copy').click(); + cy.get('.training-card-actions__copy').contains('Week 1').click(); + cy.get('.training-card-actions__copy').contains('Tuesday').click(); + cy.get('.training-card-actions__move').contains('Move').click(); + cy.get('.training-card-actions__move').contains('Week 1').click(); + cy.get('.training-card-actions__move').contains('Wednesday').click(); cy.get('.training-card').should('not.exist'); cy.getByTestId('week-0-calendar-tab-1').click(); cy.get('.training-card').should('exist'); cy.getByTestId('week-0-calendar-tab-2').click(); cy.get('.training-card').should('exist'); + cy.get('.training-card__action-button:visible').click(); + cy.get('.training-card-actions__copy').contains('Copy').click(); + cy.get('.training-card-actions__copy').contains('New Week').click(); + cy.get('.training-card-actions__copy .v-list-item:visible').contains('Monday').click(); + cy.getByTestId('week-1').should('exist'); + cy.getByTestId('schedule').contains('Week 2').click({force: true}); + cy.getByTestId('week-1-calendar-tab-0').click(); + cy.getByTestId('week-1-day-0').find('.training-card').should('exist'); }); it('resets schedule', () => { @@ -51,7 +60,7 @@ describe('Schedule tests', () => { cy.getByTestId('week-0').should('not.exist'); }); - it.only('completes and rates trainings', () => { + it('completes and rates trainings', () => { cy.addTraining(); cy.get('.training-card__action-button').click(); cy.get('.training-card__complete-button').click(); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index b215bfb..01fb1a8 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -20,6 +20,7 @@ Cypress.Commands.add('addTraining', (addWeek = true) => { if (addWeek) { cy.toRoute('schedule'); cy.getByTestId('schedule-add-week-button').click(); + cy.getByTestId('week-0').click(); } cy.getByTestId('week-0-add-training-button').click(); cy.getByTestId('edit-training-activity').click(); diff --git a/src/components/TrainingCardActionsMenuGroup.vue b/src/components/TrainingCardActionsMenuGroup.vue index 253a33b..93659f0 100644 --- a/src/components/TrainingCardActionsMenuGroup.vue +++ b/src/components/TrainingCardActionsMenuGroup.vue @@ -1,8 +1,10 @@