Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { ReviewDetails } from '../../../../types/generic/reviews';
import * as getReviewsModule from '../../../../helpers/requests/getReviews';
import { DOCUMENT_TYPE } from '../../../../helpers/utils/documentType';
import { buildPatientDetails } from '../../../../helpers/test/testBuilders';

const mockedUseNavigate = vi.fn();
const mockSetPatientDetails = vi.fn();
Expand Down Expand Up @@ -375,7 +376,7 @@ describe('ReviewDetailsAssessmentPage', () => {
});

it('displays patient demographics', async () => {
mockUsePatientDetailsContext.mockReturnValue([null, mockSetPatientDetails]);
mockUsePatientDetailsContext.mockReturnValue([buildPatientDetails(), mockSetPatientDetails]);

render(
<ReviewDetailsAssessmentStage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '../../../../types/pages/UploadDocumentsPage/types';
import { routeChildren } from '../../../../types/generic/routes';
import '../../../../helpers/utils/string-extensions';
import { buildPatientDetails } from '../../../../helpers/test/testBuilders';

vi.mock('../../../../helpers/utils/documentType');
vi.mock('../../../../helpers/hooks/useTitle', () => ({
Expand Down Expand Up @@ -134,7 +135,9 @@ describe('ReviewDetailsFileSelectStage', () => {
expect(screen.queryByText('existing.pdf')).not.toBeInTheDocument();
});

it('renders patient demograhics', () => {
it('renders patient demographics', () => {
mockUsePatientDetailsContext.mockReturnValue([buildPatientDetails(), mockSetPatientDetails]);

const documents: ReviewUploadDocument[] = [
makeReviewDoc('file1.pdf', DOCUMENT_UPLOAD_STATE.UNSELECTED, UploadDocumentType.REVIEW),
makeReviewDoc(
Expand All @@ -144,7 +147,7 @@ describe('ReviewDetailsFileSelectStage', () => {
),
];

renderApp({ reviewData: mockReviewData, uploadDocuments: documents });
renderApp({ reviewData: mockReviewData, uploadDocuments: documents, mockPatientContext: false });

expect(screen.getByTestId('patient-summary')).toBeInTheDocument();
expect(screen.getByTestId('patient-summary-full-name')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ const ReviewsDetailsStage = ({
)}

<RecordLayout
heading={reviewConfig.content.viewDocumentTitle as string}
heading={reviewConfig.content.reviewDocumentTitle as string}
fullScreenHandler={null}
detailsElement={<RecordLoader {...recordDetailsProps} />}
isFullScreen={session.isFullscreen || false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,21 @@ describe('ReviewsPage', () => {
if (snomed === '16521000000101') {
return {
content: {
reviewList: 'Lloyd George',
reviewDocumentTitle: 'Scanned paper notes',
},
displayName: 'Lloyd George Record',
displayName: 'scanned paper notes',
};
} else if (snomed === '717391000000106') {
return {
content: {
reviewList: 'Electronic Health Record',
reviewDocumentTitle: 'Electronic health record',
},
displayName: 'Electronic Health Record',
displayName: 'electronic health record',
};
}
return {
content: {
reviewList: 'Unknown Type',
reviewDocumentTitle: 'Unknown Type',
},
displayName: 'Unknown Type',
};
Expand Down Expand Up @@ -289,8 +289,8 @@ describe('ReviewsPage', () => {
});

expect(screen.getByText('900 000 0002')).toBeInTheDocument();
expect(screen.getByText('Lloyd George')).toBeInTheDocument();
expect(screen.getByText('Electronic Health Record')).toBeInTheDocument();
expect(screen.getByText('Scanned paper notes')).toBeInTheDocument();
expect(screen.getByText('Electronic health record')).toBeInTheDocument();
expect(screen.getByText('Y12345')).toBeInTheDocument();
expect(screen.getByText('Y67890')).toBeInTheDocument();
});
Expand Down Expand Up @@ -334,10 +334,10 @@ describe('ReviewsPage', () => {
renderComponent();

await waitFor(() => {
expect(screen.getByText('Lloyd George')).toBeInTheDocument();
expect(screen.getByText('Scanned paper notes')).toBeInTheDocument();
});

expect(screen.getByText('Electronic Health Record')).toBeInTheDocument();
expect(screen.getByText('Electronic health record')).toBeInTheDocument();
});

it('displays "Unknown Type" for unrecognized SNOMED codes', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export const ReviewsPage = ({ setReviewData }: ReviewsPageProps): React.JSX.Elem
let recordType: string = '';
try {
recordType = getConfigForDocType(dto.documentSnomedCodeType).content
.reviewList as string;
.reviewDocumentTitle as string;
} catch {}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,26 @@ describe('DeleteSubmitStage', () => {
});
});

it('renders DeletionCompleteStage when the Yes is selected and Continue clicked, when user role is PCSE and feature flag is disabled', async () => {
mockedUseRole.mockReturnValue(REPOSITORY_ROLE.PCSE);

mockedAxios.delete.mockReturnValue(Promise.resolve({ status: 200, data: 'Success' }));

renderComponent(DOCUMENT_TYPE.LLOYD_GEORGE, history);

expect(screen.getByRole('radio', { name: 'Yes' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Continue' })).toBeInTheDocument();

await userEvent.click(screen.getByRole('radio', { name: 'Yes' }));
await userEvent.click(screen.getByRole('button', { name: 'Continue' }));

await waitFor(() => {
expect(mockedUseNavigate).toHaveBeenCalledWith(
routeChildren.DOCUMENT_DELETE_COMPLETE,
);
});
});

it('renders DeletionCompleteStage when the Yes is selected and Continue clicked, when user role is GP_ADMIN and feature flag is enabled', async () => {
mockedUseRole.mockReturnValue(REPOSITORY_ROLE.GP_ADMIN);
mockuseConfig.mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const DeleteSubmitStageIndexView = ({
resetDocState();
setDeletionStage(SUBMISSION_STATE.SUCCEEDED);
navigate(
config.featureFlags.uploadDocumentIteration3Enabled
config.featureFlags.uploadDocumentIteration3Enabled || role === REPOSITORY_ROLE.PCSE
? routeChildren.DOCUMENT_DELETE_COMPLETE
: routeChildren.LLOYD_GEORGE_DELETE_COMPLETE,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ describe('DocumentUploadCompleteStage', () => {

const expectedDob = getFormattedDate(new Date(patientDetails.birthDate));
expect(screen.getByTestId('dob').textContent).toEqual('Date of birth: ' + expectedDob);

expect(
screen.queryByText(
'You are not the data controller',
{
exact: false,
}
),
).not.toBeInTheDocument();
});

it('should navigate to search when clicking the search link', async () => {
Expand Down Expand Up @@ -153,6 +162,25 @@ describe('DocumentUploadCompleteStage', () => {
expect(screen.getByText(documents[1].file.name)).toBeInTheDocument();
});

it('should render non-data controller message when user is not data controller', async () => {
vi.mocked(usePatient).mockReturnValueOnce(
buildPatientDetails({
canManageRecord: false,
}),
);

renderApp(documents);

expect(
screen.getByText(
'You are not the data controller',
{
exact: false,
}
),
).toBeInTheDocument();
});

const renderApp = (documents: UploadDocument[]) => {
render(
<MemoryRouter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ const DocumentUploadCompleteStage = ({ documents, documentConfig }: Props): Reac
</p>
)}

{patientDetails.canManageRecord === false && (
<p>
You are not the data controller for this patient so you cannot view the files
you have uploaded in this service.
</p>
)}

<p>
If you think you've made a mistake, contact the Patient Record Management team at{' '}
<a href="mailto:england.prmteam@nhs.net">england.prmteam@nhs.net</a>.
Expand Down
Loading
Loading