-
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #591 +/- ##
==========================================
+ Coverage 93.09% 93.82% +0.72%
==========================================
Files 85 95 +10
Lines 1564 1700 +136
Branches 107 112 +5
==========================================
+ Hits 1456 1595 +139
Misses 67 67
+ Partials 41 38 -3
Continue to review full report at Codecov.
|
const startHourTest = moment().subtract(3, 'hours').format('HH:mm:ss'); | ||
const startDateTest = new Date(`${dateTest}T${startHourTest.trim()}`); |
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 end
variables
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 have change all the tests, please check them.
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()}`); |
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.
Do you think we could have any issue about the timing when the tests run? For example, if we put this test running at 1:00 am, due you are subtracting 3 hours, it means that the current hour would be 23:00 of what day?
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 have deleted that block of lines, it's different now.
expect(component.starDateValue).toEqual(startHourValue); | ||
expect(component.endDateValue).toEqual(endHourValue); |
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.
How are you asserting that the other fields, like description
are being updated?
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.
there's a new test to prove that.
const startHourValue = moment().subtract(3, 'hours').format('HH:mm'); | ||
const endHourValue = moment().format('HH:mm'); |
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.
not sure if this should be the best approach for setting the start and end hours values, as I understand, you are setting those entry values in the before each
section. Could you read the current entry "hours" and setting the test variables with those values instead?
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 have also deleted those hours, now is in the test those values.
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(); |
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 see an opportunity to extract lines 213 and 216 into a method that receives the entryForm.value.X_VALUE
and returns everything that is being done in that large sentence.
If you find that in other files, could be an utilitary. :)
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.
It's Done thanks.
3b7454d
to
35d21e8
Compare
35d21e8
to
85a4c93
Compare
expect(component.saveEntry.emit).toHaveBeenCalledWith(data); | ||
}); | ||
|
||
it('should not modify the start_date when start_hour has not been modified', () => { | ||
const dateTest = moment().format('YYYY-MM-DD'); |
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.
change:
dateTest
to currentDate
startHourTest
to startHour
I think is necessary use other name of variable per example dateTest
to dateCurrent
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.
Ok it's changed
const isEndDateInTheFuture = moment(endDateToSubmit).isAfter(moment()); | ||
const timeEntryIsInTheFuture = isStartDateInTheFuture || isEndDateInTheFuture; | ||
|
||
if (timeEntryIsInTheFuture) { |
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 remember we made a change to extract timeEntryIsInTheFuture
into a function. I guess that caused issues in existing tests and you ended up doing it like this. Am I right, or is it an error?
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 just tried the function of not allowing a "time entry" in the future and it allowed me to add. It ignores the way we put it so I left it as it was. but with the tests, there was no problem.
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.
It's ok. Then, keep in mind that, when we may want to retake that little refactor.
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.
LGTM
fix a bug that not allow to update changes on "time entries".