Skip to content

Commit

Permalink
Merge branch 'master' into COT-462
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayparekh-hmcts authored Aug 29, 2023
2 parents 06758b0 + 5b459c6 commit 8b6eedd
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 24 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/populate-preview-deployment-id.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Populate Preview Deployment ID

on:
pull_request:
branches:
- master

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.HMCTS_GITHUB_EXUI_APP_ID }}
private_key: ${{ secrets.HMCTS_GITHUB_EXUI_PRIVATE_KEY }}
- uses: actions/checkout@v3
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Populate preview deployment ID
run: |
sed -i 's/PREVIEW_DEPLOYMENT_ID:.*/PREVIEW_DEPLOYMENT_ID: exui-preview-deployment-${{ github.event.number }}/' charts/xui-webapp/values.preview.template.yaml
shell: bash
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "${{ github.event.pull_request.head.ref }}: Setting Preview Deployment ID"
4 changes: 4 additions & 0 deletions api/lib/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import axios, { AxiosInstance } from 'axios';
import { errorInterceptor, requestInterceptor, successInterceptor } from '../interceptors';

export const http: AxiosInstance = axios.create({});
const previewDeploymentId: string = process.env.PREVIEW_DEPLOYMENT_ID;

if (previewDeploymentId) {
axios.defaults.headers.common['hmcts-deployment-id'] = previewDeploymentId;
}
axios.defaults.headers.common['Content-Type'] = 'application/json';
http.interceptors.request.use(requestInterceptor);
http.interceptors.response.use(successInterceptor, errorInterceptor);
1 change: 1 addition & 0 deletions charts/xui-webapp/values.preview.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ nodejs:
SERVICES_CASE_JUDICIAL_API: http://rd-judicial-api-aat.service.core-compute-aat.internal
SERVICES_LOCATION_REF_API_URL: http://rd-location-ref-api-aat.service.core-compute-aat.internal
FEATURE_ACCESS_MANAGEMENT_ENABLED: true
PREVIEW_DEPLOYMENT_ID: exui-preview-deployment-3230
keyVaults:
rpx:
secrets:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@angular/platform-browser-dynamic": "^11.2.14",
"@angular/router": "^11.2.14",
"@edium/fsm": "^2.1.2",
"@hmcts/ccd-case-ui-toolkit": "6.18.3-ConsoleLogs.1",
"@hmcts/ccd-case-ui-toolkit": "6.19.3-RetryCaseRetrievals.1",
"@hmcts/ccpay-web-component": "5.2.8",
"@hmcts/frontend": "0.0.39-alpha",
"@hmcts/media-viewer": "2.9.3",
Expand Down
8 changes: 8 additions & 0 deletions src/app/services/ccd-config/ccd-case.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ export class AppConfig extends AbstractAppConfig {
return this.config.activity_retry;
}

public getTimeoutsForCaseRetrieval() {
return this.config.timeouts_case_retrieval;
}

public getTimeoutsCaseRetrievalArtificialDelay() {
return this.config.timeouts_case_retrieval_artificial_delay;
}

