Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into PRMP-1287
Browse files Browse the repository at this point in the history
  • Loading branch information
NogaNHS committed Jan 3, 2025
2 parents f2d88b2 + 90207ac commit ca9ed2b
Show file tree
Hide file tree
Showing 23 changed files with 799 additions and 98 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/base-lambdas-reusable-deploy-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,17 @@ jobs:
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

deploy_mns_notification_lambda:
name: Deploy mns notification 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: mns_notification_handler
lambda_aws_name: MNSNotificationLambda
lambda_layer_names: 'core_lambda_layer'
secrets:
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}

55 changes: 43 additions & 12 deletions .github/workflows/subscribe-to-mns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,59 @@ name: Subscribe to MNS
on:
workflow_dispatch:
inputs:
build_branch:
sandbox:
description: Which sandbox would you like to run against?
required: true
type: string
type: choice
options:
- ndr-dev
- ndr-test
- pre-prod
- prod
environment:
description: Which environment settings to use?
required: true
type: string
sandbox:
required: true
type: string
default: development

permissions:
pull-requests: write
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

env:
SANDBOX: ${{ inputs.sandbox }}
AWS_REGION: ${{ vars.AWS_REGION }}
URL: ${{ vars.MNS_SUBSCRIPTION_URL }}

jobs:
placeholder:
Subscribe_to_MNS:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
defaults:
run:
working-directory: lambdas
steps:
- name: Placeholder
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
role-skip-session-tagging: true
aws-region: ${{ vars.AWS_REGION }}
mask-aws-account-id: true

- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'

- name: Install dependencies
run: |
echo "Running placeholder job on ${inputs.sandbox}"
pip install boto3 requests pyjwt cryptography
echo "Installed requirements"
- name: Run script
working-directory: ./lambdas
run: |
python3 -m scripts.mns_subscription
echo "Subscription complete"
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
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 @@ -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 @@ -126,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
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
42 changes: 18 additions & 24 deletions app/src/pages/patientResultPage/PatientResultPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jest.mock('../../helpers/hooks/usePatient');
const mockedUseRole = useRole as jest.Mock;
const mockedUsePatient = usePatient as jest.Mock;

const PAGE_HEADER_TEXT = 'Patient details'
const PAGE_TEXT = "This page displays the current data recorded in the Patient Demographic Service for this patient."
const CONFIRM_BUTTON_TEXT = 'Confirm patient details and continue'

describe('PatientResultPage', () => {
beforeEach(() => {
process.env.REACT_APP_ENVIRONMENT = 'jest';
Expand All @@ -32,7 +36,7 @@ describe('PatientResultPage', () => {
it('displays component', () => {
render(<PatientResultPage />);

expect(screen.getByText('Verify patient details')).toBeInTheDocument();
expect(screen.getByText(PAGE_HEADER_TEXT)).toBeInTheDocument();
});

it.each(authorisedRoles)(
Expand All @@ -47,23 +51,13 @@ describe('PatientResultPage', () => {
render(<PatientResultPage />);

expect(
screen.getByRole('heading', { name: 'Verify patient details' }),
screen.getByRole('heading', { name: PAGE_HEADER_TEXT }),
).toBeInTheDocument();
expect(screen.getByText(familyName)).toBeInTheDocument();
expect(
screen.getByRole('button', { name: 'Accept details are correct' }),
screen.getByRole('button', { name: CONFIRM_BUTTON_TEXT }),
).toBeInTheDocument();
expect(screen.getByText(/If patient details are incorrect/)).toBeInTheDocument();

const nationalServiceDeskLink = screen.getByRole('link', {
name: /National Service Desk/,
});

expect(nationalServiceDeskLink).toHaveAttribute(
'href',
'https://digital.nhs.uk/about-nhs-digital/contact-us#nhs-digital-service-desks',
);
expect(nationalServiceDeskLink).toHaveAttribute('target', '_blank');
},
);

Expand All @@ -79,11 +73,11 @@ describe('PatientResultPage', () => {
render(<PatientResultPage />);

expect(
screen.getByRole('heading', { name: 'Verify patient details' }),
screen.getByRole('heading', { name: PAGE_HEADER_TEXT }),
).toBeInTheDocument();
expect(
screen.getByText(
'Check these patient details match the records or attachments you plan to use',
PAGE_TEXT ,
),
).toBeInTheDocument();
},
Expand All @@ -100,7 +94,7 @@ describe('PatientResultPage', () => {
render(<PatientResultPage />);

expect(
screen.getByRole('heading', { name: 'Verify patient details' }),
screen.getByRole('heading', { name: PAGE_HEADER_TEXT }),
).toBeInTheDocument();

expect(screen.queryByText('Select patient status')).not.toBeInTheDocument();
Expand All @@ -110,7 +104,7 @@ describe('PatientResultPage', () => {
).not.toBeInTheDocument();
expect(
screen.queryByText(
'Check these patient details match the records or attachments you plan to use',
PAGE_TEXT,
),
).not.toBeInTheDocument();
});
Expand All @@ -127,7 +121,7 @@ describe('PatientResultPage', () => {
act(() => {
userEvent.click(
screen.getByRole('button', {
name: 'Accept details are correct',
name: CONFIRM_BUTTON_TEXT,
}),
);
});
Expand All @@ -148,7 +142,7 @@ describe('PatientResultPage', () => {
render(<PatientResultPage />);

expect(
screen.getByRole('heading', { name: 'Verify patient details' }),
screen.getByRole('heading', { name: PAGE_HEADER_TEXT }),
).toBeInTheDocument();
expect(
screen.getByText('The NHS number for this patient has changed.'),
Expand All @@ -167,7 +161,7 @@ describe('PatientResultPage', () => {
render(<PatientResultPage />);

expect(
screen.getByRole('heading', { name: 'Verify patient details' }),
screen.getByRole('heading', { name: PAGE_HEADER_TEXT }),
).toBeInTheDocument();
expect(
screen.getByText(
Expand All @@ -190,7 +184,7 @@ describe('PatientResultPage', () => {
render(<PatientResultPage />);

expect(
screen.getByRole('heading', { name: 'Verify patient details' }),
screen.getByRole('heading', { name: PAGE_HEADER_TEXT }),
).toBeInTheDocument();

const results = await runAxeTest(document.body);
Expand Down Expand Up @@ -237,7 +231,7 @@ describe('PatientResultPage', () => {
act(() => {
userEvent.click(
screen.getByRole('button', {
name: 'Accept details are correct',
name: CONFIRM_BUTTON_TEXT,
}),
);
});
Expand All @@ -259,7 +253,7 @@ describe('PatientResultPage', () => {

act(() => {
userEvent.click(
screen.getByRole('button', { name: 'Accept details are correct' }),
screen.getByRole('button', { name: CONFIRM_BUTTON_TEXT }),
);
});

Expand All @@ -275,7 +269,7 @@ describe('PatientResultPage', () => {

render(<PatientResultPage />);

userEvent.click(screen.getByRole('button', { name: 'Accept details are correct' }));
userEvent.click(screen.getByRole('button', { name: CONFIRM_BUTTON_TEXT }));

await waitFor(() => {
expect(mockedUseNavigate).toHaveBeenCalledWith(routes.ARF_OVERVIEW);
Expand Down
Loading

0 comments on commit ca9ed2b

Please sign in to comment.