Skip to content

Commit

Permalink
Fix task completion divergence issue
Browse files Browse the repository at this point in the history
  • Loading branch information
connorpgpmcelroy committed Sep 17, 2024
1 parent fc290ff commit 1430165
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.0.64-srt-16-september-24",
"version": "7.0.64-srt-17-september-24",
"engines": {
"node": ">=18.19.0"
},
Expand Down
2 changes: 1 addition & 1 deletion projects/ccd-case-ui-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.0.64-srt-16-september-24",
"version": "7.0.64-srt-17-september-24",
"engines": {
"node": ">=18.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ describe('CaseEditComponent', () => {
expect(validPageListCaseFieldsService.validPageListCaseFields).toHaveBeenCalled();
expect(formValueService.removeUnnecessaryFields).toHaveBeenCalled();
// check that tasks removed from session storage once event has been completed
expect(mockSessionStorageService.removeItem).toHaveBeenCalledWith('taskToComplete');
expect(mockSessionStorageService.removeItem).toHaveBeenCalledWith('clientContext');
expect(mockSessionStorageService.removeItem).toHaveBeenCalledWith('taskEventCompletionInfo');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ export class CaseEditComponent implements OnInit, OnDestroy {
return this.postCompleteTaskIfRequired();
}),finalize(() => {
this.loadingService.unregister(loadingSpinnerToken);
// on event completion ensure the previous event taskToComplete/taskEventCompletionInfo removed
this.sessionStorageService.removeItem('taskToComplete');
// on event completion ensure the previous event clientContext/taskEventCompletionInfo removed
this.sessionStorageService.removeItem('clientContext');
this.sessionStorageService.removeItem('taskEventCompletionInfo')
this.isSubmitting = false;
}))
Expand Down Expand Up @@ -526,7 +526,7 @@ export class CaseEditComponent implements OnInit, OnDestroy {
}
}

// checks whether current taskToComplete relevant for the event
// checks whether current clientContext relevant for the event
public taskExistsForThisEvent(taskInSessionStorage: Task, taskEventCompletionInfo: TaskEventCompletionInfo, eventDetails: EventDetails): boolean {
if (!taskInSessionStorage || taskInSessionStorage.case_id !== eventDetails.caseId) {
return false;
Expand All @@ -542,7 +542,7 @@ export class CaseEditComponent implements OnInit, OnDestroy {
|| this.eventMoreThanDayAgo(taskEventCompletionInfo.createdTimestamp)
) {
// if the session storage not related to event, ignore it and remove
this.sessionStorageService.removeItem('taskToComplete');
this.sessionStorageService.removeItem('clientContext');
this.sessionStorageService.removeItem('taskEventCompletionInfo');
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('TaskCancelledComponent', () => {
fixture = TestBed.createComponent(WrapperComponent);
wrapper = fixture.componentInstance;
component = fixture.componentInstance.appComponentRef;
const sessionStorageSpy = jasmine.createSpyObj('mockSessionStorageService', ['removeItem'])
const sessionStorageSpy = jasmine.createSpyObj('mockSessionStorageService', ['removeItem']);
wrapper.context = {caseId: '123456789', sessionStorageService: sessionStorageSpy} as EventCompletionStateMachineContext;
fixture.detectChanges();
});
Expand All @@ -46,7 +46,7 @@ describe('TaskCancelledComponent', () => {
it('should emit event can be completed true when clicked on continue button', () => {
spyOn(component.notifyEventCompletionCancelled, 'emit');
component.onContinue();
expect(component.context.sessionStorageService.removeItem).toHaveBeenCalledWith('taskToComplete')
expect(component.context.sessionStorageService.removeItem).toHaveBeenCalledWith('clientContext')
expect(component.notifyEventCompletionCancelled.emit).toHaveBeenCalledWith(true);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class CaseEventCompletionTaskCancelledComponent implements OnInit {

public onContinue(): void {
// Removes task to complete so event completes without task
this.context.sessionStorageService.removeItem('taskToComplete');
this.context.sessionStorageService.removeItem('clientContext');
// may be able to remove this call below since it is now unneccesary
this.notifyEventCompletionCancelled.emit(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ export class EventStartStateMachineService {
if (userInfoStr) {
userInfo = JSON.parse(userInfoStr);
}
console.log('entryActionForStateOneTaskAssignedToUser: setting taskToComplete to ' + taskStr);
// Store task to session
const taskEventCompletionInfo: TaskEventCompletionInfo = {
caseId: context.caseId,
Expand Down

0 comments on commit 1430165

Please sign in to comment.