public getActivityBatchCollectionDelayMs() {
return this.config.activity_batch_collection_delay_ms;
}
Expand Down
1 change: 1 addition & 0 deletions src/app/services/logger/logger.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class LoggerService implements ILoggerService {

private setupSwitcherForConsoleLogs() {
this.environmentService.config$.subscribe((config) => {
console.info(`Environment is ${this.environmentService.isProd() ? 'prod' : 'non-prod'}.`);
LoggerService.switchConsoleLogs({ switchOffAll: false });
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/assets/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"activity_batch_collection_delay_ms": 1,
"activity_next_poll_request_ms": 30000,
"activity_retry": 30,
"timeouts_case_retrieval": [
18, 17
],
"timeouts_case_retrieval_artificial_delay": 0,
"activity_url": "/activity",
"activity_max_request_per_batch": 25,
"print_service_url": "/print",
Expand Down
4 changes: 3 additions & 1 deletion src/cases/cases.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import {
RouterHelperService,
SearchFiltersModule,
SearchResultModule,
WorkbasketFiltersModule
WorkbasketFiltersModule,
RetryUtil
} from '@hmcts/ccd-case-ui-toolkit';
import { ExuiCommonLibModule } from '@hmcts/rpx-xui-common-lib';
import { EffectsModule } from '@ngrx/effects';
Expand Down Expand Up @@ -106,6 +107,7 @@ import { effects, reducers } from './store';
ErrorNotifierService,
NavigationNotifierService,
CasesService,
RetryUtil,
CCDAuthService,
HttpService,
HttpErrorService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
CaseEventTrigger,
CaseField,
CasesService,
RetryUtil,
createCaseEventTrigger,
DraftService,
HttpErrorService,
Expand All @@ -34,9 +35,9 @@ import { CaseCreateSubmitComponent } from './case-create-submit.component';
class MockSortService {
public features = {};
// eslint-disable-next-line @typescript-eslint/no-empty-function
public getFeatureToggle() {}
public getFeatureToggle() { }
// eslint-disable-next-line @typescript-eslint/no-empty-function
public getEditorConfiguration() {}
public getEditorConfiguration() { }
}

const EVENT_TRIGGER: CaseEventTrigger = createCaseEventTrigger(
Expand Down Expand Up @@ -78,7 +79,7 @@ const SANITISED_EDIT_FORM: CaseEventData = {
template: '<div></div>'
})

class FakeExuidCcdConnectorComponent {}
class FakeExuidCcdConnectorComponent { }

describe('CaseCreateSubmitComponent', () => {
let component: CaseCreateSubmitComponent;
Expand Down Expand Up @@ -127,6 +128,7 @@ describe('CaseCreateSubmitComponent', () => {
}
},
CasesService,
RetryUtil,
CCDAuthService,
DraftService,
AlertService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing';

import { FormControl } from '@angular/forms';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { RefDataService } from '@hmcts/rpx-xui-common-lib';
import { of } from 'rxjs';
Expand All @@ -17,7 +17,8 @@ describe('StaffSelectLocationComponent', () => {
refDataServiceMock.getLocationsByServiceCodes.and.returnValue(of([]));

await TestBed.configureTestingModule({
imports: [MatAutocompleteModule],
imports: [MatAutocompleteModule,
ReactiveFormsModule],
declarations: [StaffSelectLocationComponent],
providers: [
{ provide: RefDataService, useValue: refDataServiceMock }
Expand Down Expand Up @@ -262,8 +263,11 @@ describe('StaffSelectLocationComponent', () => {
}));

it('should get an array when search term is not an empty string', fakeAsync(() => {
// obsCount added as observable should always run initially
let obsCount = 0;
component.filteredList$.subscribe((result) => {
expect(Array.isArray(result)).toBe(true);
obsCount > 0 ? expect(Array.isArray(result)).toBe(true) : expect(Array.isArray(result)).toBe(false);
obsCount++;
});

component.searchTermFormControl.setValue('123');
Expand All @@ -273,9 +277,10 @@ describe('StaffSelectLocationComponent', () => {

it('should filter out locations based on searchTerm', fakeAsync(() => {
refDataServiceMock.getLocationsByServiceCodes.and.returnValue(of([dummyLocations[0], dummyLocations[1]]));
component.locationsControl.setValue([dummyLocations[0], dummyLocations[1]]);
let obsCount = 0;
component.filteredList$.subscribe((result) => {
expect(result).toEqual([dummyLocations[0]]);
obsCount > 0 ? expect(result).toEqual([dummyLocations[0]]) : expect(Array.isArray(result)).toBe(false);
obsCount++;
});

component.searchTermFormControl.setValue(dummyLocations[0].venue_name);
Expand All @@ -285,14 +290,36 @@ describe('StaffSelectLocationComponent', () => {

it('should fill locations with correct service codes', fakeAsync(() => {
refDataServiceMock.getLocationsByServiceCodes.and.returnValue(of([dummyLocations[0], dummyLocations[1]]));
let obsCount = 0;
component.filteredList$.subscribe((result) => {
expect(result).toEqual([dummyLocations[0]]);
expect(result[0].serviceCodes).toEqual(['BFA1', 'AAA7']);
if (obsCount > 1) {
expect(result).toEqual([dummyLocations[0]]);
expect(result[0].serviceCodes).toEqual(['BFA1', 'AAA7']);
}
obsCount++;
});
component.searchTermFormControl.setValue(dummyLocations[0].venue_name);
tick();
flush();
}));

it('should correctly set service codes for locations in formControl', fakeAsync(() => {
refDataServiceMock.getLocationsByServiceCodes.and.returnValue(of([dummyLocations[0], dummyLocations[1]]));
const mockLocationInControl: any = dummyLocations[0];
// also ensures we are checking numbers as well as strings
mockLocationInControl.location_id = parseInt(mockLocationInControl.epimms_id);
component.locationsControl.setValue([mockLocationInControl]);
let obsCount = 0;
component.filteredList$.subscribe((result) => {
obsCount > 0 ? expect(result).toEqual([dummyLocations[0]]) : expect(result).toEqual(false);
expect(component.locationsControl.value[0].serviceCodes[0]).toEqual('BFA1');
obsCount++;
});

component.searchTermFormControl.setValue(dummyLocations[0].venue_name);
tick();
flush();
}));
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
import { RefDataService } from '@hmcts/rpx-xui-common-lib';
import { combineLatest, iif, Observable, of } from 'rxjs';
import { map, switchMap, tap } from 'rxjs/operators';
import { map, startWith, switchMap, tap } from 'rxjs/operators';
import { LocationByEpimmsModelWithServiceCodes } from '../../../../models/location-by-service-code-model';
import { StaffUserLocation } from '../../../../models/staff-user-location.model';

Expand All @@ -22,6 +22,8 @@ export class StaffSelectLocationComponent implements OnInit {
public autocompleteSelectedLocation: LocationByEpimmsModelWithServiceCodes | false;
private fullLocations: LocationByEpimmsModelWithServiceCodes[];

private initialLocationServicesSet = false;

public get selectedLocations(): StaffUserLocation[] {
return this.locationsControl?.value;
}
Expand All @@ -30,7 +32,7 @@ export class StaffSelectLocationComponent implements OnInit {

public ngOnInit() {
this.filteredList$ = combineLatest([
this.searchTermFormControl.valueChanges,
this.searchTermFormControl.valueChanges.pipe(startWith('')),
this.serviceCodes$
]).pipe(
tap(([term]: [string, string[]]) => {
Expand All @@ -39,7 +41,7 @@ export class StaffSelectLocationComponent implements OnInit {
}
}),
switchMap(([term, serviceCodes]: [string, string[]]) => iif(
() => (!!term && term.length >= 0),
() => ((!!term && term.length >= 0) || !this.initialLocationServicesSet),
this.refDataService.getLocationsByServiceCodes(
serviceCodes
).pipe(
Expand All @@ -64,19 +66,20 @@ export class StaffSelectLocationComponent implements OnInit {

private setLocationServiceCodes(locations: LocationByEpimmsModelWithServiceCodes[]): LocationByEpimmsModelWithServiceCodes[] {
locations.map((location) => {
const currentId = location.epimms_id;
const currentId = location.epimms_id.toString();
const serviceCodes = location.serviceCodes;
location.serviceCodes = this.getAllServiceCodes(serviceCodes, currentId);
});
// EUI-8051 - as well as setting the correct service codes for new locations, we need to edit them for existing locations
// note: we could edit location types to produce less code - i.e. making them the same
const fixedSelectedLocations = this.locationsControl.value;
fixedSelectedLocations.forEach((location) => {
const currentId = location.location_id;
const serviceCodes = location.service_codes;
const currentId = location.location_id.toString();
const serviceCodes = location.service_codes ? location.service_codes : [];
location.service_codes = this.getAllServiceCodes(serviceCodes, currentId);
});
this.locationsControl.setValue(fixedSelectedLocations);
this.initialLocationServicesSet = true;
return locations;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface LocationByEpimmsModelWithServiceCodes {
epimms_id: string;
location_id?: string;
site_name?: string;
court_name?: string;
open_for_public?: string;
Expand Down
2 changes: 1 addition & 1 deletion yarn-audit-known-issues

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2386,12 +2386,12 @@ __metadata:
languageName: node
linkType: hard

"@hmcts/ccd-case-ui-toolkit@npm:6.18.3-ConsoleLogs.1":
version: 6.18.3-ConsoleLogs.1
resolution: "@hmcts/ccd-case-ui-toolkit@npm:6.18.3-ConsoleLogs.1"
"@hmcts/ccd-case-ui-toolkit@npm:6.19.3-RetryCaseRetrievals.1":
version: 6.19.3-RetryCaseRetrievals.1
resolution: "@hmcts/ccd-case-ui-toolkit@npm:6.19.3-RetryCaseRetrievals.1"
dependencies:
tslib: ^2.0.0
checksum: b8612d60d8cd86303ef6ac126f99f4a00973133a5cf60fc8147120efa783a87b969ff2169163481cbd47c0387f17c44203041d9f046e4d36e789d25780626a45
checksum: 804b26964c596540b05e0c88baadda0f07a4d3a9aaa5ca6782d3d9879ae01f7e6cfb59e4892483385a9d4a8428e709b06f64efa0b99518039ade9e81ced3175c
languageName: node
linkType: hard

Expand Down Expand Up @@ -19270,7 +19270,7 @@ __metadata:
"@angular/platform-browser-dynamic": ^11.2.14
"@angular/router": ^11.2.14
"@edium/fsm": ^2.1.2
"@hmcts/ccd-case-ui-toolkit": 6.18.3-ConsoleLogs.1
"@hmcts/ccd-case-ui-toolkit": 6.19.3-RetryCaseRetrievals.1
"@hmcts/ccpay-web-component": 5.2.8
"@hmcts/frontend": 0.0.39-alpha
"@hmcts/media-viewer": 2.9.3
Expand Down

0 comments on commit 8b6eedd

Please sign in to comment.