Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ajuvonen committed Jan 17, 2024
1 parent e259ba2 commit 2e6a012
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 13 deletions.
53 changes: 48 additions & 5 deletions cypress/e2e/schedule.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ describe('Schedule tests', () => {
cy.visit('/').getByTestId('navbar-schedule-link').click();
cy.get('.schedule-settings__icon-container input:checked')
.should('exist')
.getByTestId('schedule-settings-toggle-all-activities').find('input')
.getByTestId('schedule-settings-toggle-all-activities')
.find('input')
.click();
cy.get('.schedule-settings__icon-container input:checked')
.should('not.exist')
Expand All @@ -18,16 +19,16 @@ describe('Schedule tests', () => {
.getByTestId('schedule-settings-start-of-week-sunday')
.click();
cy.getByTestId('week-0-calendar-tab-0')
.should('contain.text', 'Sunday')
.getByTestId('week-0-calendar-tab-0')
.should('contain.text', 'Sunday')
.getByTestId('week-0-add-training-button')
.click();
cy.getByTestId('edit-training-activity').click();
cy.get('.v-list-item').should('have.length', 2);
cy.get('.v-list-item').first()
cy.get('.v-list-item')
.first()
.should('contain.text', 'Badminton')
.get('.v-list-item').last()
.get('.v-list-item')
.last()
.should('contain.text', 'Walking')
.getByTestId('edit-training-duration')
.find('.v-text-field__suffix')
Expand Down Expand Up @@ -60,6 +61,31 @@ describe('Schedule tests', () => {
cy.get('.simple-training-card__duration').should('contain.text', '90 m');
});

it('date settings work', () => {
cy.visit('/').getByTestId('navbar-schedule-link').click();
cy.getByTestId('schedule-settings-start-date-input').find('input').should('have.value', '');
cy.getByTestId('schedule-settings-week-numbering-assigned').should('not.exist');
cy.getByTestId('schedule-settings-week-numbering-actual').should('not.exist');
cy.getByTestId('schedule-settings-default-start-time-input').should('not.exist');
cy.getByTestId('schedule-settings-start-date-input').click();
cy.get('.dp__calendar_item:not([aria-disabled])').last().click();
cy.getByTestId('schedule-settings-start-date-input').find('input').invoke('val').as('date');
cy.getByTestId('schedule-settings-week-numbering-assigned').should('exist');
cy.getByTestId('schedule-settings-week-numbering-actual').should('exist');
cy.getByTestId('schedule-settings-default-start-time-input').should('exist');
cy.getByTestId('schedule-settings-default-start-time-input')
.find('input')
.should('have.value', '12:00');
cy.get('@date').then((date) => {
cy.getByTestId('schedule-settings-start-of-week-sunday').click();
cy.getByTestId('schedule-settings-start-date-input')
.find('input')
.should('not.have.value', date);
cy.getByTestId('schedule-settings-start-of-week-monday').click();
cy.getByTestId('schedule-settings-start-date-input').find('input').should('have.value', date);
});
});

it('adds new trainings', () => {
cy.visit('/').getByTestId('navbar-schedule-link').click();
cy.getByTestId('schedule-settings-add-week-button').click();
Expand All @@ -80,4 +106,21 @@ describe('Schedule tests', () => {
cy.getByTestId('week-0-delete-button').click();
cy.getByTestId('schedule').should('not.exist');
});

it('copies and moves trainings', () => {
cy.visit('/').getByTestId('navbar-schedule-link').click();
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').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');
});
});
1 change: 1 addition & 0 deletions src/components/ActionMenuWeekGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const menuIcon = props.action === 'move' ? 'mdi-arrow-all' : 'mdi-content-copy';
v-bind="props"
:title="$t(`trainingCard.${action}`)"
:prepend-icon="menuIcon"
:class="`training-card__${action}-button`"
/>
</template>
<v-list-group v-for="(week, weekIndex) in weeks" :key="week.id">
Expand Down
1 change: 1 addition & 0 deletions src/components/ScheduleSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ const [duration, durationErrors] = useValidatedRef(settings, 'defaultDuration',
variant="underlined"
readonly
hide-details
data-test-id="schedule-settings-default-start-time-input"
@keyup.enter="openMenu"
></v-text-field>
</template>
Expand Down
4 changes: 2 additions & 2 deletions src/components/__tests__/WeekSupplement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {v4 as uuidv4} from 'uuid';
import {Intensity, type Training} from '@/types';
import WeekSupplement from '@/components/WeekSupplement.vue';

const trainings = [
const trainings: Training[] = [
{
id: uuidv4(),
weekId: uuidv4(),
Expand All @@ -17,7 +17,7 @@ const trainings = [
completionSummary: '',
location: 'Total wreck gym',
},
] as Training[];
];

describe('WeekSupplement', () => {
it('mounts', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,17 @@ exports[`ScheduleSettings > mounts 1`] = `
<!----><i data-v-76426b41="" class="mdi-boxing-glove mdi v-icon notranslate v-theme--light v-icon--size-large" aria-hidden="true"></i> Boxing
</label>
</div>
<div data-v-76426b41="" class="schedule-settings__icon-container d-inline-flex">
<div data-v-76426b41="" class="v-selection-control v-selection-control--dirty v-selection-control--density-default v-checkbox-btn flex-grow-0">
<div class="v-selection-control__wrapper">
<!---->
<div class="v-selection-control__input"><i class="mdi-checkbox-marked mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i><input id="schedule-settings-activity-cycling" aria-disabled="false" type="checkbox" value="cycling"></div>
</div>
<!---->
</div><label data-v-76426b41="" class="v-label flex-grow-1" for="schedule-settings-activity-cycling">
<!----><i data-v-76426b41="" class="mdi-bike-fast mdi v-icon notranslate v-theme--light v-icon--size-large" aria-hidden="true"></i> Cycling
</label>
</div>
<div data-v-76426b41="" class="schedule-settings__icon-container d-inline-flex">
<div data-v-76426b41="" class="v-selection-control v-selection-control--dirty v-selection-control--density-default v-checkbox-btn flex-grow-0">
<div class="v-selection-control__wrapper">
Expand All @@ -335,6 +346,17 @@ exports[`ScheduleSettings > mounts 1`] = `
<!----><i data-v-76426b41="" class="mdi-dumbbell mdi v-icon notranslate v-theme--light v-icon--size-large" aria-hidden="true"></i> Gym
</label>
</div>
<div data-v-76426b41="" class="schedule-settings__icon-container d-inline-flex">
<div data-v-76426b41="" class="v-selection-control v-selection-control--dirty v-selection-control--density-default v-checkbox-btn flex-grow-0">
<div class="v-selection-control__wrapper">
<!---->
<div class="v-selection-control__input"><i class="mdi-checkbox-marked mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i><input id="schedule-settings-activity-gymnastics" aria-disabled="false" type="checkbox" value="gymnastics"></div>
</div>
<!---->
</div><label data-v-76426b41="" class="v-label flex-grow-1" for="schedule-settings-activity-gymnastics">
<!----><i data-v-76426b41="" class="mdi-gymnastics mdi v-icon notranslate v-theme--light v-icon--size-large" aria-hidden="true"></i> Gymnastics
</label>
</div>
<div data-v-76426b41="" class="schedule-settings__icon-container d-inline-flex">
<div data-v-76426b41="" class="v-selection-control v-selection-control--dirty v-selection-control--density-default v-checkbox-btn flex-grow-0">
<div class="v-selection-control__wrapper">
Expand All @@ -361,22 +383,33 @@ exports[`ScheduleSettings > mounts 1`] = `
<div data-v-76426b41="" class="v-selection-control v-selection-control--dirty v-selection-control--density-default v-checkbox-btn flex-grow-0">
<div class="v-selection-control__wrapper">
<!---->
<div class="v-selection-control__input"><i class="mdi-checkbox-marked mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i><input id="schedule-settings-activity-meditation" aria-disabled="false" type="checkbox" value="meditation"></div>
<div class="v-selection-control__input"><i class="mdi-checkbox-marked mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i><input id="schedule-settings-activity-running" aria-disabled="false" type="checkbox" value="running"></div>
</div>
<!---->
</div><label data-v-76426b41="" class="v-label flex-grow-1" for="schedule-settings-activity-meditation">
<!----><i data-v-76426b41="" class="mdi-meditation mdi v-icon notranslate v-theme--light v-icon--size-large" aria-hidden="true"></i> Meditation
</div><label data-v-76426b41="" class="v-label flex-grow-1" for="schedule-settings-activity-running">
<!----><i data-v-76426b41="" class="mdi-run mdi v-icon notranslate v-theme--light v-icon--size-large" aria-hidden="true"></i> Running
</label>
</div>
<div data-v-76426b41="" class="schedule-settings__icon-container d-inline-flex">
<div data-v-76426b41="" class="v-selection-control v-selection-control--dirty v-selection-control--density-default v-checkbox-btn flex-grow-0">
<div class="v-selection-control__wrapper">
<!---->
<div class="v-selection-control__input"><i class="mdi-checkbox-marked mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i><input id="schedule-settings-activity-running" aria-disabled="false" type="checkbox" value="running"></div>
<div class="v-selection-control__input"><i class="mdi-checkbox-marked mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i><input id="schedule-settings-activity-shooting" aria-disabled="false" type="checkbox" value="shooting"></div>
</div>
<!---->
</div><label data-v-76426b41="" class="v-label flex-grow-1" for="schedule-settings-activity-running">
<!----><i data-v-76426b41="" class="mdi-run mdi v-icon notranslate v-theme--light v-icon--size-large" aria-hidden="true"></i> Running
</div><label data-v-76426b41="" class="v-label flex-grow-1" for="schedule-settings-activity-shooting">
<!----><i data-v-76426b41="" class="mdi-bullseye-arrow mdi v-icon notranslate v-theme--light v-icon--size-large" aria-hidden="true"></i> Shooting
</label>
</div>
<div data-v-76426b41="" class="schedule-settings__icon-container d-inline-flex">
<div data-v-76426b41="" class="v-selection-control v-selection-control--dirty v-selection-control--density-default v-checkbox-btn flex-grow-0">
<div class="v-selection-control__wrapper">
<!---->
<div class="v-selection-control__input"><i class="mdi-checkbox-marked mdi v-icon notranslate v-theme--light v-icon--size-default" aria-hidden="true"></i><input id="schedule-settings-activity-skating" aria-disabled="false" type="checkbox" value="skating"></div>
</div>
<!---->
</div><label data-v-76426b41="" class="v-label flex-grow-1" for="schedule-settings-activity-skating">
<!----><i data-v-76426b41="" class="mdi-skate mdi v-icon notranslate v-theme--light v-icon--size-large" aria-hidden="true"></i> Skating
</label>
</div>
<div data-v-76426b41="" class="schedule-settings__icon-container d-inline-flex">
Expand Down

0 comments on commit 2e6a012

Please sign in to comment.