From 438279f209012664f8ffcdeb053f6def38f49a6c Mon Sep 17 00:00:00 2001 From: DrFreud1 Date: Tue, 20 Jul 2021 15:21:07 -0500 Subject: [PATCH 1/4] fix: TT-289 added an extra comparison to make sure the update date is being saved --- .../components/details-fields/details-fields.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.ts b/src/app/modules/shared/components/details-fields/details-fields.component.ts index 82b99a121..420081936 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.ts @@ -270,7 +270,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { const updatedDate = new Date(`${entryFormDate}T${updatedHour.trim()}`).toISOString(); const initialDate = get(this.entryToEdit, date, updatedDate); const initialHour = formatDate(get(this.entryToEdit, date, updatedDate), 'HH:mm', 'en'); - const dateHasNotChanged = updatedHour === initialHour; + const dateHasNotChanged = (initialDate === updatedDate) && (updatedHour === initialHour); const result = dateHasNotChanged ? initialDate : updatedDate; return result; } From 04aa35773a05e2b8d1ad93db75fff125c6356dbe Mon Sep 17 00:00:00 2001 From: DrFreud1 Date: Thu, 22 Jul 2021 15:05:42 -0500 Subject: [PATCH 2/4] fix: TT-289 remove non-relevant anymore test cases, after fist changes --- .../details-fields.component.spec.ts | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts b/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts index 42f6e2263..2fa11b8af 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts @@ -418,19 +418,6 @@ describe('DetailsFieldsComponent', () => { expect(component.saveEntry.emit).toHaveBeenCalledWith(data); }); - it('should not modify the start_date when start_hour has not been modified', () => { - const currentDate = moment().format('YYYY-MM-DD'); - const startHour = moment().subtract(3, 'hours').format('HH:mm:ss'); - const expectedStartDate = new Date(`${currentDate}T${startHour.trim()}`); - - component.entryToEdit = { ...entryToEdit, start_date: expectedStartDate }; - fixture.componentInstance.ngOnChanges(); - - component.entryForm.patchValue({ description: 'test' }); - - expect(component.dateToSubmit('start_date', 'start_hour')).toEqual(expectedStartDate); - }); - it('should modify the start_date when start_hour has been modified', () => { const startDate = new Date(mockCurrentDate); @@ -445,19 +432,6 @@ describe('DetailsFieldsComponent', () => { expect(component.dateToSubmit('start_date', 'start_hour')).toEqual(expectedStartDate); }); - it('should not modify the end_date when end_hour has not been modified', () => { - const currentDate = moment().format('YYYY-MM-DD'); - const endHour = moment().subtract(3, 'hours').format('HH:mm:ss'); - const expectedEndDate = new Date(`${currentDate}T${endHour.trim()}`); - - component.entryToEdit = { ...entryToEdit, end_date: expectedEndDate }; - fixture.componentInstance.ngOnChanges(); - - component.entryForm.patchValue({ description: 'test' }); - - expect(component.dateToSubmit('end_date', 'end_hour')).toEqual(expectedEndDate); - }); - it('should modify the end_date when end_hour has been modified', () => { const endDate = new Date(mockCurrentDate); From 4ef1559e51a2a25f977cbb0e849b8d9f42296ccd Mon Sep 17 00:00:00 2001 From: Santiago Pozo Ruiz <38196801+DrFreud1@users.noreply.github.com> Date: Fri, 23 Jul 2021 14:28:26 -0500 Subject: [PATCH 3/4] Update details-fields.component.ts --- .../components/details-fields/details-fields.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.ts b/src/app/modules/shared/components/details-fields/details-fields.component.ts index 420081936..1086ed695 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.ts @@ -270,7 +270,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { const updatedDate = new Date(`${entryFormDate}T${updatedHour.trim()}`).toISOString(); const initialDate = get(this.entryToEdit, date, updatedDate); const initialHour = formatDate(get(this.entryToEdit, date, updatedDate), 'HH:mm', 'en'); - const dateHasNotChanged = (initialDate === updatedDate) && (updatedHour === initialHour); + const dateHasNotChanged = (initialDate === updatedDate); const result = dateHasNotChanged ? initialDate : updatedDate; return result; } From 981cfb812ec50b1df9d58149113958429682e492 Mon Sep 17 00:00:00 2001 From: Santiago Pozo Ruiz <38196801+DrFreud1@users.noreply.github.com> Date: Fri, 23 Jul 2021 14:37:25 -0500 Subject: [PATCH 4/4] Update details-fields.component.ts --- .../shared/components/details-fields/details-fields.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.ts b/src/app/modules/shared/components/details-fields/details-fields.component.ts index 1086ed695..e36b97433 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.ts @@ -269,7 +269,6 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { const updatedHour = this.entryForm.value[hour]; const updatedDate = new Date(`${entryFormDate}T${updatedHour.trim()}`).toISOString(); const initialDate = get(this.entryToEdit, date, updatedDate); - const initialHour = formatDate(get(this.entryToEdit, date, updatedDate), 'HH:mm', 'en'); const dateHasNotChanged = (initialDate === updatedDate); const result = dateHasNotChanged ? initialDate : updatedDate; return result;