Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/lambdas/requirements/layers/p…
Browse files Browse the repository at this point in the history
…ip-60b803aef9
  • Loading branch information
abbas-khan10 authored Jan 20, 2025
2 parents 22eb280 + a29502b commit c2bf8df
Show file tree
Hide file tree
Showing 90 changed files with 2,058 additions and 361 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/base-cypress-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
repository: 'nhsconnect/national-document-repository'
ref: ${{ github.event.inputs.build_branch }}

- name: Cypress install
Expand Down Expand Up @@ -49,7 +50,7 @@ jobs:
working-directory: ./app

- name: Save build folder
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build
if-no-files-found: error
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/base-cypress-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
repository: 'nhsconnect/national-document-repository'
ref: ${{ inputs.build_branch }}

- name: Download the build folder
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: build
path: ./app/build
Expand Down
37 changes: 36 additions & 1 deletion .github/workflows/base-lambdas-reusable-deploy-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ on:
required: true
type: 'string'
sandbox:
description: 'Which Sandbox to push to'
description: 'Which Sandbox to push to?'
required: true
type: 'string'
is_sandbox:
description: 'Is this deploying to a sandbox?'
required: false
default: false
type: boolean
secrets:
AWS_ASSUME_ROLE:
required: true
Expand Down Expand Up @@ -94,6 +99,20 @@ jobs:
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

deploy_delete_document_object_handler:
name: Deploy delete_document_object_handler
uses: ./.github/workflows/base-lambdas-reusable-deploy.yml
with:
environment: ${{ inputs.environment}}
python_version: ${{ inputs.python_version }}
build_branch: ${{ inputs.build_branch}}
sandbox: ${{ inputs.sandbox }}
lambda_handler_name: delete_document_object_handler
lambda_aws_name: DeleteDocumentObjectS3
lambda_layer_names: 'core_lambda_layer'
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

deploy_document_manifest_job_lambda:
name: Deploy document_manifest_job_lambda
uses: ./.github/workflows/base-lambdas-reusable-deploy.yml
Expand Down Expand Up @@ -389,6 +408,21 @@ jobs:
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

deploy_get_document_reference_lambda:
name: Deploy get nrl document reference lambda
uses: ./.github/workflows/base-lambdas-reusable-deploy.yml
with:
environment: ${{ inputs.environment}}
python_version: ${{ inputs.python_version }}
build_branch: ${{ inputs.build_branch}}
sandbox: ${{ inputs.sandbox }}
lambda_handler_name: nrl_get_document_reference_handler
lambda_aws_name: GetDocumentReference
lambda_layer_names: 'core_lambda_layer'
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}


deploy_edge_presign_lambda:
name: Deploy edge presign cloudfront lambda
uses: ./.github/workflows/base-lambdas-edge-deploy.yml
Expand All @@ -403,6 +437,7 @@ jobs:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

deploy_mns_notification_lambda:
if: ${{ ! inputs.is_sandbox }}
name: Deploy mns notification lambda
uses: ./.github/workflows/base-lambdas-reusable-deploy.yml
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/full-deploy-to-sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
sandbox: ${{ inputs.sandbox }}
environment: ${{ inputs.environment }}
python_version: "3.11"
is_sandbox: true
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lambdas-deploy-feature-to-sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
python_version: "3.11"
build_branch: ${{ inputs.build_branch }}
sandbox: ${{ inputs.sandbox }}
is_sandbox: true
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/lambdas-dev-to-main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
- main
paths:
- 'lambdas/**'
workflow_call:
secrets:
AWS_ASSUME_ROLE:
required: true

permissions:
pull-requests: write
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ui-dev-to-main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
- main
paths:
- 'app/**'
workflow_call:
secrets:
AWS_ASSUME_ROLE:
required: true

permissions:
pull-requests: write
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import authPayload from '../../../fixtures/requests/auth/GET_TokenRequest_GP_ADMIN.json';
import { Roles } from '../../../support/roles';
import dbItem from '../../../fixtures/dynamo-db-items/active-patient.json';
import searchPatientPayload from '../../../fixtures/requests/GET_SearchPatientLGUpload.json';

describe('Authentication & Authorisation', () => {
const baseUrl = Cypress.config('baseUrl');
Expand Down Expand Up @@ -86,4 +88,42 @@ describe('Authentication & Authorisation', () => {
},
);
});

