diff --git a/package-lock.json b/package-lock.json index b76d033a7..afdf5fb40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6787,9 +6787,9 @@ "dev": true }, "elliptic": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz", - "integrity": "sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw==", + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", + "integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", "dev": true, "requires": { "bn.js": "^4.4.0", diff --git a/src/app/modules/time-entries/pages/time-entries.component.spec.ts b/src/app/modules/time-entries/pages/time-entries.component.spec.ts index f5008fde0..f47e226e2 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.spec.ts +++ b/src/app/modules/time-entries/pages/time-entries.component.spec.ts @@ -11,10 +11,11 @@ import { TechnologyState } from '../../shared/store/technology.reducers'; import { TimeEntriesSummaryComponent } from '../../time-clock/components/time-entries-summary/time-entries-summary.component'; import * as entryActions from '../../time-clock/store/entry.actions'; import { EntryState } from '../../time-clock/store/entry.reducer'; -import { getTimeEntriesDataSource } from '../../time-clock/store/entry.selectors'; +import { getTimeEntriesDataSource, getActiveTimeEntry } from '../../time-clock/store/entry.selectors'; import { LoadActiveEntry } from './../../time-clock/store/entry.actions'; import { TimeEntriesComponent } from './time-entries.component'; - +import { ActionsSubject } from '@ngrx/store'; +import { EntryActionTypes } from './../../time-clock/store/entry.actions'; describe('TimeEntriesComponent', () => { type Merged = TechnologyState & ProjectState & EntryState; @@ -179,6 +180,27 @@ describe('TimeEntriesComponent', () => { expect(component.entryId).toBe(anEntryId); }); + it('when trigger edit action and there is no active entry, active entry should be null', () => { + state.active = null; + mockEntriesSelector = store.overrideSelector(getActiveTimeEntry, state.active); + + const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject; + const action = { + type: EntryActionTypes.UPDATE_ENTRY_SUCCESS, + payload: { + project_id: 'project-id', + start_date: '2010-05-05T10:04', + description: 'description', + technologies: [], + uri: 'abc', + }, + }; + + actionSubject.next(action); + + expect(component.activeTimeEntry).toBeNull(); + }); + it('given a list of entries having an entry running when editing a different entry it cannot be marked as WIP ', () => { const anEntryId = '1'; const anotherEntryId = '2'; diff --git a/src/app/modules/time-entries/pages/time-entries.component.ts b/src/app/modules/time-entries/pages/time-entries.component.ts index 054fddccf..cb8c984ca 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.ts +++ b/src/app/modules/time-entries/pages/time-entries.component.ts @@ -46,6 +46,7 @@ export class TimeEntriesComponent implements OnInit, OnDestroy { ) ) ).subscribe((action) => { + this.loadActiveEntry(); this.store.dispatch(new entryActions.LoadEntries(new Date().getMonth() + 1)); }); } @@ -124,9 +125,7 @@ export class TimeEntriesComponent implements OnInit, OnDestroy { loadActiveEntry() { this.store.dispatch(new entryActions.LoadActiveEntry()); this.store.pipe(select(getActiveTimeEntry)).subscribe((activeTimeEntry) => { - if (activeTimeEntry) { - this.activeTimeEntry = activeTimeEntry; - } + this.activeTimeEntry = activeTimeEntry; }); }