From c1ed9782d70a1eeef4f5649c0ca79217138e8c10 Mon Sep 17 00:00:00 2001 From: Guido Quezada Date: Mon, 4 Jan 2021 16:25:32 -0500 Subject: [PATCH 1/2] TT-108 fix: edit the first running entry of the month after one hour --- .../components/month-picker/month-picker.component.spec.ts | 2 +- .../components/entry-fields/entry-fields.component.ts | 2 +- src/app/modules/time-clock/store/entry.effects.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts b/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts index d9160c8f3..94196e6b1 100644 --- a/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts +++ b/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts @@ -62,7 +62,7 @@ describe('MonthPickerComponent', () => { it('selectMonth should call selectDate', () => { spyOn(component, 'selectDate'); component.selectMonth(10); - expect(component.selectDate).toHaveBeenCalledWith(10, 2020); + expect(component.selectDate).toHaveBeenCalledWith(10, 2021); }); }); diff --git a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.ts b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.ts index d5327d8c1..f6160a48f 100644 --- a/src/app/modules/time-clock/components/entry-fields/entry-fields.component.ts +++ b/src/app/modules/time-clock/components/entry-fields/entry-fields.component.ts @@ -138,7 +138,7 @@ export class EntryFieldsComponent implements OnInit { return; } - const lastEntryStartDate = get(this.lastEntry, 'start_date', moment().subtract(1, 'hours')); + const lastEntryStartDate = get(this.lastEntry, 'start_date', moment(newHourEntered).subtract(1, 'minutes')); const isEntryDateInLastStartDate = moment(newHourEntered).isSameOrBefore(lastEntryStartDate); if (isEntryDateInLastStartDate) { this.toastrService.error('There is another time entry registered in this time range'); diff --git a/src/app/modules/time-clock/store/entry.effects.ts b/src/app/modules/time-clock/store/entry.effects.ts index 58aa988ad..43d73cc4f 100644 --- a/src/app/modules/time-clock/store/entry.effects.ts +++ b/src/app/modules/time-clock/store/entry.effects.ts @@ -232,7 +232,7 @@ export class EntryEffects { }).pipe( map((entries) => { const lastEntry = entries[1]; - const isStartTimeInLastEntry = moment(entry.start_date).isBefore(lastEntry.end_date); + const isStartTimeInLastEntry = lastEntry && moment(entry.start_date).isBefore(lastEntry.end_date); if (isStartTimeInLastEntry) { return new actions.UpdateEntry({ id: lastEntry.id, end_date: entry.start_date }); } else { From c12decfb8dcae479850ca3ef2671a9bfb283ab35 Mon Sep 17 00:00:00 2001 From: Guido Quezada Date: Tue, 5 Jan 2021 13:01:43 -0500 Subject: [PATCH 2/2] TT-108 fix: selectMonth should call selectDate test --- .../components/month-picker/month-picker.component.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts b/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts index 94196e6b1..ea7e4d316 100644 --- a/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts +++ b/src/app/modules/shared/components/month-picker/month-picker.component.spec.ts @@ -60,9 +60,10 @@ describe('MonthPickerComponent', () => { it('selectMonth should call selectDate', () => { + component.selectedYear = 2020; spyOn(component, 'selectDate'); component.selectMonth(10); - expect(component.selectDate).toHaveBeenCalledWith(10, 2021); + expect(component.selectDate).toHaveBeenCalledWith(10, 2020); }); });