-
Notifications
You must be signed in to change notification settings - Fork 1
fix: #572 allow manual editing in time in when switch project #581
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 #581 +/- ##
==========================================
+ Coverage 93.09% 93.32% +0.23%
==========================================
Files 85 92 +7
Lines 1564 1633 +69
Branches 107 111 +4
==========================================
+ Hits 1456 1524 +68
- Misses 67 68 +1
Partials 41 41
Continue to review full report at Codecov.
|
| expect(toastrServiceStub.error).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('displays error message when new hour entered is in the past of other entry', () => { |
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 am not quite sure about what are you testing here. Correct me if I am wrong please:
Displays an error message when new entry has start_time before (start time/end time???) of active entry
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.
yes, it's the same, the name could be:
Displays an error message when new entry has start_time before end time of last entry
| component.setDataToUpdate(entry); | ||
| spyOn(toastrServiceStub, 'error'); | ||
|
|
||
| const hourInTheFuture = moment().add(-6, 'hour').format('HH:mm:ss'); |
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 the time can be in the future if you're actually subtracting hours. BTW, you can use the function subtract instead of add in this case
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.
thanks, I already change it
| expect(toastrServiceStub.error).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('If start hour is in the past of other entry, reset to initial start_date in form', () => { |
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 don't get what are you testing here. Feel free to send me a DM
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.
This test is to restart to the previous time when you enter a wrong time.
I corrected the name to:
should reset to current start_date of form when start_date is before the current entrie’s start_date
| it('when a start hour is updated, then dispatch UpdateActiveEntry', () => { | ||
| component.activeEntry = entry ; | ||
| component.setDataToUpdate(entry); | ||
| const newHour = moment().format('HH:mm:ss'); |
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.
let's use newTime or updatedTime instead of newHour
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, I change to updatedTime
| expect(store.dispatch).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('when a start hour is update, then select the last time entry', async(() => { |
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.
Correct me if I am wrong, I think this is what you are testing here.
When start_time is updated, component.last_entry is equal to...
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.
Sure, another way would be:
When start_time is updated, component.last_entry is equal to last time entry in the state
| expect(component.lastEntry).toBe(state.entries.timeEntriesDataSource.data[1]); | ||
| })); | ||
|
|
||
| it('when a start hour is updated in other time entry, then dispatch UpdateEntry and UpdateEntryRunning', () => { |
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.
When start_time is updated for a time entry. UpdateEntry and UpdateEntryRuning actions are dispatched.
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.
Of course, that phrase is better understood.
| spyOn(store, 'dispatch'); | ||
|
|
||
| component.onUpdateStartHour(); | ||
| expect(store.dispatch).toHaveBeenCalledTimes(2); |
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.
You might want to verify here the above-mentioned actions have been dispatched.
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 tested
| const isFirstEntry = this.lastEntry !== undefined ? this.lastEntry.start_date : moment().add(-1, 'hours'); | ||
| const isEntryDateInLastStartDate = moment(newHourEntered).isBefore(isFirstEntry); | ||
| if (isEntryDateInLastStartDate) { | ||
| this.toastrService.error('You cannot start a time-entry before another time-entry'); |
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.
What do you mean?
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.
Is to control that the user does not enter a time equal to or prior to the last time entry.
I have changed the message to:
There is already a time-entry with the time entered. The entry time cannot be the same as another time-entry
function to change the start and end time of previous time entry when switch project