Skip to content

Commit d12ce95

Browse files
authored
Tt 289 cannot edit the date of an entry (#708)
* fix: TT-289 added an extra comparison to make sure the update date is being saved * fix: TT-289 remove non-relevant anymore test cases, after fist changes * Update details-fields.component.ts * Update details-fields.component.ts
1 parent 0dec7ac commit d12ce95

File tree

2 files changed

+1
-28
lines changed

2 files changed

+1
-28
lines changed

src/app/modules/shared/components/details-fields/details-fields.component.spec.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -418,19 +418,6 @@ describe('DetailsFieldsComponent', () => {
418418
expect(component.saveEntry.emit).toHaveBeenCalledWith(data);
419419
});
420420

421-
it('should not modify the start_date when start_hour has not been modified', () => {
422-
const currentDate = moment().format('YYYY-MM-DD');
423-
const startHour = moment().subtract(3, 'hours').format('HH:mm:ss');
424-
const expectedStartDate = new Date(`${currentDate}T${startHour.trim()}`);
425-
426-
component.entryToEdit = { ...entryToEdit, start_date: expectedStartDate };
427-
fixture.componentInstance.ngOnChanges();
428-
429-
component.entryForm.patchValue({ description: 'test' });
430-
431-
expect(component.dateToSubmit('start_date', 'start_hour')).toEqual(expectedStartDate);
432-
});
433-
434421
it('should modify the start_date when start_hour has been modified', () => {
435422
const startDate = new Date(mockCurrentDate);
436423

@@ -445,19 +432,6 @@ describe('DetailsFieldsComponent', () => {
445432
expect(component.dateToSubmit('start_date', 'start_hour')).toEqual(expectedStartDate);
446433
});
447434

448-
it('should not modify the end_date when end_hour has not been modified', () => {
449-
const currentDate = moment().format('YYYY-MM-DD');
450-
const endHour = moment().subtract(3, 'hours').format('HH:mm:ss');
451-
const expectedEndDate = new Date(`${currentDate}T${endHour.trim()}`);
452-
453-
component.entryToEdit = { ...entryToEdit, end_date: expectedEndDate };
454-
fixture.componentInstance.ngOnChanges();
455-
456-
component.entryForm.patchValue({ description: 'test' });
457-
458-
expect(component.dateToSubmit('end_date', 'end_hour')).toEqual(expectedEndDate);
459-
});
460-
461435
it('should modify the end_date when end_hour has been modified', () => {
462436
const endDate = new Date(mockCurrentDate);
463437

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
269269
const updatedHour = this.entryForm.value[hour];
270270
const updatedDate = new Date(`${entryFormDate}T${updatedHour.trim()}`).toISOString();
271271
const initialDate = get(this.entryToEdit, date, updatedDate);
272-
const initialHour = formatDate(get(this.entryToEdit, date, updatedDate), 'HH:mm', 'en');
273-
const dateHasNotChanged = updatedHour === initialHour;
272+
const dateHasNotChanged = (initialDate === updatedDate);
274273
const result = dateHasNotChanged ? initialDate : updatedDate;
275274
return result;
276275
}

0 commit comments

Comments
 (0)