Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: TTA-206 validate clockin
  • Loading branch information
Abigail Cabascango committed Nov 9, 2022
commit 472b09db6e9dc30fcc799e0e23c8e5da6a7a3e1e
Original file line number Diff line number Diff line change
Expand Up @@ -206,25 +206,4 @@ describe('ProjectListHoverComponent', () => {
expect(component.clockIn).toHaveBeenCalledWith(id, customer, name);
});

// TODO Fix this test since it is throwing this error
// Expected spy dispatch to have been called with:
// [CreateEntry({ payload: Object({ project_id: '1', start_date: '2020-07-27T22:30:26.743Z', timezone_offset: 300 }),
// type: '[Entry] CREATE_ENTRY' })]
// but actual calls were:
// [CreateEntry({ payload: Object({ project_id: '1', start_date: '2020-07-27T22:30:26.742Z', timezone_offset: 300 }),
// type: '[Entry] CREATE_ENTRY' })].

// Call 0:
// Expected $[0].payload.start_date = '2020-07-27T22:30:26.742Z' to equal '2020-07-27T22:30:26.743Z'.
// it('creates time-entry with timezone_offset property', () => {
// spyOn(store, 'dispatch');
// component.clockIn('1', 'customer', 'project');
// expect(store.dispatch).toHaveBeenCalledWith(
// new CreateEntry({
// project_id: '1',
// start_date: new Date().toISOString(),
// timezone_offset: new Date().getTimezoneOffset()
// })
// );
// });
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { LoadActivities } from './../../../activities-management/store/activity-
import { allActivities } from 'src/app/modules/activities-management/store/activity-management.selectors';
import { head } from 'lodash';
import { Entry } from '../../../shared/models';
import { EntryState } from '../../store/entry.reducer';

@Component({
selector: 'app-project-list-hover',
Expand All @@ -41,10 +42,11 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
recentProjectsSubscription: Subscription;
activeEntrySubscription: Subscription;
loadActivitiesSubscription: Subscription;
canMarkEntryAsWIP = true;
canMarkEntryAsWIP : boolean;

constructor(
private formBuilder: FormBuilder,
private storeEntry: Store<EntryState>,
private store: Store<ProjectState>,
private actionsSubject$: ActionsSubject,
private toastrService: ToastrService
Expand Down Expand Up @@ -116,11 +118,13 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
technologies: [],
activity_id: head(this.activities).id,
};
this.store.pipe(select(getTimeEntriesDataSource)).subscribe(ds => {
this.canMarkEntryAsWIP = !this.isThereAnEntryRunning(ds.data);
this.canMarkEntryAsWIP = true;
this.storeEntry.pipe(select(getTimeEntriesDataSource)).subscribe(ds => {
this.canMarkEntryAsWIP = this.isThereAnEntryRunning(ds.data);
});
if (this.canMarkEntryAsWIP !== false ){
this.toastrService.error('There is an existing time entry running please check your time entries')

if (this.canMarkEntryAsWIP === true ){
this.toastrService.error('There is an existing time entry running please check your time entries');
return;
}
this.store.dispatch(new entryActions.ClockIn(entry));
Expand All @@ -134,7 +138,9 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
const runningEntry: Entry = entries.find(entry => entry.running === true);
return runningEntry;
}

isThereAnEntryRunning(entries: Entry[]) {
console.log(!!this.getEntryRunning(entries))
return !!this.getEntryRunning(entries);
}

Expand Down