Skip to content

Commit

Permalink
Update README.md (#1698)
Browse files Browse the repository at this point in the history
* Update README.md

* PRL-6535-sonar

* PRL-6535-sonar

* PRL-6535-sonar

* PRL-6535-sonar

* remove duplicate line
  • Loading branch information
sealDebolina authored Oct 29, 2024
1 parent a8f193f commit 04652a0
Show file tree
Hide file tree
Showing 80 changed files with 969 additions and 3,100 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# prl-citizen-frontend
## prl-citizen-frontend

Updated with Release 4.0

Expand Down
1 change: 0 additions & 1 deletion charts/prl-citizen-frontend/values.preview.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ nodejs:
COS_URL: 'http://prl-cos-aat.service.core-compute-aat.internal'
REASONABLE_ADJUSTMENTS: 'https://cui-ra.aat.platform.hmcts.net'
FACT_URL: 'http://fact-api-aat.service.core-compute-aat.internal'
REASONABLE_ADJUSTMENTS: 'https://cui-ra.{{ .Values.global.environment }}.platform.hmcts.net'
REDIS_HOST: 'prl-citizen-frontend-secondary-redis-{{ .Values.global.environment }}.redis.cache.windows.net'
LAUNCH_DARKLY_OFFLINE_MODE: false
C100_REBUILD_FLAG: false
Expand Down
18 changes: 9 additions & 9 deletions config/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ services:
url: 'https://api.os.uk/search/places/v1'
token: POSTCODE_TOKEN
authProvider:
url: 'http://rpe-service-auth-provider-demo.service.core-compute-demo.internal'
url: 'http://rpe-service-auth-provider-aat.service.core-compute-aat.internal'
microservice: 'prl_citizen_frontend'
secret: 'NEED TO INSERT SECRET'
idam:
authorizationURL: 'https://idam-web-public.demo.platform.hmcts.net/login'
tokenURL: 'https://idam-api.demo.platform.hmcts.net/o/token'
authorizationURL: 'https://idam-web-public.aat.platform.hmcts.net/login'
tokenURL: 'https://idam-api.aat.platform.hmcts.net/o/token'
clientID: 'prl-citizen-frontend'
citizenClientSecret:
cosApiClientSecret:
Expand All @@ -21,18 +21,18 @@ services:
citizen:
uploadDocsEmail: UPLOAD_DOCUMENTS_EMAIL
case:
url: 'http://ccd-data-store-api-demo.service.core-compute-demo.internal'
url: 'http://ccd-data-store-api-aat.service.core-compute-aat.internal'
cos:
url: 'http://prl-cos-demo.service.core-compute-demo.internal'
url: 'http://prl-cos-aat.service.core-compute-aat.internal'
documentManagement:
url: 'http://ccd-case-document-am-api-demo.service.core-compute-demo.internal'
url: 'http://ccd-case-document-am-api-aat.service.core-compute-aat.internal'
fact:
url: 'http://fact-api-demo.service.core-compute-demo.internal'
url: 'http://fact-api-aat.service.core-compute-aat.internal'
reasonableAdjustments:
url: 'https://cui-ra.demo.platform.hmcts.net'
url: 'https://cui-ra.aat.platform.hmcts.net'
equalityAndDiversity:
name: 'Equality and Diversity Service'
url: 'https://pcq.demo.platform.hmcts.net'
url: 'https://pcq.aat.platform.hmcts.net'
path: '/service-endpoint'
tokenKey: PCQ_TOKEN
health:
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sonar.tests=src/test/
sonar.test.exclusions=src/**/*.njk
sonar.typescript.lcov.reportPaths=coverage/lcov.info
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.exclusions=src/**/*.test.ts,src/main/steps/tasklistresponse/responseCaseSequence.ts,src/main/steps/tasklistresponse/tasklistresponseCaseSequence.ts**/__mocks__/**,src/**/content.ts,src/main/steps/applicant/applicantCaseSequence.ts,src/main/steps/respondent/respondentcaseSequence.ts,src/main/steps/common/task-list/components/tasklist/config/*.ts,src/main/steps/common/task-list/components/notification-banner/*/*.ts,src/main/steps/common/task-list/components/side-links/config/*.ts,src/main/steps/common/task-list/components/side-links/content.ts,src/main/steps/tasklistresponse/summary/handler.ts,src/main/app/case/C100CaseApi.ts,src/main/steps/common/task-list/components/tasklist/utils.ts
sonar.exclusions=src/**/*.test.ts,**/__mocks__/**,src/**/*content.ts,src/main/steps/common/task-list/components/tasklist/config/*.ts,src/main/steps/common/task-list/components/notification-banner/*/*.ts,src/main/steps/common/task-list/components/side-links/config/*.ts,src/main/steps/common/task-list/components/side-links/content.ts
sonar.organization=hmcts
sonar.cpd.typescript.minimumLines=250
sonar.cpd.javascript.minimumLines=250
Expand Down
3 changes: 2 additions & 1 deletion src/main/app/address/AddressLookupPostControllerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default class AddressLookupPostControllerBase extends PostController<AnyO
Object.assign(req.session.userCase, formData);

const redirectUrl = this.setRedirectUrl();
const matcher = new RegExp(/^[A-Z]{1,2}\d[A-Z0-9]? ?\d[A-Z]{2}$/i);

if (!req.body.citizenUserAddressPostcode) {
req.session.errors = [];
Expand All @@ -36,7 +37,7 @@ export default class AddressLookupPostControllerBase extends PostController<AnyO
errorType: 'required',
});
req.session.save(() => res.redirect(redirectUrl));
} else if (!(req.body.citizenUserAddressPostcode as string).match(/^[A-Z]{1,2}\d[A-Z0-9]? ?\d[A-Z]{2}$/i)) {
} else if (!matcher.test(req.body.citizenUserAddressPostcode as string)) {
req.session.errors = [];
req.session.errors?.push({
propertyName: 'citizenUserAddressPostcode',
Expand Down
12 changes: 6 additions & 6 deletions src/main/app/case/CaseApi.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
// const results = {
// data: {
// id: '1234',
// state: State.Draft,
// state: State.AWAITING_SUBMISSION_TO_HMCTS,
// data: {},
// },
// };
Expand All @@ -71,7 +71,7 @@

// expect(userCase).toStrictEqual({
// id: '1234',
// state: State.Draft,
// state: State.AWAITING_SUBMISSION_TO_HMCTS,
// });
// });

Expand Down Expand Up @@ -103,12 +103,12 @@
// test('Should retrieve the first case if two cases found', async () => {
// const firstMockCase = {
// id: '1',
// state: State.Draft,
// state: State.AWAITING_SUBMISSION_TO_HMCTS,
// case_data: {},
// };
// // const secondMockCase = {
// // id: '2',
// // state: State.Draft,
// // state: State.AWAITING_SUBMISSION_TO_HMCTS,
// // case_data: {},
// // };

Expand All @@ -120,7 +120,7 @@

// expect(userCase).toStrictEqual({
// id: '1',
// state: State.Draft,
// state: State.AWAITING_SUBMISSION_TO_HMCTS,
// });
// });

Expand Down Expand Up @@ -191,7 +191,7 @@
// mockedAxios.get.mockResolvedValue({
// data: {
// id: '1234',
// state: State.Draft,
// state: State.AWAITING_SUBMISSION_TO_HMCTS,
// data: {},
// },
// });
Expand Down
4 changes: 2 additions & 2 deletions src/main/app/case/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,8 @@ export interface CaseWithId extends Case {
id: string;
state: State;
applicantTemporaryFormData?: {
TempFirstName?: string | unknown;
TempLastName?: string | unknown;
TempFirstName?: string;
TempLastName?: string;
};
applicationPayOnline?: YesOrNo;
legalRepresentativeForProceedings?: YesOrNo;
Expand Down
9 changes: 0 additions & 9 deletions src/main/app/case/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2653,15 +2653,6 @@ export interface C1ASafteyConcernsAbuse {
childrenConcernedAbout?: string[];
}

export interface PRL_C1ASafteyConcernsAbuse {
behaviourDetails?: string;
behaviourStartDate?: string;
isOngoingBehaviour?: YesNoEmpty;
seekHelpFromPersonOrAgency?: YesNoEmpty;
seekHelpDetails?: string;
childrenConcernedAbout?: string[];
}

export interface C1ASafteyConcerns {
child?: {
physicalAbuse?: C1ASafteyConcernsAbuse;
Expand Down
2 changes: 1 addition & 1 deletion src/main/app/controller/GetController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('GetController', () => {
const getContentMock = jest.fn().mockReturnValue({});
const controller = new GetController('page', getContentMock);

const req = mockRequest({ userCase: { state: State.Draft }, session: { errors: [] } });
const req = mockRequest({ userCase: { state: State.AWAITING_SUBMISSION_TO_HMCTS }, session: { errors: [] } });
const res = mockResponse();
await controller.get(req, res);

Expand Down
4 changes: 2 additions & 2 deletions src/main/app/controller/GetController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class GetController {
...content,
sessionErrors,
htmlLang: language,
caseId: req.session.userCase?.caseId || req.session.userCase?.id,
caseId: req.session.userCase?.caseId ?? req.session.userCase?.id,
paymentError: req.session.paymentError,
document_type,
breadcrumbs: BreadcrumbController.get(req.session, language),
Expand Down Expand Up @@ -105,7 +105,7 @@ export class GetController {

// Browsers default language
const negotiator = new Negotiator(req);
return negotiator.language(LanguageToggle.supportedLanguages) || 'en';
return negotiator.language(LanguageToggle.supportedLanguages) ?? 'en';
}

private getCaption(req: AppRequest) {
Expand Down
10 changes: 4 additions & 6 deletions src/main/app/form/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ export class Form {

// if there are checkboxes or options, check them for errors
if (isFormOptions(field)) {
const valuesErrors = field.values.flatMap(value => this.getErrorsFromField(body, value.name || id, value));
const valuesErrors = field.values.flatMap(value => this.getErrorsFromField(body, value.name ?? id, value));

errors.push(...valuesErrors);
}
// if there are subfields and the current field is selected then check for errors in the subfields
else if (field.subFields) {
if (body[id] === field.value || (body[id] && body[id].includes(field.value))) {
if (body[id] === field.value || body[id]?.includes(field.value)) {
const subFields = Object.entries(field.subFields);
const subFieldErrors = subFields.flatMap(([subId, subField]) => this.getErrorsFromField(body, subId, subField));

Expand Down Expand Up @@ -122,15 +122,13 @@ export type LanguageLookup = (lang: Record<string, never>) => string;
type Parser = (value: Record<string, unknown> | string[]) => void;

export type LabelFormFormatter = {
text?: string | never;
text?: string;
classes?: string;
isPageHeading?: boolean;
};

type Label = LabelFormFormatter | string | LanguageLookup;

type Warning = Label;

export type ValidationCheck = (
value: string | string[] | CaseDate | undefined,
formData: Partial<Case>
Expand Down Expand Up @@ -228,7 +226,7 @@ export interface FormInput {
attributes?: Partial<HTMLInputElement | HTMLTextAreaElement>;
validator?: ValidationCheck;
parser?: Parser;
warning?: Warning;
warning?: Label;
conditionalText?: Label;
subFields?: Record<string, FormField>;
open?: boolean;
Expand Down
4 changes: 0 additions & 4 deletions src/main/app/form/validation copy.ts

This file was deleted.

32 changes: 19 additions & 13 deletions src/main/app/form/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export type Validator = (
export type DateValidator = (value: CaseDate | undefined) => void | string;

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
export type AnyType = any;
export const enum ValidationError {
REQUIRED = 'required',
NOT_SELECTED = 'notSelected',
Expand Down Expand Up @@ -141,9 +140,9 @@ export const isInvalidHelpWithFeesRef: Validator = value => {
if (fieldNotFilledIn) {
return fieldNotFilledIn;
}

const matcher = new RegExp(/^HWF-[A-Z0-9]{3}-[A-Z0-9]{3}$/i);
if (typeof value === 'string') {
if (!value.match(/^HWF-[A-Z0-9]{3}-[A-Z0-9]{3}$/i)) {
if (!matcher.test(value)) {
return 'invalid';
}

Expand All @@ -158,26 +157,29 @@ export const isInvalidPostcode: Validator = value => {
if (fieldNotFilledIn) {
return fieldNotFilledIn;
}

if (!(value as string).match(/^[A-Z]{1,2}\d[A-Z0-9]? ?\d[A-Z]{2}$/i)) {
const matcher = new RegExp(/^[A-Z]{1,2}\d[A-Z0-9]? ?\d[A-Z]{2}$/i);
if (!matcher.test(value as string)) {
return 'invalid';
}
};

export const isPhoneNoValid: Validator = value => {
if (typeof value === 'string') {
return !value.match(/^$|^[0-9 +().-]{11,}$/) ? 'invalid' : undefined;
const matcher = new RegExp(/^$|^[0-9 +().-]{11,}$/);
return !matcher.test(value) ? 'invalid' : undefined;
}
};

export const isAlphaNumeric: Validator = value => {
if (typeof value === 'string') {
return !value.match(/^[a-zA-Z0-9_\s]*$/) ? 'invalid' : undefined;
const matcher = new RegExp(/^[a-zA-Z0-9_\s]*$/);
return !matcher.test(value) ? 'invalid' : undefined;
}
};
export const isAlphaNumericWithApostrophe: Validator = value => {
if (typeof value === 'string') {
return !value.match(/^[a-zA-Z0-9'_\s]*$/) ? 'invalid' : undefined;
const matcher = new RegExp(/^[a-zA-Z0-9'_\s]*$/);
return !matcher.test(value) ? 'invalid' : undefined;
}
};
export const isEmailValid: Validator = value => {
Expand All @@ -187,13 +189,16 @@ export const isEmailValid: Validator = value => {
};

export const isFieldLetters: Validator = value => {
if (!(value as string).match(/^[\p{Script=Latin}'’\-\s]*$/gu)) {
const matcher = new RegExp(/^[\p{Script=Latin}'’\-\s]*$/gu);
if (!matcher.test(value as string)) {
return 'invalid';
}
};

export const isValidCaseReference: Validator = value => {
if (!(value as string).match(/^\d{16}$/) && !(value as string).match(/^\d{4}-\d{4}-\d{4}-\d{4}$/)) {
const matcher = new RegExp(/^\d{4}-\d{4}-\d{4}-\d{4}$/);
const matcher1 = new RegExp(/^\d{16}$/);
if (!matcher1.test(value as string) && !matcher.test(value as string)) {
return 'invalid';
}
};
Expand Down Expand Up @@ -236,20 +241,21 @@ export const isAccessCodeValid: Validator = value => {
};

export const isNumeric: Validator = value => {
if (value && !(value as string).match(/^\d+$/)) {
const matcher = new RegExp(/^\d+$/);
if (value && !matcher.test(value as string)) {
return ValidationError.NOT_NUMERIC;
}
};

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
export const isFileSizeGreaterThanMaxAllowed = (files: any): boolean => {
const { documents }: AnyType = files;
const { documents } = files;
return documents.size > C100MaxFileSize;
};

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
export const isValidFileFormat = (files: any): boolean => {
const { documents }: AnyType = files;
const { documents } = files;
const extension = documents.name.toLowerCase().split('.')[documents.name.split('.').length - 1];
return AllowedFileExtentionList.indexOf(extension) > -1;
};
Expand Down
11 changes: 11 additions & 0 deletions src/main/app/utils/featureToggles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ describe('FeatureToggles', () => {
it('should throw an error if toggle does not exist', () => {
expect(() => FeatureToggles.hasAnyAuthorisedFeature([])).to.throw(Error);
});
it('should not throw an error feature names are provided', () => {
expect(FeatureToggles.hasAnyAuthorisedFeature([], ...['c100Rebuild'])).equal(false);
});
it('should not throw an error feature names are provided -diffent array object', () => {
expect(() => FeatureToggles.hasAnyAuthorisedFeature(['c100Rebuild'], ...['testingSupport'])).not.to.throw(Error);
});
it('should not throw an error feature names are provided -some matching array object', () => {
expect(() =>
FeatureToggles.hasAnyAuthorisedFeature(['c100Rebuild', 'testingSupport'], ...['testingSupport'])
).not.to.throw(Error);
});
});

describe('isEnabled', () => {
Expand Down
5 changes: 1 addition & 4 deletions src/main/app/utils/featureToggles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ export class FeatureToggles {
throw new Error('At least one feature name has to be provided');
}

return features.some(
feature =>
FeatureToggles.isEnabled(feature) && authorisedFeatures !== undefined && authorisedFeatures.includes(feature)
);
return features.some(feature => FeatureToggles.isEnabled(feature) && authorisedFeatures?.includes(feature));
}

static isAnyEnabled(...featureNames: string[]): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/main/modules/properties-volume/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class PropertiesVolume {
* Load a secret from the aat vault using azure cli
*/
private setLocalSecret(secret: string, toPath: string): void {
const result = execSync(`az keyvault secret show --vault-name prl-demo -o tsv --query value --name ${secret}`);
const result = execSync(`az keyvault secret show --vault-name prl-aat -o tsv --query value --name ${secret}`);
set(config, toPath, result.toString().replace('\n', ''));
}
}
2 changes: 1 addition & 1 deletion src/main/steps/applicant/task-list/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Applicant } from '../../../app/case/definition';

export const getApplicantAllegationsOfHarmAndViolence = (userCase: CaseWithId): boolean => {
let flag = false;
if (userCase && userCase.allegationsOfHarmYesNo) {
if (userCase?.allegationsOfHarmYesNo) {
flag = true;
}
return flag;
Expand Down
Loading

0 comments on commit 04652a0

Please sign in to comment.