Skip to content

Commit

Permalink
Bug/e UI 1274 task completion error message (#1664)
Browse files Browse the repository at this point in the history
* Error message for wrong file type refactored. (#1619)

* Error message for wrong file type refactored.

* check statement added

* initialise errorMsg

* PR review comments fix

* version number change

---------

Co-authored-by: RiteshHMCTS <[email protected]>

* datetime format error fix and unit test (#1615)

* datetime format error fix and unit test

* Date format changed to correct incorrect display

* version number changed

---------

Co-authored-by: RiteshHMCTS <[email protected]>

* Ex UI 1112 new branch update hearing requirements event is stuck (#1630)

* objects validation  to prevent runtime errors

* unit test

* version change and code fix

* added else clause

---------

Co-authored-by: RiteshHMCTS <[email protected]>

* remove dynamic list field if value is null frm CYA (#1648)

* remove dynamic list field if value is null frm CYA

* simplified the code

* Added serviceId params to request (#1557)

* Added serviceId params to request

* added a new model file. Unsubscribe subjects

* getOrgService func modified

* duplicate logic removed

* console log msg removed

* Unit tests

* version changed

* Linting issue fixed

* version no change

* version no changed to a newer version

* yarn audit

* version  number changed

* package  json file

---------

Co-authored-by: RiteshHMCTS <[email protected]>

* exui-1152 (#1646)

* exui-1152

* version updated along with sonar failure issue

* sonar issue

* EXUI-830 screen fixes when event raised (#1631)

* Error log added to handleError function

* code comment modified

---------

Co-authored-by: RiteshHMCTS <[email protected]>

* unit test fix

* sonar failure

* unit test added

* Bug/e UI 1229 event complete before task (#1656)

* Rearranging event and task completion

Event completion now set to occur before task completion

* linting and testing

* Additional code changes

Edit for more appropriate code

* Change version for tag

* Add new tests for sonar issues

Also clean code slightly

* Slight technical improvement

* Revert "Slight technical improvement"

This reverts commit 55c40f3.

* Add event completion logic in case of task completion error

---------

Co-authored-by: RiteshHMCTS <[email protected]>

* release notes updated

* version updated

* Add error messages for task completion where required

* version updated

* release notes updated with version number

* Make potential fix

* Revert unneccessary changes

* Update form-value.service.ts

---------

Co-authored-by: OgunyemiO <[email protected]>
Co-authored-by: RiteshHMCTS <[email protected]>
Co-authored-by: Ritesh Dsouza <[email protected]>
  • Loading branch information
4 people authored Feb 8, 2024
1 parent 0706e65 commit f9ef740
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 14 deletions.
4 changes: 4 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## RELEASE NOTES

### Version 7.0.11
**EUI-1274** Correctly display error messages on event completion when task fails to complete

### Version 7.0.7-welsh-translation-yes-no-field-fix
**EUI-9165** Re-tag for re-release of fix, following merge conflict resolution with latest from `master`

Expand Down
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.10",
"version": "7.0.11",
"engines": {
"node": ">=18.17.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.10",
"version": "7.0.11",
"engines": {
"node": ">=18.17.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import { Injectable } from '@angular/core';
export class Constants {
public static readonly MANDATORY: string = 'MANDATORY';
public static readonly REGEX_WHITESPACES: string = '^[^ ]+(?:\\s+[^ ]+)*$';
public static readonly TASK_COMPLETION_ERROR = 'The associated task for this event failed to complete automatically. Please complete the task manually in the Tasks tab on the case';
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CaseEventTrigger } from '../../../domain/case-view/case-event-trigger.m
import { CaseField } from '../../../domain/definition/case-field.model';
import { createCaseEventTrigger } from '../../../fixture/shared.test.fixture';
import { FieldsFilterPipe } from '../../../pipes/complex/fields-filter.pipe';
import { FieldsPurger, FieldsUtils, LoadingService, SessionStorageService, WindowService } from '../../../services';
import { AlertService, FieldsPurger, FieldsUtils, LoadingService, SessionStorageService, WindowService } from '../../../services';
import { FormErrorService, FormValueService } from '../../../services/form';
import { PaletteUtilsModule } from '../../palette';
import { Confirmation, Wizard, WizardPage, WizardPageField } from '../domain';
Expand Down Expand Up @@ -213,6 +213,7 @@ describe('CaseEditComponent', () => {
let route: any;
let mockSessionStorageService: jasmine.SpyObj<SessionStorageService>;
let mockWorkAllocationService: jasmine.SpyObj<WorkAllocationService>;
let mockAlertService: jasmine.SpyObj<AlertService>;
const validPageListCaseFieldsService = new ValidPageListCaseFieldsService(fieldsUtils);

describe('profile available in route', () => {
Expand Down Expand Up @@ -273,6 +274,7 @@ describe('CaseEditComponent', () => {
]);
mockSessionStorageService = createSpyObj<SessionStorageService>('SessionStorageService', ['getItem', 'removeItem', 'setItem']);
mockWorkAllocationService = createSpyObj<WorkAllocationService>('WorkAllocationService', ['assignAndCompleteTask', 'completeTask']);
mockAlertService = createSpyObj<AlertService>('WorkAllocationService', ['error', 'setPreserveAlerts']);
spyOn(validPageListCaseFieldsService, 'deleteNonValidatedFields');
spyOn(validPageListCaseFieldsService, 'validPageListCaseFields');

Expand Down Expand Up @@ -324,6 +326,7 @@ describe('CaseEditComponent', () => {
{ provide: ActivatedRoute, useValue: route },
{ provide: WorkAllocationService, useValue: mockWorkAllocationService},
{ provide: SessionStorageService, useValue: mockSessionStorageService},
{ provide: AlertService, useValue: mockAlertService },
WindowService,
{ provide: LoadingService, loadingServiceMock },
{ provide: ValidPageListCaseFieldsService, useValue: validPageListCaseFieldsService},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '../../../domain';
import { Task } from '../../../domain/work-allocation/Task';
import {
AlertService,
FieldsPurger, FieldsUtils, FormErrorService, FormValueService, LoadingService,
SessionStorageService, WindowService
} from '../../../services';
Expand All @@ -21,6 +22,7 @@ import { Confirmation, Wizard, WizardPage } from '../domain';
import { EventCompletionParams } from '../domain/event-completion-params.model';
import { CaseNotifier, WizardFactoryService, WorkAllocationService } from '../services';
import { ValidPageListCaseFieldsService } from '../services/valid-page-list-caseFields.service';
import { Constants } from '../../../commons/constants';

@Component({
selector: 'ccd-case-edit',
Expand Down Expand Up @@ -100,7 +102,8 @@ export class CaseEditComponent implements OnInit, OnDestroy {
private readonly formErrorService: FormErrorService,
private readonly loadingService: LoadingService,
private readonly validPageListCaseFieldsService: ValidPageListCaseFieldsService,
private readonly workAllocationService: WorkAllocationService
private readonly workAllocationService: WorkAllocationService,
private readonly alertService: AlertService
) {}

public ngOnInit(): void {
Expand Down Expand Up @@ -421,6 +424,7 @@ export class CaseEditComponent implements OnInit, OnDestroy {
const loadingSpinnerToken = this.loadingService.register();
// keep the initial event response to finalise process after task completion
let eventResponse: object;
this.sessionStorageService.setItem('taskCompletionError', 'false');
submit(caseEventData).pipe(switchMap((response) => {
eventResponse = response;
return this.postCompleteTaskIfRequired();
Expand All @@ -443,10 +447,13 @@ export class CaseEditComponent implements OnInit, OnDestroy {
}
this.isSubmitting = false;
} else {
this.sessionStorageService.setItem('taskCompletionError', 'true');
// task assignment/completion error - handled within workallocation service
// could set task to be deleted (or completed later)?
// note: think error messages only shown if user is caseworker - might reqauire changing
this.finishEventCompletionLogic(eventResponse);
// below allows error to be shown on navigation to confirmation page
this.alertService.setPreserveAlerts(true);
this.alertService.error({phrase: Constants.TASK_COMPLETION_ERROR});
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Observable, of } from 'rxjs';
import { CaseEventData, CaseEventTrigger, CaseField, CaseView, FieldType, HttpError } from '../../../domain';
import { createCaseEventTrigger } from '../../../fixture';
import { CaseReferencePipe } from '../../../pipes';
import { ActivityPollingService, AlertService, FieldsUtils } from '../../../services';
import { ActivityPollingService, AlertService, FieldsUtils, SessionStorageService } from '../../../services';
import { CaseNotifier, CasesService } from '../../case-editor';
import { CaseEventTriggerComponent } from './case-event-trigger.component';
import createSpyObj = jasmine.createSpyObj;
Expand Down Expand Up @@ -130,6 +130,7 @@ describe('CaseEventTriggerComponent', () => {
let alertService: any;
let caseNotifier: any;
let casesService: any;
let sessionStorageService: any;
let casesReferencePipe: any;
let activityPollingService: any;

Expand All @@ -141,8 +142,9 @@ describe('CaseEventTriggerComponent', () => {

casesReferencePipe = createSpyObj<CaseReferencePipe>('caseReference', ['transform']);

alertService = createSpyObj<AlertService>('alertService', ['success', 'warning']);
alertService = createSpyObj<AlertService>('alertService', ['success', 'warning', 'setPreserveAlerts']);
activityPollingService = createSpyObj<ActivityPollingService>('activityPollingService', ['postEditActivity']);
sessionStorageService = createSpyObj<SessionStorageService>('sessionStorageService', ['getItem', 'removeItem']);
activityPollingService.postEditActivity.and.returnValue(of(true));
router = {
navigate: jasmine.createSpy('navigate'),
Expand Down Expand Up @@ -175,7 +177,8 @@ describe('CaseEventTriggerComponent', () => {
{ provide: Router, useValue: router },
{ provide: AlertService, useValue: alertService },
{ provide: CaseReferencePipe, useValue: casesReferencePipe },
{ provide: ActivityPollingService, useValue: activityPollingService }
{ provide: ActivityPollingService, useValue: activityPollingService },
{ provide: SessionStorageService, useValue: sessionStorageService }
]
})
.compileComponents();
Expand Down Expand Up @@ -222,6 +225,15 @@ describe('CaseEventTriggerComponent', () => {
expect(alertService.success).toHaveBeenCalled();
});

it('should alert warning message after task completion error available and set to true in session storage', () => {
casesService.createEvent.and.returnValue(of({}));
sessionStorageService.getItem.and.returnValue('true')

component.submitted({ caseId: 123, status: 'happy' });

expect(alertService.warning).toHaveBeenCalled();
});

it('should alert warning message after navigation upon successful event creation but incomplete call back', () => {
casesService.createEvent.and.returnValue(of({}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ import { ActivatedRoute, Router } from '@angular/router';
import { Observable, Subscription, of } from 'rxjs';
import { Activity, CaseEventData, CaseEventTrigger, CaseView, DisplayMode } from '../../../domain';
import { CaseReferencePipe } from '../../../pipes';
import { ActivityPollingService, AlertService, EventStatusService, FieldsUtils } from '../../../services';
import { ActivityPollingService, AlertService, EventStatusService, FieldsUtils, SessionStorageService } from '../../../services';
import { CaseNotifier, CasesService } from '../../case-editor';
import { Constants } from '../../../commons/constants';

@Component({
selector: 'ccd-case-event-trigger',
templateUrl: './case-event-trigger.html'
})
export class CaseEventTriggerComponent implements OnInit, OnDestroy {
public static readonly EVENT_COMPLETION_MESSAGE = `Case #%CASEREFERENCE% has been updated with event: %NAME%`;
public static readonly CALLBACK_FAILED_MESSAGE = ' but the callback service cannot be completed';

public BANNER = DisplayMode.BANNER;
public eventTrigger: CaseEventTrigger;
public caseDetails: CaseView;
Expand All @@ -26,7 +30,8 @@ export class CaseEventTriggerComponent implements OnInit, OnDestroy {
private readonly alertService: AlertService,
private readonly route: ActivatedRoute,
private readonly caseReferencePipe: CaseReferencePipe,
private readonly activityPollingService: ActivityPollingService
private readonly activityPollingService: ActivityPollingService,
private readonly sessionStorageService: SessionStorageService
) {
}

Expand Down Expand Up @@ -81,20 +86,27 @@ export class CaseEventTriggerComponent implements OnInit, OnDestroy {

public submitted(event: any): void {
const eventStatus: string = event['status'];
const taskCompletionFailed = this.sessionStorageService.getItem('taskCompletionError') === 'true';
this.router
.navigate([this.parentUrl])
.then(() => {
const caseReference = this.caseReferencePipe.transform(this.caseDetails.case_id.toString());
const replacements = { CASEREFERENCE: caseReference, NAME: this.eventTrigger.name };
if (EventStatusService.isIncomplete(eventStatus)) {
this.alertService.setPreserveAlerts(true);
if (taskCompletionFailed) {
// if task still present in session storage, we know that the task has not been correctly completed
this.alertService.warning({
phrase: CaseEventTriggerComponent.EVENT_COMPLETION_MESSAGE + '. ' + Constants.TASK_COMPLETION_ERROR
, replacements});
this.sessionStorageService.removeItem('taskCompletionError');
} else if (EventStatusService.isIncomplete(eventStatus)) {
this.alertService.warning({
phrase: `Case #%CASEREFERENCE% has been updated with event: %NAME%
but the callback service cannot be completed`,
phrase: CaseEventTriggerComponent.EVENT_COMPLETION_MESSAGE + CaseEventTriggerComponent.CALLBACK_FAILED_MESSAGE,
replacements
});
} else {
this.alertService.success({
phrase: 'Case #%CASEREFERENCE% has been updated with event: %NAME%',
phrase: CaseEventTriggerComponent.EVENT_COMPLETION_MESSAGE,
replacements,
preserve: true
});
Expand Down

0 comments on commit f9ef740

Please sign in to comment.