context('Page refresh redirection ', () => {
const workspace = Cypress.env('WORKSPACE');
dbItem.FileLocation = dbItem.FileLocation.replace('{env}', workspace);

const lloydGeorgeRecordUrl = '/patient/lloyd-george-record';
const verifyUrl = '/patient/verify';
const patientSearchUrl = '/patient/search';

it(
'Refreshing the browser after searching for a patient will return the user to the patient search page',
{ tags: 'regression ', defaultCommandTimeout: 20000 },
() => {
cy.login(Roles.GP_ADMIN);
cy.visit(patientSearchUrl);

cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
body: searchPatientPayload,
}).as('search');
cy.intercept('POST', '/LloydGeorgeStitch*', {
statusCode: 404,
}).as('stitch');

cy.getByTestId('nhs-number-input').type(searchPatientPayload.nhsNumber);
cy.getByTestId('search-submit-btn').click();

cy.url().should('contain', verifyUrl);
cy.get('#verify-submit').click();

cy.url().should('contain', lloydGeorgeRecordUrl);

cy.reload();

cy.url().should('contain', patientSearchUrl);
},
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,29 @@ const downloadPageTitle =
'Download the Lloyd George record for this patient - Access and store digital patient documents';
const downloadingPageTitle = 'Downloading documents - Access and store digital patient documents';
const downloadCompletePageTitle = 'Download complete - Access and store digital patient documents';
const verifyPatientPageTitle =
'Patient details - Access and store digital patient documents';
const verifyPatientPageTitle = 'Patient details - Access and store digital patient documents';
const lloydGeorgeRecordPageTitle = 'Available records - Access and store digital patient documents';
const testFiles = [
{
fileName: '1of2_testy_test.pdf',
created: '2024-05-07T14:52:00.827602Z',
virusScannerResult: 'Clean',
id: 'test-id',
fileSize: 200,
},
{
fileName: '2of2_testy_test.pdf',
created: '2024-05-07T14:52:00.827602Z',
virusScannerResult: 'Clean',
id: 'test-id-2',
fileSize: 200,
},
{
fileName: '1of1_lone_test_file.pdf',
created: '2024-01-01T14:52:00.827602Z',
virusScannerResult: 'Clean',
id: 'test-id-3',
fileSize: 200,
},
];

Expand All @@ -40,6 +42,7 @@ const singleTestFile = [
created: '2024-01-01T14:52:00.827602Z',
virusScannerResult: 'Clean',
id: 'test-id-3',
fileSize: 200,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ describe('GP Workflow: Upload Lloyd George record', () => {
'You can upload full or part of a patient record',
);
cy.getByTestId('upload-patient-record-button').should('exist');
cy.contains('Control and F').should('not exist');
cy.getByTestId('upload-patient-record-button').click();
uploadedFilePathNames.forEach((file) => {
cy.getByTestId('button-input').selectFile(file, { force: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ describe('LloydGeorgeDownloadStage', () => {

const expectedTestId = 'download-file-header-' + mockPdf.numberOfFiles + '-files';
expect(screen.getByTestId(expectedTestId)).toBeInTheDocument();
expect(screen.getByTestId('cancel-download-link')).toHaveTextContent(
'Cancel and return to patient record',
);
});

it('renders a progress bar', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ function LloydGeorgeDownloadStage({
const onPageLoad = async () => {
progressTimer.stop();
window.clearInterval(intervalTimer);
if (!nhsNumber) {
navigate(routes.SEARCH_PATIENT);
return;
}
try {
const preSignedUrl = await getPresignedUrlForZip({
baseUrl,
Expand Down Expand Up @@ -189,7 +193,7 @@ function LloydGeorgeDownloadStage({
navigate(routes.LLOYD_GEORGE);
}}
>
Cancel
Cancel and return to patient record
</Link>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ function LloydGeorgeSelectDownloadStage({
useEffect(() => {
const onPageLoad = async () => {
setSubmissionSearchState(SEARCH_AND_DOWNLOAD_STATE.SEARCH_PENDING);
if (!nhsNumber) {
navigate(routes.SEARCH_PATIENT);
return;
}
try {
// This check is in place for when we navigate directly to a full download,
// in that instance we do not need to get a list of selectable files as we will download all files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import usePatient from '../../../../helpers/hooks/usePatient';
import { LinkProps } from 'react-router-dom';
import LloydGeorgeSelectSearchResults, { Props } from './LloydGeorgeSelectSearchResults';
import userEvent from '@testing-library/user-event';
import { routes } from '../../../../types/generic/routes';
import { SEARCH_AND_DOWNLOAD_STATE } from '../../../../types/pages/documentSearchResultsPage/types';
import { runAxeTest } from '../../../../helpers/test/axeTestHelper';

Expand Down Expand Up @@ -57,6 +56,20 @@ describe('LloydGeorgeSelectSearchResults', () => {
expect(screen.getByTestId('toggle-selection-btn')).toBeInTheDocument();
});

it('renders the correct table headers', () => {
renderComponent({ selectedDocuments: mockSelectedDocuments });

const headers = screen.getAllByRole('columnheader');
const expectedHeaders = ['Selected', 'Filename', 'Upload date', 'File size'];

expectedHeaders.forEach((headerText, index) => {
expect(headers[index]).toHaveTextContent(headerText);
});

const filesTable = screen.getByTestId('available-files-table-title');
expect(filesTable).toHaveTextContent(/bytes|KB|MB|GB/);
});

it('shows error box when download selected files button is clicked but no files selected', async () => {
renderComponent({ selectedDocuments: [] });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { SEARCH_AND_DOWNLOAD_STATE } from '../../../../types/pages/documentSearc
import ErrorBox from '../../../layout/errorBox/ErrorBox';
import PatientSummary from '../../../generic/patientSummary/PatientSummary';
import BackButton from '../../../generic/backButton/BackButton';
import formatFileSize from '../../../../helpers/utils/formatFileSize';

export type Props = {
searchResults: Array<SearchResult>;
Expand Down Expand Up @@ -108,6 +109,7 @@ const AvailableFilesTable = ({
)}
<Table.Cell className={'table-column-header'}>Filename</Table.Cell>
<Table.Cell className={'table-column-header'}>Upload date</Table.Cell>
<Table.Cell className={'table-column-header'}>File size</Table.Cell>
</Table.Row>
</Table.Head>
<Table.Body>
Expand Down Expand Up @@ -147,6 +149,12 @@ const AvailableFilesTable = ({
>
{getFormattedDatetime(new Date(result.created))}
</Table.Cell>
<Table.Cell
id={'available-files-row-' + index + '-file-size'}
data-testid="file-size"
>
{formatFileSize(result.fileSize)}
</Table.Cell>
</Table.Row>
))}
</Table.Body>
Expand Down
10 changes: 6 additions & 4 deletions app/src/components/generic/recordCard/RecordCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ function RecordCard({
View in full screen
</button>
)}
<p>
To search within this record use <strong>Control</strong> and{' '}
<strong>F</strong>
</p>
{cloudFrontUrl && (
<p>
To search within this record use <strong>Control</strong> and{' '}
<strong>F</strong>
</p>
)}
</Card.Content>
<div>{children}</div>
</Card>
Expand Down
4 changes: 4 additions & 0 deletions app/src/components/layout/footer/Footer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ describe('Footer', () => {
render(<Footer />);
expect(screen.getByTestId('privacy-link')).toBeInTheDocument();
});
it('renders service updates link', () => {
render(<Footer />);
expect(screen.getByTestId('service-updates-link')).toBeInTheDocument();
});
});

describe('Navigation', () => {
Expand Down
14 changes: 13 additions & 1 deletion app/src/components/layout/footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import React from 'react';
import { Footer as NHSFooter } from 'nhsuk-react-components';
import { routes } from '../../../types/generic/routes';

const serviceUpdatesLink =
'https://digital.nhs.uk/services/access-and-store-digital-patient-documents/service-updates';

function Footer() {
return (
<NHSFooter>
Expand All @@ -11,10 +14,19 @@ function Footer() {
data-testid="privacy-link"
rel="opener"
target="_blank"
aria-label="(Privacy notice - this link will open in a new tab)"
aria-label="Privacy notice - Opens in a new tab"
>
Privacy notice
</NHSFooter.ListItem>
<NHSFooter.ListItem
href={serviceUpdatesLink}
data-testid="service-updates-link"
rel="noopener"
target="_blank"
aria-label="Service updates - Opens in a new tab"
>
Service updates
</NHSFooter.ListItem>
</NHSFooter.List>
{/* TODO - PRMP-1348: Remove hardcoded styling below if no longer required */}
<NHSFooter.Copyright style={{ color: '#231f20' }}>
Expand Down
1 change: 1 addition & 0 deletions app/src/helpers/test/testBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const buildSearchResult = (searchResultOverride?: Partial<SearchResult>) => {
created: moment().format(),
virusScannerResult: 'Clean',
ID: '1234qwer-241ewewr',
fileSize: 224,
...searchResultOverride,
};
return result;
Expand Down
Loading

0 comments on commit c2bf8df

Please sign in to comment.