Skip to content

Conversation

PaulRC-ioet
Copy link
Contributor

fix a bug that not allow to update changes on "time entries".

@codecov
Copy link

codecov bot commented Dec 17, 2020

Codecov Report

Merging #591 (1685b88) into master (13de42e) will increase coverage by 0.72%.
The diff coverage is 98.75%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
src/app/app-routing.module.ts 100.00% <ø> (ø)
...nents/time-range-form/time-range-form.component.ts 100.00% <ø> (ø)
...project-list-hover/project-list-hover.component.ts 88.37% <ø> (ø)
...dules/time-entries/pages/time-entries.component.ts 83.58% <87.50%> (+0.76%) ⬆️
src/app/modules/users/store/user.reducers.ts 87.50% <87.50%> (ø)
src/app/guards/login-guard/login.guard.ts 100.00% <100.00%> (ø)
...nologies-report-guard/technologies-report.guard.ts 100.00% <100.00%> (ø)
src/app/modules/login/login.component.ts 100.00% <100.00%> (+16.66%) ⬆️
...app/modules/login/services/azure.ad.b2c.service.ts 86.95% <100.00%> (+4.60%) ⬆️
...ponents/details-fields/details-fields.component.ts 90.69% <100.00%> (+3.51%) ⬆️
... and 31 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e23d02...1685b88. Read the comment docs.

Comment on lines 82 to 83
const startHourTest = moment().subtract(3, 'hours').format('HH:mm:ss');
const startDateTest = new Date(`${dateTest}T${startHourTest.trim()}`);
Copy link
Contributor

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

Copy link
Contributor Author

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.

Comment on lines 79 to 83
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()}`);
Copy link
Contributor

@josepato87 josepato87 Dec 17, 2020

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?

Copy link
Contributor Author

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.

Comment on lines 331 to 332
expect(component.starDateValue).toEqual(startHourValue);
expect(component.endDateValue).toEqual(endHourValue);
Copy link
Contributor

@josepato87 josepato87 Dec 17, 2020

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?

Copy link
Contributor Author

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.

Comment on lines 326 to 327
const startHourValue = moment().subtract(3, 'hours').format('HH:mm');
const endHourValue = moment().format('HH:mm');
Copy link
Contributor

@josepato87 josepato87 Dec 17, 2020

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?

Copy link
Contributor Author

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.

Comment on lines 213 to 216
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();
Copy link
Contributor

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. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's Done thanks.

@PaulRC-ioet PaulRC-ioet force-pushed the TT-85FixOverlappingSeconds branch from 3b7454d to 35d21e8 Compare December 18, 2020 20:51
@PaulRC-ioet PaulRC-ioet force-pushed the TT-85FixOverlappingSeconds branch from 35d21e8 to 85a4c93 Compare December 22, 2020 16:27
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');
Copy link
Collaborator

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

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@josepato87 josepato87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@josepato87 josepato87 merged commit df0ae39 into master Dec 23, 2020
@josepato87 josepato87 deleted the TT-85FixOverlappingSeconds branch December 23, 2020 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants