Skip to content

Commit

Permalink
Chore/update release with master (#1558)
Browse files Browse the repository at this point in the history
* Fixing exception in unit tests (#1555)

* EUI-8679/8770: WorkbasketFiltersComponent and JudicialUser field fixes (#1553)

* updated

* updated

* updated

* Updated

* Initial fixes for EXUI-623

* Fix issue via making the jurisdiction model object optionally contain the selected case type

* create new toolkit version

* Update release notes

* Fix tests

* EUI-8679/8770: WorkbasketFiltersComponent and JudicialUser field fixes

EUI-8679: Remove JudicialUser FormControl values from the overall FormGroup value stored and passed as search criteria by the `WorkbasketFiltersComponent` when applying filters; EUI-8770: Ensure the `WorkbasketFiltersComponent` announces the selected jurisdiction and case type via the `JurisdictionService`; in the `WriteJudicialUserField` component, get the current jurisdiction and case type from the `JurisdictionService` if no case info is present.

* Fix import ordering

* EUI-8679/8770: WorkbasketFiltersComponent and JudicialUser field fixes

Re-tag for formal release. Also includes partial reversion of EXUI-623 (`WriteDocumentFieldComponent` changes) due to deficient unit test coverage.

---------

Co-authored-by: Muhammad Anjum <[email protected]>
Co-authored-by: Andy Wilkins <[email protected]>
Co-authored-by: Andy Wilkins <[email protected]>

---------

Co-authored-by: Andy Wilkins <[email protected]>
Co-authored-by: Muhammad Anjum <[email protected]>
Co-authored-by: Andy Wilkins <[email protected]>
  • Loading branch information
4 people authored Sep 18, 2023
1 parent 99cc702 commit d182ba2
Show file tree
Hide file tree
Showing 14 changed files with 199 additions and 39 deletions.
10 changes: 10 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
## RELEASE NOTES
### Version 6.19.4-sscs-joh-fixes
**EUI-8679/EUI-8770** Re-tag for formal release. Also includes partial reversion of EXUI-623 (`WriteDocumentFieldComponent` changes) due to deficient unit test coverage

### Version 6.19.5-hotfix-EUI-8679-8770
**EUI-8679** Remove JudicialUser FormControl values from the overall FormGroup value stored and passed as search criteria by the `WorkbasketFiltersComponent` when applying filters
**EUI-8770** Ensure the `WorkbasketFiltersComponent` announces the selected jurisdiction and case type via the `JurisdictionService`; in the `WriteJudicialUserField` component, get the current jurisdiction and case type from the `JurisdictionService` if no case info is present

### Version 6.19.5-secure-doc-case-creation.1
**EXUI-623** Make secure docstore work during case creation

### Version 6.19.1-case-flags-v2-reasonable-adjustments
**EUI-7243** Case flags v2 reasonable adjustments - updating 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": "6.19.3-mv-upgrade",
"version": "6.19.4-sscs-joh-fixes",
"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-mv-upgrade",
"version": "6.19.4-sscs-joh-fixes",
"engines": {
"yarn": "^3.5.0",
"npm": "^8.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ import { CaseworkerService } from './services/case-worker.service';
FormsModule,
ReactiveFormsModule,
CaseEditDataModule,
PaletteModule,
LabelSubstitutorModule,
ConditionalShowModule,
ErrorsModule,
PortalModule,
LoadingSpinnerModule,
BannersModule,
PaletteModule,
RpxTranslationModule.forChild()
],
declarations: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CaseEvent } from '../../domain/definition/case-event.model';
import { CaseTypeLite } from '../../domain/definition/case-type-lite.model';
import { Jurisdiction } from '../../domain/definition/jurisdiction.model';
import { createACL } from '../../fixture/shared.test.fixture';
import { AlertService, DefinitionsService, OrderService, SessionStorageService } from '../../services';
import { AlertService, DefinitionsService, JurisdictionService, OrderService, SessionStorageService } from '../../services';
import { MockRpxTranslatePipe } from '../../test/mock-rpx-translate.pipe';
import { CreateCaseFiltersComponent } from './create-case-filters.component';
import createSpyObj = jasmine.createSpyObj;
Expand Down Expand Up @@ -263,6 +263,7 @@ const FILTERED_CASE_EVENTS: CaseEvent[] = [{
let mockDefinitionsService: any;
let mockOrderService: any;
let mockAlertService: any;
let jurisdictionService: any;

const TEST_FORM_GROUP = new FormGroup({});

Expand Down Expand Up @@ -297,6 +298,9 @@ describe('CreateCaseFiltersComponent', () => {
sessionStorageService = jasmine.createSpyObj<SessionStorageService>('sessionStorageService', ['getItem']);
sessionStorageService.getItem.and.returnValue(`{"id": 1, "forename": "Firstname", "surname": "Surname",
"roles": ["role1", "role3"], "email": "[email protected]","token": null}`);
jurisdictionService = createSpyObj<JurisdictionService>('jurisdictionService',
['announceSelectedJurisdiction']);


TestBed
.configureTestingModule({
Expand All @@ -311,7 +315,8 @@ describe('CreateCaseFiltersComponent', () => {
{ provide: OrderService, useValue: mockOrderService },
{ provide: AlertService, useValue: mockAlertService },
{ provide: DefinitionsService, useValue: mockDefinitionsService },
{ provide: SessionStorageService, useValue: sessionStorageService}
{ provide: SessionStorageService, useValue: sessionStorageService },
{ provide: JurisdictionService, useValue: jurisdictionService}
]
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CaseEvent } from '../../domain/definition/case-event.model';
import { CaseTypeLite } from '../../domain/definition/case-type-lite.model';
import { Jurisdiction } from '../../domain/definition/jurisdiction.model';
import { DefinitionsService } from '../../services/definitions/definitions.service';
import { JurisdictionService } from '../../services/jurisdiction/jurisdiction.service';
import { OrderService } from '../../services/order/order.service';
import { SessionStorageService } from '../../services/session/session-storage.service';
import { CreateCaseFiltersSelection } from './create-case-filters-selection.model';
Expand Down Expand Up @@ -44,7 +45,8 @@ export class CreateCaseFiltersComponent implements OnInit {
constructor(
private readonly orderService: OrderService,
private readonly definitionsService: DefinitionsService,
private readonly sessionStorageService: SessionStorageService
private readonly sessionStorageService: SessionStorageService,
private readonly jurisdictionService: JurisdictionService
) { }

public ngOnInit() {
Expand Down Expand Up @@ -99,6 +101,8 @@ export class CreateCaseFiltersComponent implements OnInit {
}

public apply() {
this.selected.jurisdiction.currentCaseType = this.selected.caseType;
this.jurisdictionService.announceSelectedJurisdiction(this.selected.jurisdiction);
this.selectionSubmitted.emit({
jurisdictionId: this.selected.jurisdiction.id,
caseTypeId: this.selected.caseType.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('WriteDocumentFieldComponent', () => {
of(RESPONSE_SECOND_DOCUMENT)
);
mockDialog = createSpyObj<MatDialog>('dialog', ['open']);
mockMatDialogRef = createSpyObj<MatDialogRef<DocumentDialogComponent>>('matDialogRef', ['beforeClosed']);
mockMatDialogRef = createSpyObj<MatDialogRef<DocumentDialogComponent>>('matDialogRef', ['beforeClosed','close']);
casesService = createSpyObj('casesService', ['getCaseViewV2']);

mockFileUploadStateService = createSpyObj<FileUploadStateService>('fileUploadStateService', [
Expand Down Expand Up @@ -204,6 +204,8 @@ describe('WriteDocumentFieldComponent', () => {
mockMatDialogRef = {
beforeClosed() {
return of('Replace');
},
close(r: any) {
}
};
mockDialog.open.and.returnValue(mockMatDialogRef);
Expand All @@ -219,6 +221,8 @@ describe('WriteDocumentFieldComponent', () => {
mockMatDialogRef = {
beforeClosed() {
return of('Replace');
},
close(r: any) {
}
};
mockDialog.open.and.returnValue(mockMatDialogRef);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CUSTOM_ELEMENTS_SCHEMA, Pipe, PipeTransform } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ComponentFixture, TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
import { FormGroup, ReactiveFormsModule, ValidationErrors, Validators } from '@angular/forms';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { By } from '@angular/platform-browser';
import { of, throwError } from 'rxjs';
import { BehaviorSubject, of, throwError } from 'rxjs';
import { Constants } from '../../../commons/constants';
import { HmctsServiceDetail } from '../../../domain/case-flag';
import { CaseField, FieldType } from '../../../domain/definition';
import { CaseField, CaseTypeLite, FieldType, Jurisdiction } from '../../../domain/definition';
import { JudicialUserModel } from '../../../domain/jurisdiction';
import { CaseFlagRefdataService, FieldsUtils, FormValidatorsService, JurisdictionService, SessionStorageService } from '../../../services';
import { FirstErrorPipe, IsCompoundPipe, PaletteUtilsModule } from '../utils';
Expand Down Expand Up @@ -499,4 +499,58 @@ describe('WriteJudicialUserFieldComponent', () => {
const errorMessageElement = fixture.debugElement.query(By.css('.error-message')).nativeElement;
expect(errorMessageElement.textContent).toContain('Judicial User is required');
});

it('should get the jurisdiction and case type via the JurisdictionService if there is no case info', fakeAsync(() => {
sessionStorageService.getItem.and.returnValue(null);
const dummyJurisdictionAndCaseType = {
id: 'J1',
name: 'Jurisdiction 1',
description: 'Dummy jurisdiction',
caseTypes: [],
currentCaseType: {
id: 'CT1',
name: 'Case Type 1'
} as CaseTypeLite
} as Jurisdiction;
Object.defineProperty(jurisdictionService, 'selectedJurisdictionBS', { value: new BehaviorSubject(null) });
jurisdictionService.selectedJurisdictionBS.next(dummyJurisdictionAndCaseType);
spyOn(jurisdictionService.selectedJurisdictionBS, 'subscribe').and.callThrough();
component.setJurisdictionAndCaseType();
tick();
expect(jurisdictionService.selectedJurisdictionBS.subscribe).toHaveBeenCalled();
expect(component.jurisdiction).toEqual(dummyJurisdictionAndCaseType.id);
expect(component.caseType).toEqual(dummyJurisdictionAndCaseType.currentCaseType.id);
}));

it('should not get the jurisdiction and case type via the JurisdictionService if there is case info', () => {
Object.defineProperty(jurisdictionService, 'selectedJurisdictionBS', { value: new BehaviorSubject(null) });
spyOn(jurisdictionService.selectedJurisdictionBS, 'subscribe');
component.setJurisdictionAndCaseType();
expect(jurisdictionService.selectedJurisdictionBS.subscribe).not.toHaveBeenCalled();
expect(component.jurisdiction).toEqual('SSCS');
expect(component.caseType).toEqual('Benefit');
});

it('should unsubscribe from any subscriptions when the component is destroyed', fakeAsync(() => {
sessionStorageService.getItem.and.returnValue(null);
const dummyJurisdictionAndCaseType = {
id: 'J1',
name: 'Jurisdiction 1',
description: 'Dummy jurisdiction',
caseTypes: [],
currentCaseType: {
id: 'CT1',
name: 'Case Type 1'
} as CaseTypeLite
} as Jurisdiction;
Object.defineProperty(jurisdictionService, 'selectedJurisdictionBS', { value: new BehaviorSubject(null) });
jurisdictionService.selectedJurisdictionBS.next(dummyJurisdictionAndCaseType);
spyOn(jurisdictionService.selectedJurisdictionBS, 'subscribe').and.callThrough();
component.setJurisdictionAndCaseType();
tick();
expect(jurisdictionService.selectedJurisdictionBS.subscribe).toHaveBeenCalled();
spyOn(component.jurisdictionSubscription, 'unsubscribe');
component.ngOnDestroy();
expect(component.jurisdictionSubscription.unsubscribe).toHaveBeenCalled();
}));
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { AbstractControl, FormControl, ValidationErrors, Validators } from '@angular/forms';
import { Observable, of } from 'rxjs';
import { Observable, Subscription, of } from 'rxjs';
import { catchError, debounceTime, filter, map, switchMap, take, tap } from 'rxjs/operators';
import { Constants } from '../../../commons/constants';
import { JudicialUserModel } from '../../../domain/jurisdiction';
Expand All @@ -13,7 +13,7 @@ import { IsCompoundPipe } from '../utils/is-compound.pipe';
styleUrls: ['./write-judicial-user-field.component.scss'],
templateUrl: './write-judicial-user-field.component.html'
})
export class WriteJudicialUserFieldComponent extends WriteComplexFieldComponent implements OnInit {
export class WriteJudicialUserFieldComponent extends WriteComplexFieldComponent implements OnInit, OnDestroy {

public readonly minSearchCharacters = 2;

Expand All @@ -27,6 +27,7 @@ export class WriteJudicialUserFieldComponent extends WriteComplexFieldComponent
public errors: ValidationErrors;
public invalidSearchTerm = false;
public judicialUserSelected = false;
public jurisdictionSubscription: Subscription;

constructor(private readonly jurisdictionService: JurisdictionService,
private readonly sessionStorageService: SessionStorageService,
Expand Down Expand Up @@ -106,6 +107,16 @@ export class WriteJudicialUserFieldComponent extends WriteComplexFieldComponent
const caseInfo = JSON.parse(caseInfoStr);
this.jurisdiction = caseInfo?.jurisdiction;
this.caseType = caseInfo?.caseType;
} else {
// If there is no case info, attempt to get the current jurisdiction and case type via the JurisdictionService
this.jurisdictionSubscription = this.jurisdictionService.selectedJurisdictionBS.subscribe((jurisdiction) => {
if (jurisdiction) {
this.jurisdiction = jurisdiction.id;
if (jurisdiction.currentCaseType) {
this.caseType = jurisdiction.currentCaseType.id;
}
}
});
}
}

Expand Down Expand Up @@ -155,4 +166,8 @@ export class WriteJudicialUserFieldComponent extends WriteComplexFieldComponent
this.judicialUserControl.setValidators(Validators.required);
}
}

public ngOnDestroy(): void {
this.jurisdictionSubscription?.unsubscribe();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,16 @@ const PALETTE_COMPONENTS = [
CaseFlagRefdataService,
YesNoService,
CollectionCreateCheckerService,
JurisdictionService,
PaletteService,
FormValidatorsService,
FileUploadStateService,
FileUploadProgressGuard,
WindowService,
CommonDataService,
JurisdictionService,
LinkedCasesService,
{provide: MAT_DATE_LOCALE, useValue: 'en-GB'}
],
entryComponents: [CaseFileViewFolderSelectorComponent]
]
})
export class PaletteModule {
}
Loading

0 comments on commit d182ba2

Please sign in to comment.