Skip to content

Commit

Permalink
update ver num, update getCaseFlagsRefdata to always add available-ex…
Browse files Browse the repository at this point in the history
…ternal-flag, update tests (#1716)

Co-authored-by: Ritesh Dsouza <[email protected]>
  • Loading branch information
Josh-HMCTS and RiteshHMCTS authored Aug 6, 2024
1 parent d21086e commit fa5a167
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
2 changes: 2 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## RELEASE NOTES

### Version 7.0.55
**EXUI-1775** Refdata intend to change

### Version 7.0.54
**EXUI-2085** Add Task completion logs in app insight
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.54",
"version": "7.0.55",
"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.54",
"version": "7.0.55",
"engines": {
"node": ">=18.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('Case Flag Refdata Service', () => {
next: flagTypes => expect(flagTypes).toEqual(dummyFlagsData.flags[0].FlagDetails)
});

const req = httpMock.expectOne(caseFlagsRefdataApiUrl.replace(':sid', 'BBA3'));
const req = httpMock.expectOne(caseFlagsRefdataApiUrl.replace(':sid', 'BBA3')+'?available-external-flag=N');
expect(req.request.method).toEqual('GET');
req.flush(dummyFlagsData);
});
Expand All @@ -106,7 +106,7 @@ describe('Case Flag Refdata Service', () => {
next: flagTypes => expect(flagTypes).toEqual(dummyFlagsData.flags[0].FlagDetails)
});

const req = httpMock.expectOne(`${caseFlagsRefdataApiUrl.replace(':sid', 'BBA3')}?flag-type=${RefdataCaseFlagType.PARTY}`);
const req = httpMock.expectOne(`${caseFlagsRefdataApiUrl.replace(':sid', 'BBA3')}?flag-type=${RefdataCaseFlagType.PARTY}&available-external-flag=N`);
expect(req.request.method).toEqual('GET');
req.flush(dummyFlagsData);
});
Expand All @@ -117,7 +117,7 @@ describe('Case Flag Refdata Service', () => {
});

const req = httpMock.expectOne(
`${caseFlagsRefdataApiUrl.replace(':sid', 'BBA3')}?flag-type=${RefdataCaseFlagType.PARTY}&welsh-required=Y`);
`${caseFlagsRefdataApiUrl.replace(':sid', 'BBA3')}?flag-type=${RefdataCaseFlagType.PARTY}&welsh-required=Y&available-external-flag=N`);
expect(req.request.method).toEqual('GET');
req.flush(dummyFlagsData);
});
Expand All @@ -127,7 +127,7 @@ describe('Case Flag Refdata Service', () => {
next: flagTypes => expect(flagTypes).toEqual(dummyFlagsData.flags[0].FlagDetails)
});

const req = httpMock.expectOne(`${caseFlagsRefdataApiUrl.replace(':sid', 'BBA3')}?welsh-required=N`);
const req = httpMock.expectOne(`${caseFlagsRefdataApiUrl.replace(':sid', 'BBA3')}?welsh-required=N&available-external-flag=N`);
expect(req.request.method).toEqual('GET');
req.flush(dummyFlagsData);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,26 @@ export class CaseFlagRefdataService {
*/
public getCaseFlagsRefdata(serviceId: string, flagType?: RefdataCaseFlagType, welshRequired?: boolean, externalFlagsOnly?: boolean): Observable<FlagType[]> {
let url = this.appConfig.getCaseFlagsRefdataApiUrl();

if (url) {
url = url.replace(':sid', serviceId);
const requestSearchParams = new URLSearchParams();
if (flagType) {
url += `?flag-type=${flagType}`;
requestSearchParams.set('flag-type', flagType);
}
if (typeof welshRequired === 'boolean') {
// Check if flag-type has been added to the query string; if so, append welsh-required with '&'
url.indexOf('?') > -1 ? url += '&' : url += '?';
welshRequired ? url += 'welsh-required=Y' : url += 'welsh-required=N';
}

if (externalFlagsOnly) {
// Check if anything has been added to the query string; if so, append available-external-flag with '&'
url.indexOf('?') > -1 ? url += '&' : url += '?';
url += 'available-external-flag=Y';
const welshFlagValue = welshRequired ? 'Y' : 'N';
requestSearchParams.set('welsh-required', welshFlagValue);
}

const externalFlagsValue = externalFlagsOnly ? 'Y' : 'N';
requestSearchParams.set('available-external-flag', externalFlagsValue);
url = `${url}?${requestSearchParams.toString()}`;
return this.http
.get(url, {observe: 'body'})
.get(url, { observe: 'body' })
.pipe(
// Reference Data Common API returns a single object with a "flags" array, which itself contains a single object
// with a "FlagDetails" array, which contains a hierarchy of flag types in an object - one each for "Party" flags
// and "Case" flags
map(body => {
map((body) => {
if (!body || !body.flags || !body.flags.length || !body.flags[0].FlagDetails || !body.flags[0].FlagDetails.length) {
// Note: Reference Data Common API appears to respond with a 404 error rather than send an empty response,
// so this may be redundant
Expand Down

0 comments on commit fa5a167

Please sign in to comment.