Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ describe('DetailsFieldsComponent', () => {
component.ngOnChanges();

component.activities$.subscribe(items => {
console.log(items);

expect(items.length).toBe(param.expected_size_activities);
});
});
Expand Down Expand Up @@ -621,6 +619,20 @@ describe('DetailsFieldsComponent', () => {
expect(result).toBe(param.expected_result);
});
});

it('should display an error message when isStartTimeEntryAfterEndedEntry() is true & goingToWorkOnThis is false', () => {
const times = {
start_date: '2021-04-21',
end_date: '2021-04-21',
start_hour: '10:00',
end_hour: '00:00',
};
component.goingToWorkOnThis = false;
component.entryForm.setValue({ ...formValues, ...times });
const displayError = component.isStartTimeEntryAfterEndedEntry() && !component.goingToWorkOnThis;
component.onSubmit();
expect(displayError).toBeTrue();
});
/*
TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
and now these couple of tests are failing. A solution to this error might be generate a Test Wrapper Component. More details here:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
}

ngOnChanges(): void {
this.goingToWorkOnThis = this.entryToEdit ? this.entryToEdit.running : false;
this.goingToWorkOnThis = this.entryToEdit ? this.entryToEdit.running ?? true : false;
this.shouldRestartEntry = false;

if (this.entryToEdit) {
Expand Down Expand Up @@ -276,7 +276,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
const startDateToSubmit = this.dateToSubmit('start_date', 'start_hour');
const endDateToSubmit = this.dateToSubmit('end_date', 'end_hour');

if (this.isStartTimeEntryAfterEndedEntry()) {
if (this.isStartTimeEntryAfterEndedEntry() && !this.goingToWorkOnThis) {
this.toastrService.error('You must end the time entry after it started');
return;
}
Expand All @@ -291,6 +291,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
uri: this.entryForm.value.uri,
timezone_offset: new Date().getTimezoneOffset(),
};

if (this.goingToWorkOnThis) {
delete entry.end_date;
}
Expand Down