Skip to content

Commit d589221

Browse files
TT-236 When you add a new entry and check "I'm working on this" you should take the current time for "Time in" (#681)
* fix: TT-236 fix bug in details-fields 'Im working on this' * fix: TT-236 restore deleted logic
1 parent 7693eb8 commit d589221

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/app/modules/shared/components/details-fields/details-fields.component.spec.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ describe('DetailsFieldsComponent', () => {
233233
component.ngOnChanges();
234234

235235
component.activities$.subscribe(items => {
236-
console.log(items);
237-
238236
expect(items.length).toBe(param.expected_size_activities);
239237
});
240238
});
@@ -621,6 +619,20 @@ describe('DetailsFieldsComponent', () => {
621619
expect(result).toBe(param.expected_result);
622620
});
623621
});
622+
623+
it('should display an error message when isStartTimeEntryAfterEndedEntry() is true & goingToWorkOnThis is false', () => {
624+
const times = {
625+
start_date: '2021-04-21',
626+
end_date: '2021-04-21',
627+
start_hour: '10:00',
628+
end_hour: '00:00',
629+
};
630+
component.goingToWorkOnThis = false;
631+
component.entryForm.setValue({ ...formValues, ...times });
632+
const displayError = component.isStartTimeEntryAfterEndedEntry() && !component.goingToWorkOnThis;
633+
component.onSubmit();
634+
expect(displayError).toBeTrue();
635+
});
624636
/*
625637
TODO As part of https://github.com/ioet/time-tracker-ui/issues/424 a new parameter was added to the details-field-component,
626638
and now these couple of tests are failing. A solution to this error might be generate a Test Wrapper Component. More details here:

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
141141
}
142142

143143
ngOnChanges(): void {
144-
this.goingToWorkOnThis = this.entryToEdit ? this.entryToEdit.running : false;
144+
this.goingToWorkOnThis = this.entryToEdit ? this.entryToEdit.running ?? true : false;
145145
this.shouldRestartEntry = false;
146146

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

279-
if (this.isStartTimeEntryAfterEndedEntry()) {
279+
if (this.isStartTimeEntryAfterEndedEntry() && !this.goingToWorkOnThis) {
280280
this.toastrService.error('You must end the time entry after it started');
281281
return;
282282
}
@@ -291,6 +291,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
291291
uri: this.entryForm.value.uri,
292292
timezone_offset: new Date().getTimezoneOffset(),
293293
};
294+
294295
if (this.goingToWorkOnThis) {
295296
delete entry.end_date;
296297
}

0 commit comments

Comments
 (0)