Skip to content

Commit

Permalink
Move modules (#1549)
Browse files Browse the repository at this point in the history
* Move modules

* Fix tests

* Remove unwanted changes

* Add new test

* update version

* remove code
  • Loading branch information
DavidJayakumar authored Aug 23, 2023
1 parent c5c84d4 commit 87282a3
Show file tree
Hide file tree
Showing 15 changed files with 204 additions and 20 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": "6.19.3-RetryCaseRetrievals.1",
"version": "6.19.3-qm-respond-event-completion",
"engines": {
"yarn": "^3.5.0",
"npm": "^8.10.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": "6.19.3-RetryCaseRetrievals.1",
"version": "6.19.3-qm-respond-event-completion",
"engines": {
"yarn": "^3.5.0",
"npm": "^8.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ import { CaseEditGenericErrorsComponent } from './case-edit-generic-errors/case-
import { CaseEditPageComponent } from './case-edit-page/case-edit-page.component';
import { CaseEditSubmitComponent } from './case-edit-submit/case-edit-submit.component';
import { CaseEditComponent } from './case-edit/case-edit.component';
import {
CaseEventCompletionComponent,
CaseEventCompletionTaskCancelledComponent,
CaseEventCompletionTaskReassignedComponent
} from './case-event-completion';
import { CaseProgressComponent } from './case-progress/case-progress.component';
import {
CaseNotifier,
Expand Down Expand Up @@ -78,9 +73,6 @@ import { CaseworkerService } from './services/case-worker.service';
CaseEditPageComponent,
CaseEditFormComponent,
CaseEditSubmitComponent,
CaseEventCompletionComponent,
CaseEventCompletionTaskCancelledComponent,
CaseEventCompletionTaskReassignedComponent,
CaseCreateComponent,
CaseProgressComponent,
CaseEditGenericErrorsComponent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Inject } from '@angular/core';
import { CaseEventCompletionComponent, COMPONENT_PORTAL_INJECTION_TOKEN } from '../../case-event-completion.component';
import { COMPONENT_PORTAL_INJECTION_TOKEN, CaseEventCompletionComponent } from '../../case-event-completion.component';

@Component({
selector: 'app-case-event-completion-task-cancelled',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { SessionStorageService } from '../../../../../services/session/session-s
import { CaseworkerService } from '../../../services/case-worker.service';
import { JudicialworkerService } from '../../../services/judicial-worker.service';
import { WorkAllocationService } from '../../../services/work-allocation.service';
import { CaseEventCompletionComponent, COMPONENT_PORTAL_INJECTION_TOKEN } from '../../case-event-completion.component';
import { COMPONENT_PORTAL_INJECTION_TOKEN, CaseEventCompletionComponent } from '../../case-event-completion.component';

@Component({
selector: 'app-case-event-completion-task-reassigned',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './../case-editor/case-event-completion';
export * from './address';
export * from './base-field';
export * from './case-file-view';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { FormValidatorsService } from '../../services/form/form-validators.servi
import { JurisdictionService } from '../../services/jurisdiction/jurisdiction.service';
import { LoadingModule } from '../../services/loading/loading.module';
import { WindowService } from '../../services/window';
import { CaseEventCompletionComponent, CaseEventCompletionTaskCancelledComponent, CaseEventCompletionTaskReassignedComponent } from '../case-editor/case-event-completion';
import { WriteAddressFieldComponent } from './address/write-address-field.component';
import { FieldReadComponent, FieldReadLabelComponent, FieldWriteComponent } from './base-field';
import { CaseFileViewOverlayMenuComponent } from './case-file-view';
Expand Down Expand Up @@ -125,6 +126,7 @@ import {
QueryCaseDetailsHeaderComponent,
QueryCheckYourAnswersComponent,
QueryDetailsComponent,
QueryEventCompletionComponent,
QueryListComponent,
QueryWriteAddDocumentsComponent,
QueryWriteDateInputComponent,
Expand Down Expand Up @@ -263,7 +265,13 @@ const PALETTE_COMPONENTS = [
QueryWriteDateInputComponent,
QualifyingQuestionOptionsComponent,
QualifyingQuestionDetailComponent,
QueryAttachmentsReadComponent
QueryAttachmentsReadComponent,
QueryEventCompletionComponent,

// Case event completion
CaseEventCompletionComponent,
CaseEventCompletionTaskCancelledComponent,
CaseEventCompletionTaskReassignedComponent
];

@NgModule({
Expand Down Expand Up @@ -313,7 +321,7 @@ const PALETTE_COMPONENTS = [
LanguageInterpreterDisplayPipe,
ManageCaseFlagsLabelDisplayPipe,
UpdateFlagTitleDisplayPipe,
...PALETTE_COMPONENTS,
...PALETTE_COMPONENTS
],
exports: [
NgxMatDatetimePickerModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
export * from './qualifying-questions/qualifying-question-detail/qualifying-question-detail.component';
export * from './qualifying-questions/qualifying-question-options/qualifying-question-options.component';
export * from './query-attachments-read/query-attachments-read.component';
export * from './query-case-details-header/query-case-details-header.component';
export * from './query-check-your-answers/query-check-your-answers.component';
export * from './query-details/query-details.component';
export * from './query-event-completion/query-event-completion.component';
export * from './query-list/query-list.component';
export * from './query-write/query-write-date-input/query-write-date-input.component';
export * from './query-write/query-write-add-documents/query-write-add-documents.component';
export * from './query-write/query-write-date-input/query-write-date-input.component';
export * from './query-write/query-write-raise-query/query-write-raise-query.component';
export * from './query-write/query-write-respond-to-query/query-write-respond-to-query.component';
export * from './query-attachments-read/query-attachments-read.component';

Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ <h1 class="govuk-heading-l">
(click)="goBack()">
{{ 'Previous' | rpxTranslate }}
</button>
<button class="govuk-button" data-module="govuk-button">
<button class="govuk-button" data-module="govuk-button" (click)="submit()">
{{ 'Submit' | rpxTranslate }}
</button>
</div>
</div>

<ccd-query-event-completion [eventCompletionParams]="eventCompletionParams">
</ccd-query-event-completion>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { CUSTOM_ELEMENTS_SCHEMA, Pipe, PipeTransform } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { BehaviorSubject, of } from 'rxjs';
import { CaseView, TaskSearchParameter } from '../../../../../../shared/domain';
import { EventCompletionParams } from '../../../../case-editor/domain/event-completion-params.model';
import { CaseNotifier, WorkAllocationService } from '../../../../case-editor/services';
import { QueryCreateContext, QueryListItem } from '../../models';
import { QueryCheckYourAnswersComponent } from './query-check-your-answers.component';

Expand All @@ -16,6 +21,9 @@ describe('QueryCheckYourAnswersComponent', () => {
let component: QueryCheckYourAnswersComponent;
let fixture: ComponentFixture<QueryCheckYourAnswersComponent>;
let nativeElement: any;
let casesService: any;
let caseNotifier: any;
let workAllocationService: any;

const items = [
{
Expand Down Expand Up @@ -113,12 +121,69 @@ describe('QueryCheckYourAnswersComponent', () => {
]
});

const snapshotActivatedRoute = {
snapshot: {
params: {
qid: '1'
}
}
};

const CASE_VIEW: CaseView = {
case_id: '1',
case_type: {
id: 'TestAddressBookCase',
name: 'Test Address Book Case',
jurisdiction: {
id: 'TEST',
name: 'Test',
}
},
channels: [],
state: {
id: 'CaseCreated',
name: 'Case created'
},
tabs: [],
triggers: [],
events: []
};

const response = {
tasks: [{
additional_properties: {
additionalProp1: '1'
},
assignee: '12345',
case_id: '1',
case_name: 'Alan Jonson',
created_date: '2021-04-19T14:00:00.000+0000',
due_date: '2021-05-20T16:00:00.000+0000',
id: 'Task_2',
jurisdiction: 'Immigration and Asylum',
case_category: 'asylum',
name: 'Task name',
permissions: null
}]
};

beforeEach(async () => {
workAllocationService = jasmine.createSpyObj('WorkAllocationService', ['searchTasks']);
workAllocationService.searchTasks.and.returnValue(of(response));
casesService = jasmine.createSpyObj('casesService', ['getCaseViewV2']);
caseNotifier = new CaseNotifier(casesService);
caseNotifier.caseView = new BehaviorSubject(CASE_VIEW).asObservable();

await TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [
QueryCheckYourAnswersComponent,
RpxTranslateMockPipe
],
providers: [
{ provide: ActivatedRoute, useValue: snapshotActivatedRoute },
{ provide: WorkAllocationService, useValue: workAllocationService },
{ provide: CaseNotifier, useValue: caseNotifier }
]
})
.compileComponents();
Expand Down Expand Up @@ -188,4 +253,24 @@ describe('QueryCheckYourAnswersComponent', () => {
expect(columnHeadings[0].nativeElement.textContent.trim()).toEqual('Query detail');
expect(columnHeadings[1].nativeElement.textContent.trim()).toEqual('Document attached');
});

describe('submit', () => {
it('should call search task', () => {
component.submit();
fixture.detectChanges();
const searchParameter = { ccdId: '1' } as TaskSearchParameter;
expect(workAllocationService.searchTasks).toHaveBeenCalledWith(searchParameter);
});

it('should trigger event completion', () => {
component.submit();
fixture.detectChanges();
const eventCompletionParams: EventCompletionParams = {
caseId: '1',
eventId: 'respondToQuery',
task: response.tasks[0]
};
expect(component.eventCompletionParams).toEqual(eventCompletionParams);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,20 +1,72 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';
import { take } from 'rxjs/operators';
import { TaskSearchParameter } from '../../../../../../../lib/shared/domain';
import { EventCompletionParams } from '../../../../case-editor/domain/event-completion-params.model';
import { CaseNotifier, WorkAllocationService } from '../../../../case-editor/services';
import { QueryCreateContext, QueryListItem } from '../../models';

@Component({
selector: 'ccd-query-check-your-answers',
templateUrl: './query-check-your-answers.component.html',
styleUrls: ['./query-check-your-answers.component.scss']
})
export class QueryCheckYourAnswersComponent {
export class QueryCheckYourAnswersComponent implements OnInit, OnDestroy {
@Input() public formGroup: FormGroup;
@Input() public queryItem: QueryListItem;
@Input() public queryCreateContext: QueryCreateContext;
@Output() public backClicked = new EventEmitter<boolean>();
public queryCreateContextEnum = QueryCreateContext;

public eventCompletionParams: EventCompletionParams;
private caseId: string;
private eventId: string;
private queryId: string;
private searchTasksSubsciption: Subscription;

constructor(
private readonly route: ActivatedRoute,
private readonly workAllocationService: WorkAllocationService,
private readonly caseNotifier: CaseNotifier) { }

public ngOnInit(): void {
this.queryId = this.route.snapshot.params.qid;
this.caseNotifier.caseView.pipe(take(1)).subscribe(caseDetails => {
this.caseId = caseDetails.case_id;
// To be set after integration
this.eventId = 'respondToQuery';
});
}

public ngOnDestroy(): void {
this.searchTasksSubsciption?.unsubscribe();
}

public goBack(): void {
this.backClicked.emit(true);
}

public submit(): void {
// Search Task
const searchParameter = { ccdId: this.caseId } as TaskSearchParameter;
this.searchTasksSubsciption = this.workAllocationService.searchTasks(searchParameter)
.subscribe((response: any) => {
// Filter task by query id
const filteredtask = response.tasks?.find((task) => {
return Object.values(task.additional_properties).some((value) => {
if (value === this.queryId) {
return task;
}
});
});
// Trigger event completion
this.eventCompletionParams = {
caseId: this.caseId,
eventId: this.eventId,
task: filteredtask
};
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export class QueryDetailsComponent {
const userDetails = JSON.parse(this.sessionStorage.getItem('userDetails'));
return userDetails && userDetails.roles
&& !(userDetails.roles.includes('pui-case-manager')
|| userDetails.roles.some((role) => role.toLowerCase().includes('judge')))
|| userDetails.roles.some((role) => role.toLowerCase().includes('judge')));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<ccd-case-event-completion [eventCompletionParams]="eventCompletionParams"
(eventCanBeCompleted)="onEventCanBeCompleted($event)">
</ccd-case-event-completion>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { QueryEventCompletionComponent } from './query-event-completion.component';

describe('QueryEventCompletionComponent', () => {
let component: QueryEventCompletionComponent;
let fixture: ComponentFixture<QueryEventCompletionComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ QueryEventCompletionComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(QueryEventCompletionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component, Input } from '@angular/core';
import { EventCompletionParams } from '../../../../case-editor/domain/event-completion-params.model';

@Component({
selector: 'ccd-query-event-completion',
templateUrl: './query-event-completion.component.html'
})
export class QueryEventCompletionComponent {
@Input() public eventCompletionParams: EventCompletionParams;

public onEventCanBeCompleted(value: boolean): void {
// Submit the query response
}
}

0 comments on commit 87282a3

Please sign in to comment.