Skip to content

Commit

Permalink
PRMDR-676: Update server error page descriptions (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
abbas-khan10 authored Apr 11, 2024
1 parent 9452dea commit 519c6ea
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 37 deletions.
71 changes: 39 additions & 32 deletions app/src/helpers/utils/errorCodes.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
const technicalIssueMsg = 'There is a technical issue on our side';
const accountVerifyMsg = 'There was an error verifying your account details';
const roleAccessMsg = 'There was an error verifying your role access';
const createFileMsg = 'There was problem when creating files for the patient';
const patientFileRetrievalMsg = 'There was an error retrieving files for the patient record';
const feedbackMsg = 'Your feedback failed to send';

const errorCodes: { [key: string]: string } = {
CDR_5001: 'Internal error',
CDR_5002: 'Internal error',
DT_5001: 'Failed to resolve dynamodb table name for this document',
LR_5001: 'Server error',
LIN_5001: 'Unrecognised state value',
LIN_5002: 'Issue when contacting CIS2',
LIN_5003: 'Bad response from ODS API',
LIN_5004: 'Unable to remove used state value',
LIN_5005: 'Failed to find SSM parameter value for user role',
LIN_5006: 'Failed to find SSM parameter value for user role',
LIN_5007: 'Failed to find SSM parameter value for smartcard',
LIN_5008: 'Failed to find SSM parameter value for PCSE role',
LIN_5009: 'Failed to find SSM parameter value for GP role',
LIN_5010: 'SSM parameter values for PSCE ODS err_code may not exist',
DMS_5001: 'Failed to parse document reference from from DynamoDb response',
DMS_5002: 'Failed to create document manifest',
DMS_5003: 'Failed to create document manifest',
LGS_5001: 'Unable to retrieve documents for patient',
LGS_5002: 'Unable to return stitched pdf file due to internal error',
LGS_5003: 'Unable to retrieve documents for patient',
LGS_5004: 'Unable to retrieve documents for patient',
DRS_5001: 'An error occurred when searching for available documents',
DDS_5001: 'Failed to delete documents',
OUT_5001: 'Error logging user out',
ENV_5001: 'An error occurred due to missing environment variable',
GWY_5001: 'Failed to utilise AWS client/resource',
SFB_5001: 'Error occur when sending email by SES',
SFB_5002: 'Failed to fetch parameters for sending email from SSM param store',
FFL_5001: 'Failed to parse feature flag/s from AppConfig response',
FFL_5002: 'Failed to retrieve feature flag/s from AppConfig profile',
FFL_5003: 'Feature is not enabled',
LGL_423: 'Record is uploading. Wait a few minutes and try again.',
CDR_5001: 'There was an unexplained error',
CDR_5002: technicalIssueMsg,
DT_5001: technicalIssueMsg,
LR_5001: 'There is a problem with the server',
LIN_5001: 'The details entered did not match',
LIN_5002: 'There is an issue reaching the Care Identity Service (CIS)',
LIN_5003: technicalIssueMsg,
LIN_5004: 'There was an error responding to your request',
LIN_5005: accountVerifyMsg,
LIN_5006: accountVerifyMsg,
LIN_5007: 'There was an error verifying your smartcard details',
LIN_5008: roleAccessMsg,
LIN_5009: roleAccessMsg,
LIN_5010: accountVerifyMsg,
DMS_5001: createFileMsg,
DMS_5002: createFileMsg,
DMS_5003: createFileMsg,
LGS_5001: 'There was an error retrieving the patient record',
LGS_5002: 'There was an error combining files for the patient record',
LGS_5003: patientFileRetrievalMsg,
LGS_5004: patientFileRetrievalMsg,
DRS_5001: 'There was an error searching for patient files',
DDS_5001: 'The files failed to delete',
OUT_5001: 'There was a problem logging you out',
ENV_5001: technicalIssueMsg,
GWY_5001: technicalIssueMsg,
SFB_5001: feedbackMsg,
SFB_5002: feedbackMsg,
FFL_5001: technicalIssueMsg,
FFL_5002: technicalIssueMsg,
FFL_5003: technicalIssueMsg,
LGL_423: 'Record is uploading. Wait a few minutes and try again',
};

export default errorCodes;
24 changes: 20 additions & 4 deletions app/src/pages/serverErrorPage/ServerErrorPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('ServerErrorPage', () => {
name: 'Sorry, there is a problem with the service',
}),
).toBeInTheDocument();
expect(screen.getByText('An unknown error has occurred.')).toBeInTheDocument();
expect(screen.getByText('There was an unexplained error')).toBeInTheDocument();
expect(
screen.getByText(
"Try again by returning to the previous page. You'll need to enter any information you submitted again.",
Expand Down Expand Up @@ -69,8 +69,24 @@ describe('ServerErrorPage', () => {
name: 'Sorry, there is a problem with the service',
}),
).toBeInTheDocument();
expect(screen.getByText('Internal error')).toBeInTheDocument();
expect(screen.queryByText('An unknown error has occurred.')).not.toBeInTheDocument();
expect(screen.getByText('There was an unexplained error')).toBeInTheDocument();
expect(screen.getByText(mockInteractionId)).toBeInTheDocument();
});

it('renders page content with non-default error message and id when there is a valid error code with interaction id', () => {
const mockErrorCode = 'CDR_5002';
const mockInteractionId = '000-000';
const mockEncoded = btoa(JSON.stringify([mockErrorCode, mockInteractionId]));
jest.spyOn(URLSearchParams.prototype, 'get').mockReturnValue(mockEncoded);
render(<ServerErrorPage />);

expect(
screen.getByRole('heading', {
name: 'Sorry, there is a problem with the service',
}),
).toBeInTheDocument();
expect(screen.getByText('There is a technical issue on our side')).toBeInTheDocument();
expect(screen.queryByText('There was an unexplained error')).not.toBeInTheDocument();
expect(screen.getByText(mockInteractionId)).toBeInTheDocument();
});

Expand All @@ -86,7 +102,7 @@ describe('ServerErrorPage', () => {
name: 'Sorry, there is a problem with the service',
}),
).toBeInTheDocument();
expect(screen.getByText('An unknown error has occurred.')).toBeInTheDocument();
expect(screen.getByText('There was an unexplained error')).toBeInTheDocument();
expect(screen.getByText(mockInteractionId)).toBeInTheDocument();
expect(screen.queryByText(mockErrorCode)).not.toBeInTheDocument();
});
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/serverErrorPage/ServerErrorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ServerErrorPage = () => {
const error: ServerError = encodedError ? JSON.parse(atob(encodedError)) : [null, null];
const [errorCode, interactionId] = error;

const defaultMessage = 'An unknown error has occurred.';
const defaultMessage = 'There was an unexplained error';

const errorMessage =
errorCode && !!errorCodes[errorCode] ? errorCodes[errorCode] : defaultMessage;
Expand Down

0 comments on commit 519c6ea

Please sign in to comment.