-
Notifications
You must be signed in to change notification settings - Fork 1
[PRMP-1517] Dont Know NHS Number journey review #1133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lillie-dae
wants to merge
6
commits into
main
Choose a base branch
from
PRMP-1517
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0fcfb49
[PRMP-1517] Dont Know NHS Number journey review
lillie-dae e2326a9
minor fix
lillie-dae 7fed559
minor fix
lillie-dae 92abedb
replace useParam with useReviewId hook
adamwhitingnhs e3862d7
add missed useParam
adamwhitingnhs 764f96f
Merge branch 'main' into PRMP-1517
DuncanSangsterNHS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...wDetailsDontKnowNHSNumberConfirmStage/ReviewDetailsDontKnowNHSNumberConfirmStage.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| import { render, screen, within } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { afterEach, beforeEach, describe, expect, it, vi, Mock } from 'vitest'; | ||
| import ReviewDetailsDontKnowNHSNumberConfirmStage from './ReviewDetailsDontKnowNHSNumberConfirmStage'; | ||
| import useReviewId from '../../../../helpers/hooks/useReviewId'; | ||
|
|
||
| vi.mock('../../../../helpers/utils/documentType'); | ||
| vi.mock('../../../../helpers/hooks/useReviewId'); | ||
|
|
||
| const mockReviewId = 'test-review-123'; | ||
| const mockNavigate = vi.fn(); | ||
| const mockUseReviewId = useReviewId as Mock; | ||
|
|
||
| vi.mock('react-router-dom', async (): Promise<unknown> => { | ||
| const actual = await vi.importActual('react-router-dom'); | ||
| return { | ||
| ...actual, | ||
| useNavigate: (): Mock => mockNavigate, | ||
| useParams: (): { reviewId: string } => ({ reviewId: mockReviewId }), | ||
| Link: ({ children, to, ...props }: any) => ( | ||
| <a href={to} {...props}> | ||
| {children} | ||
| </a> | ||
| ), | ||
| }; | ||
| }); | ||
|
|
||
| describe('ReviewDetailsDontKnowNHSNumberConfirmStage', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| import.meta.env.VITE_ENVIRONMENT = 'vitest'; | ||
| mockUseReviewId.mockReturnValue(mockReviewId); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.clearAllMocks(); | ||
| }); | ||
|
|
||
| describe('Rendering', () => { | ||
| it('renders the page content', () => { | ||
| render(<ReviewDetailsDontKnowNHSNumberConfirmStage />); | ||
|
|
||
| expect( | ||
| screen.getByRole('heading', { | ||
| name: 'Check this document has downloaded to your computer', | ||
| }), | ||
| ).toBeInTheDocument(); | ||
|
|
||
| const callout = screen.getByTestId('review-notification'); | ||
| expect(callout).toBeInTheDocument(); | ||
| expect( | ||
| within(callout).getByText( | ||
| /check this document has downloaded to your computer\. When you finish reviewing/i, | ||
| ), | ||
| ).toBeInTheDocument(); | ||
|
|
||
| expect(screen.getByTestId('back-button')).toBeInTheDocument(); | ||
|
|
||
| expect( | ||
| screen.getByRole('button', { name: 'Finish reviewing this document' }), | ||
| ).toBeInTheDocument(); | ||
|
|
||
| expect( | ||
| screen.getByRole('link', { name: 'Go back to download the document' }), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Navigation', () => { | ||
| it('navigates to the complete patient unknown route when finish reviewing is clicked', async () => { | ||
| const user = userEvent.setup(); | ||
| render(<ReviewDetailsDontKnowNHSNumberConfirmStage />); | ||
|
|
||
| await user.click( | ||
| screen.getByRole('button', { name: 'Finish reviewing this document' }), | ||
| ); | ||
|
|
||
| expect(mockNavigate).toHaveBeenCalledWith( | ||
| `/admin/reviews/${mockReviewId}/complete/patient-unknown`, | ||
| undefined, | ||
| ); | ||
| }); | ||
|
|
||
| it('calls navigate(-1) when the go back link is clicked', async () => { | ||
| const user = userEvent.setup(); | ||
| render(<ReviewDetailsDontKnowNHSNumberConfirmStage />); | ||
|
|
||
| await user.click( | ||
| screen.getByRole('link', { name: 'Go back to download the document' }), | ||
| ); | ||
|
|
||
| expect(mockNavigate).toHaveBeenCalledWith(-1); | ||
| }); | ||
| }); | ||
| }); |
67 changes: 67 additions & 0 deletions
67
...reviewDetailsDontKnowNHSNumberConfirmStage/ReviewDetailsDontKnowNHSNumberConfirmStage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { Button, WarningCallout } from 'nhsuk-react-components'; | ||
| import { JSX } from 'react'; | ||
| import { useNavigate } from 'react-router-dom'; | ||
| import { navigateUrlParam, routeChildren } from '../../../../types/generic/routes'; | ||
| import BackButton from '../../../generic/backButton/BackButton'; | ||
| import useReviewId from '../../../../helpers/hooks/useReviewId'; | ||
|
|
||
| const ReviewDetailsDontKnowNHSNumberConfirmStage = (): JSX.Element => { | ||
| const navigate = useNavigate(); | ||
| const reviewId = useReviewId(); | ||
|
|
||
| const handleFinishReviewing = async (e: React.MouseEvent<HTMLElement>): Promise<void> => { | ||
| if (!reviewId) { | ||
| return; | ||
| } | ||
|
|
||
| navigateUrlParam( | ||
| routeChildren.ADMIN_REVIEW_COMPLETE_PATIENT_UNKNOWN, | ||
| { reviewId }, | ||
| navigate, | ||
| ); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="nhsuk-width-container"> | ||
| <BackButton dataTestid="back-button" /> | ||
| <h1 className="nhsuk-heading-l">Check this document has downloaded to your computer</h1> | ||
|
|
||
| <WarningCallout data-testid="review-notification"> | ||
| <WarningCallout.Label>Important</WarningCallout.Label> | ||
| <p> | ||
| Check this document has downloaded to your computer. When you finish reviewing | ||
| this document, it will be removed from your list of documents to review and you | ||
| will not be able to access it again. | ||
| </p> | ||
| </WarningCallout> | ||
|
|
||
| <div className="d-flex align-center"> | ||
| <Button | ||
| type="submit" | ||
| id="finish-review-button" | ||
| className="mr-9 mb-1" | ||
| onClick={handleFinishReviewing} | ||
| > | ||
| Finish reviewing this document | ||
| </Button> | ||
|
|
||
| <a | ||
| href={routeChildren.ADMIN_REVIEW_DONT_KNOW_NHS_NUMBER.replaceAll( | ||
| ':reviewId', | ||
| reviewId!, | ||
| )} | ||
| id="go-back-download-link" | ||
| className="nhsuk-link" | ||
| onClick={(e): void => { | ||
| e.preventDefault(); | ||
| navigate(-1); | ||
| }} | ||
| > | ||
| Go back to download the document | ||
| </a> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ReviewDetailsDontKnowNHSNumberConfirmStage; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.