-
Notifications
You must be signed in to change notification settings - Fork 1
TT-85 fix: fix overlapping seconds on time entries #591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
8b50d4f
3155406
29da434
85a4c93
1685b88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,11 @@ describe('DetailsFieldsComponent', () => { | |
| description: '', | ||
| technology: '', | ||
| }; | ||
| const dateTest = moment().format('YYYY-MM-DD'); | ||
| const endHourTest = moment().format('HH:mm:ss'); | ||
| const endDateTest = new Date(`${dateTest}T${endHourTest.trim()}`); | ||
| const startHourTest = moment().subtract(3, 'hours').format('HH:mm:ss'); | ||
| const startDateTest = new Date(`${dateTest}T${startHourTest.trim()}`); | ||
|
||
|
|
||
| beforeEach(waitForAsync(() => { | ||
| TestBed.configureTestingModule({ | ||
|
|
@@ -101,8 +106,8 @@ describe('DetailsFieldsComponent', () => { | |
| project_id: 'id', | ||
| activity_id: '', | ||
| uri: 'ticketUri', | ||
| start_date: null, | ||
| end_date: null, | ||
| start_date: startDateTest, | ||
| end_date: endDateTest, | ||
| description: '', | ||
| technologies: [], | ||
| id: 'xyz' | ||
|
|
@@ -314,6 +319,19 @@ describe('DetailsFieldsComponent', () => { | |
| expect(component.saveEntry.emit).toHaveBeenCalledWith(data); | ||
| }); | ||
|
|
||
| fit('onSubmit an entry without change hours, should not modify the start_date and end_date ', () => { | ||
| component.entryToEdit = {...entryToEdit, description: 'test', }; | ||
| fixture.componentInstance.ngOnChanges(); | ||
|
|
||
| const startHourValue = moment().subtract(3, 'hours').format('HH:mm'); | ||
| const endHourValue = moment().format('HH:mm'); | ||
|
||
|
|
||
| component.onSubmit(); | ||
|
|
||
| expect(component.starDateValue).toEqual(startHourValue); | ||
| expect(component.endDateValue).toEqual(endHourValue); | ||
|
||
| }); | ||
|
|
||
| it('displays error message when the date selected is in the future', () => { | ||
| spyOn(toastrServiceStub, 'error'); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,8 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { | |
| activities: Activity[] = []; | ||
| goingToWorkOnThis = false; | ||
| shouldRestartEntry = false; | ||
| starDateValue; | ||
| endDateValue; | ||
|
|
||
| constructor(private formBuilder: FormBuilder, private store: Store<Merged>, | ||
| private actionsSubject$: ActionsSubject, private toastrService: ToastrService) { | ||
|
|
@@ -139,6 +141,8 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { | |
| uri: this.entryToEdit.uri, | ||
| technology: '', | ||
| }); | ||
| this.starDateValue = formatDate(get(this.entryToEdit, 'start_date', '00:00'), 'HH:mm', 'en'); | ||
| this.endDateValue = formatDate(get(this.entryToEdit, 'end_date', '00:00'), 'HH:mm', 'en'); | ||
| } else { | ||
| this.cleanForm(); | ||
| } | ||
|
|
@@ -204,13 +208,20 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { | |
| } | ||
| const startDate = this.entryForm.value.start_date; | ||
| const endDate = this.entryForm.value.end_date; | ||
| this.starDateValue = this.entryForm.value.start_hour === this.starDateValue ? | ||
| this.entryToEdit.start_date : | ||
| new Date(`${startDate}T${this.entryForm.value.start_hour.trim()}`).toISOString(); | ||
| this.endDateValue = this.entryForm.value.end_hour === this.endDateValue ? | ||
| this.entryToEdit.end_date : | ||
| new Date(`${endDate}T${this.entryForm.value.end_hour.trim()}`).toISOString(); | ||
|
||
|
|
||
| const entry = { | ||
| project_id: this.entryForm.value.project_id, | ||
| activity_id: this.entryForm.value.activity_id, | ||
| technologies: get(this, 'selectedTechnologies', []), | ||
| description: this.entryForm.value.description, | ||
| start_date: new Date(`${startDate}T${this.entryForm.value.start_hour.trim()}`).toISOString(), | ||
| end_date: new Date(`${endDate}T${this.entryForm.value.end_hour.trim()}`).toISOString(), | ||
| start_date: this.starDateValue, | ||
| end_date: this.endDateValue, | ||
| uri: this.entryForm.value.uri, | ||
| timezone_offset: new Date().getTimezoneOffset(), | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move these two lines before the
endvariablesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have change all the tests, please check them.