Skip to content

Commit

Permalink
Merge branch 'main' into PRMP-1188
Browse files Browse the repository at this point in the history
  • Loading branch information
steph-torres-nhs authored Jan 3, 2025
2 parents 85ea123 + 018cc07 commit 26f26de
Show file tree
Hide file tree
Showing 33 changed files with 228 additions and 220 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/subscribe-to-mns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ on:
sandbox:
required: true
type: string
secrets:
AWS_ASSUME_ROLE:
required: true
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
Expand Down
2 changes: 1 addition & 1 deletion app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The National Document Repository user interface (UI) has been developed with Rea

### 1. Set Env Variables

Create a `.env` file by duplicating [.env.template](.env.template) and adding any missing values. This file is sourced to
In the app/ directory create a `.env` file by duplicating the [.env.template](.env.template) and adding any missing values. This file is sourced to
your shell env so make sure it doesn't have any extra whitespace, comments etc.
The `local` environment variable will allow your local app to bypass auth and mock most lambda requests.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Feature flags - Lloyd George Workflow', () => {
});
cy.title().should(
'eq',
'Verify patient details - Access and store digital patient documents',
'Patient details - Access and store digital patient documents',
);

cy.get('#verify-submit').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const downloadPageTitle =
const downloadingPageTitle = 'Downloading documents - Access and store digital patient documents';
const downloadCompletePageTitle = 'Download complete - Access and store digital patient documents';
const verifyPatientPageTitle =
'Verify patient details - Access and store digital patient documents';
'Patient details - Access and store digital patient documents';
const lloydGeorgeRecordPageTitle = 'Available records - Access and store digital patient documents';
const testFiles = [
{
Expand Down Expand Up @@ -171,9 +171,6 @@ describe('GP Workflow: View Lloyd George record', () => {
// Assert contents of page when downloading
cy.getByTestId('lloyd-george-download-header').should('exist');
cy.getByTestId('cancel-download-link').should('exist');
cy.getByTestId('download-file-header-' + testFiles.length + '-files').should(
'exist',
);

// Assert contents of page after download
cy.wait('@documentManifestCompleted');
Expand Down Expand Up @@ -225,7 +222,6 @@ describe('GP Workflow: View Lloyd George record', () => {
cy.title().should('eq', downloadingPageTitle);
// Assert contents of page when downloading
cy.getByTestId('lloyd-george-download-header').should('exist');
cy.getByTestId('download-file-header-2-files').should('exist');

cy.getByTestId('cancel-download-link').should('exist');

Expand Down Expand Up @@ -289,8 +285,6 @@ describe('GP Workflow: View Lloyd George record', () => {
cy.title().should('eq', downloadingPageTitle);
// Assert contents of page when downloading
cy.getByTestId('lloyd-george-download-header').should('exist');
cy.getByTestId('download-file-header-1-files').should('exist');

cy.getByTestId('cancel-download-link').should('exist');

// Assert contents of page after download
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ describe('GP Workflow: Patient search and verify', () => {
cy.wait('@search');
cy.title().should(
'eq',
'Verify patient details - Access and store digital patient documents',
'Patient details - Access and store digital patient documents',
);

cy.url().should('include', 'verify');
cy.url().should('eq', baseUrl + patientVerifyUrl);
cy.get('#gp-message').should('be.visible');
cy.get('#gp-message').should(
'have.text',
'Check these patient details match the records or attachments you plan to use',
'This page displays the current data recorded in the Patient Demographic Service for this patient.',
);
cy.get('#verify-submit').click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ describe('GP Workflow: View Lloyd George record', () => {
assertPatientInfo();
cy.getByTestId('pdf-card')
.should('include.text', 'Lloyd George record')
.should('include.text', 'Last updated: 09 October 2023 at 15:41:38')
.should('include.text', '12 files | File size: 502 KB | File format: PDF');
.should('include.text', 'Last updated: 09 October 2023 at 15:41:38');
cy.getByTestId('pdf-viewer').should('be.visible');

// Act - open full screen view
Expand Down
2 changes: 1 addition & 1 deletion app/cypress/e2e/0-ndr-core-tests/homepage.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Home Page', () => {
});

it('displays service banner', { tags: 'regression' }, () => {
cy.get('.govuk-phase-banner__content__tag').should('have.text', 'New Service');
cy.get('.govuk-phase-banner__content__tag').should('have.text', 'New service');
cy.get('.govuk-phase-banner__text').should(
'have.text',
'Your feedback will help us to improve this service.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ describe('LloydGeorgeDownloadStage', () => {

const renderComponent = (history: MemoryHistory, propsOverride?: Partial<Props>) => {
const props: Omit<Props, 'setStage' | 'setDownloadStage'> = {
numberOfFiles: mockPdf.numberOfFiles,
deleteAfterDownload: false,
...propsOverride,
numberOfFiles: mockPdf.numberOfFiles,
};

return render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ function LloydGeorgeDownloadStage({
filename: '',
});
const linkRef = useRef<HTMLAnchorElement | null>(null);

const pageDownloadCountId = 'download-file-header-' + numberOfFiles + '-files';
const mounted = useRef(false);
const navigate = useNavigate();
const { mockLocal } = useConfig();
const patientDetails = usePatient();
const nhsNumber = patientDetails?.nhsNumber ?? '';
const [delayTimer, setDelayTimer] = useState<NodeJS.Timeout>();

const pageDownloadCountId = 'download-file-header-' + numberOfFiles + '-files';

const progressTimer = useMemo(() => {
return new FakeProgress({
timeConstant: timeToComplete,
Expand Down Expand Up @@ -145,7 +143,6 @@ function LloydGeorgeDownloadStage({
navigate,
mockLocal,
selectedDocuments,
numberOfFiles,
]);

const pageHeader = 'Downloading documents';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { render, screen } from '@testing-library/react';
import LgRecordDetails, { Props } from './LloydGeorgeRecordDetails';
import { buildLgSearchResult } from '../../../../helpers/test/testBuilders';
import formatFileSize from '../../../../helpers/utils/formatFileSize';

const mockPdf = buildLgSearchResult();

Expand All @@ -19,20 +18,13 @@ describe('LloydGeorgeRecordDetails', () => {
renderComponent();

expect(screen.getByText(`Last updated: ${mockPdf.lastUpdated}`)).toBeInTheDocument();
expect(screen.getByText(`${mockPdf.numberOfFiles} files`)).toBeInTheDocument();
expect(
screen.getByText(`File size: ${formatFileSize(mockPdf.totalFileSizeInBytes)}`),
).toBeInTheDocument();
expect(screen.getByText('File format: PDF')).toBeInTheDocument();
});
});
});

const renderComponent = (propsOverride?: Partial<Props>) => {
const props: Props = {
lastUpdated: mockPdf.lastUpdated,
numberOfFiles: mockPdf.numberOfFiles,
totalFileSizeInBytes: mockPdf.totalFileSizeInBytes,
...propsOverride,
};
return render(<LgRecordDetails {...props} />);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import React from 'react';
import formatFileSize from '../../../../helpers/utils/formatFileSize';

export type Props = {
lastUpdated: string;
numberOfFiles: number;
totalFileSizeInBytes: number;
};

function LloydGeorgeRecordDetails({ lastUpdated, numberOfFiles, totalFileSizeInBytes }: Props) {
function LloydGeorgeRecordDetails({ lastUpdated }: Props) {
return (
<div className="lloydgeorge_record-details">
<div className="lloydgeorge_record-details_details">
<div className="lloydgeorge_record-details_details--last-updated">
Last updated: {lastUpdated}
</div>
<div className="lloydgeorge_record-details_details--num-files">
<span>{numberOfFiles} files</span>
{' | '}
<span>File size: {formatFileSize(totalFileSizeInBytes)}</span>
{' | '}
<span>File format: PDF</span>
{' |'}
</div>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import useRole from '../../../../helpers/hooks/useRole';
import useIsBSOL from '../../../../helpers/hooks/useIsBSOL';
import useConfig from '../../../../helpers/hooks/useConfig';
import { act, render, screen, waitFor } from '@testing-library/react';
import formatFileSize from '../../../../helpers/utils/formatFileSize';
import { DOWNLOAD_STAGE } from '../../../../types/generic/downloadStage';
import { getFormattedDate } from '../../../../helpers/utils/formatDate';
import userEvent from '@testing-library/user-event';
Expand Down Expand Up @@ -62,11 +61,6 @@ describe('LloydGeorgeViewRecordStage', () => {
expect(screen.getByText('View in full screen')).toBeInTheDocument();
expect(screen.getByText('Lloyd George record')).toBeInTheDocument();
expect(screen.getByText(`Last updated: ${mockPdf.lastUpdated}`)).toBeInTheDocument();
expect(screen.getByText(`${mockPdf.numberOfFiles} files`)).toBeInTheDocument();
expect(
screen.getByText(`File size: ${formatFileSize(mockPdf.totalFileSizeInBytes)}`),
).toBeInTheDocument();
expect(screen.getByText('File format: PDF')).toBeInTheDocument();

expect(
screen.queryByText('No documents are available for this patient.'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import RecordCard from '../../../generic/recordCard/RecordCard';
import RecordMenuCard from '../../../generic/recordMenuCard/RecordMenuCard';
import useTitle from '../../../../helpers/hooks/useTitle';
import { routeChildren } from '../../../../types/generic/routes';
import { routes, routeChildren } from '../../../../types/generic/routes';
import { useNavigate } from 'react-router-dom';
import PatientSimpleSummary from '../../../generic/patientSimpleSummary/PatientSimpleSummary';
import ProgressBar from '../../../generic/progressBar/ProgressBar';
Expand Down Expand Up @@ -97,8 +97,6 @@ function LloydGeorgeViewRecordStage({
const recordDetailsProps: RecordDetailsProps = {
downloadStage,
lastUpdated,
numberOfFiles,
totalFileSizeInBytes,
};

const pageHeader = 'Available records';
Expand Down Expand Up @@ -128,7 +126,10 @@ function LloydGeorgeViewRecordStage({
Exit full screen
</BackLink>
) : (
<BackButton />
<BackButton
toLocation={routes.VERIFY_PATIENT}
backLinkText="Go back to Patient details"
/>
)}
{!fullScreen && userIsGpAdminNonBSOL && (
<div className="lloydgeorge_record-stage_gp-admin-non-bsol">
Expand Down Expand Up @@ -258,17 +259,9 @@ function LloydGeorgeViewRecordStage({
);
}

type RecordDetailsProps = Pick<
Props,
'downloadStage' | 'lastUpdated' | 'numberOfFiles' | 'totalFileSizeInBytes'
>;
type RecordDetailsProps = Pick<Props, 'downloadStage' | 'lastUpdated'>;

const RecordDetails = ({
downloadStage,
lastUpdated,
numberOfFiles,
totalFileSizeInBytes,
}: RecordDetailsProps) => {
const RecordDetails = ({ downloadStage, lastUpdated }: RecordDetailsProps) => {
switch (downloadStage) {
case DOWNLOAD_STAGE.INITIAL:
case DOWNLOAD_STAGE.PENDING:
Expand All @@ -277,8 +270,6 @@ const RecordDetails = ({
case DOWNLOAD_STAGE.SUCCEEDED: {
const detailsProps = {
lastUpdated,
numberOfFiles,
totalFileSizeInBytes,
};
return <LloydGeorgeRecordDetails {...detailsProps} />;
}
Expand Down
13 changes: 13 additions & 0 deletions app/src/components/generic/backButton/BackButton.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,17 @@ export const BackButton: Story = {
args: {},
};

export const WithCustomText: Story = {
args: {
backLinkText: 'navigate to ...',
},
};

export const WithCustomToLocationAndText: Story = {
args: {
toLocation: '/specified-location',
backLinkText: 'navigate to /specified-location',
},
};

export default meta;
26 changes: 26 additions & 0 deletions app/src/components/generic/backButton/BackButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,30 @@ describe('BackButton', () => {
expect(mockUseNavigate).toHaveBeenCalledWith(-1);
});
});

it('navigates to specified location when the "toLocation" property is defined' , async () => {

render(<BackButton toLocation="/specified-location" />);
userEvent.click( screen.getByText('Go back'));

await waitFor(() => {
expect(mockUseNavigate).toHaveBeenCalledWith('/specified-location');
});

});

it('displays default back link text when "backLinkText" is not provided', async () => {

render(<BackButton toLocation="/specified-location" />);
expect(screen.getByText('Go back')).toBeInTheDocument();

});

it('displays custom back link text when "backLinkText" is defined', async () => {

render(<BackButton backLinkText="navigate to ..." />);
expect(screen.getByText('navigate to ...')).toBeInTheDocument();

});

});
13 changes: 10 additions & 3 deletions app/src/components/generic/backButton/BackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@ import React from 'react';
import type { MouseEvent } from 'react';
import { useNavigate } from 'react-router-dom';

const BackButton = () => {
interface BackButtonProps {
toLocation?: string;
backLinkText?: string;
}

const BackButton = ({ toLocation, backLinkText = 'Go back' }: BackButtonProps) => {
const navigate = useNavigate();

const onBack = (e: MouseEvent<HTMLAnchorElement>) => {
e.preventDefault();
navigate(-1);

if (toLocation) navigate(toLocation);
else navigate(-1);
};

return (
<BackLink onClick={onBack} href="#">
Go back
{backLinkText}
</BackLink>
);
};
Expand Down
10 changes: 3 additions & 7 deletions app/src/components/generic/recordMenuCard/RecordMenuCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,9 @@ const SideMenuSubSection = ({ actionLinks, heading, setStage }: SubSectionProps)
return (
<>
<h2 className="nhsuk-heading-m">{heading}</h2>
<ol>
{actionLinks.map((link) => (
<li key={link.key}>
<LinkItem link={link} setStage={setStage} />
</li>
))}
</ol>
{actionLinks.map((link) => (
<LinkItem key={link.key} link={link} setStage={setStage} />
))}
</>
);
};
Expand Down
5 changes: 4 additions & 1 deletion app/src/components/layout/footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ function Footer() {
Privacy notice
</NHSFooter.ListItem>
</NHSFooter.List>
<NHSFooter.Copyright>&copy; {'Crown copyright'}</NHSFooter.Copyright>
{/* TODO - PRMP-1348: Remove hardcoded styling below if no longer required */}
<NHSFooter.Copyright style={{ color: '#231f20' }}>
&copy; {'NHS England'}
</NHSFooter.Copyright>
</NHSFooter>
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/layout/phaseBanner/PhaseBanner.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('PhaseBanner', () => {
it('renders PhaseBanner with content', () => {
renderComponent();

expect(screen.getByText('New Service')).toBeInTheDocument();
expect(screen.getByText('New service')).toBeInTheDocument();

expect(screen.getByText(/Your/i)).toBeInTheDocument();
expect(screen.getByText(/feedback/i)).toBeInTheDocument();
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/layout/phaseBanner/PhaseBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function PhaseBanner() {
<div className="nhsuk-width-container">
<div className="govuk-phase-banner__content">
<strong className="govuk-tag govuk-phase-banner__content__tag">
New Service
New service
</strong>
<p className="govuk-phase-banner__text">
Your {linkToFeedbackPage} will help us to improve this service.
Expand Down
Loading

0 comments on commit 26f26de

Please sign in to comment.