From 01c941add4427d24bec4b98414624ee2021e93ff Mon Sep 17 00:00:00 2001 From: RachelHowellNHS Date: Thu, 16 May 2024 13:59:27 +0100 Subject: [PATCH] [PRMDR-803] use test builder --- .../LloydGeorgeDownloadComplete.test.tsx | 23 ++-------- .../LloydGeorgeSelectDownloadStage.tsx | 45 ++----------------- 2 files changed, 7 insertions(+), 61 deletions(-) diff --git a/app/src/components/blocks/_lloydGeorge/lloydGeorgeDownloadComplete/LloydGeorgeDownloadComplete.test.tsx b/app/src/components/blocks/_lloydGeorge/lloydGeorgeDownloadComplete/LloydGeorgeDownloadComplete.test.tsx index 36b31f4d6..74537f303 100644 --- a/app/src/components/blocks/_lloydGeorge/lloydGeorgeDownloadComplete/LloydGeorgeDownloadComplete.test.tsx +++ b/app/src/components/blocks/_lloydGeorge/lloydGeorgeDownloadComplete/LloydGeorgeDownloadComplete.test.tsx @@ -1,5 +1,5 @@ import usePatient from '../../../../helpers/hooks/usePatient'; -import { buildPatientDetails } from '../../../../helpers/test/testBuilders'; +import { buildPatientDetails, buildSearchResult } from '../../../../helpers/test/testBuilders'; import { render, screen, waitFor } from '@testing-library/react'; import LloydGeorgeDownloadComplete from './LloydGeorgeDownloadComplete'; import userEvent from '@testing-library/user-event'; @@ -18,24 +18,9 @@ const numberOfFiles = 7; const selectedDocuments = ['test-id-1', 'test-id-2']; const downloadAllSelectedDocuments: Array = []; const searchResults = [ - { - fileName: '1of2_test.pdf', - created: '2024-01-01T14:52:00.827602Z', - virusScannerResult: 'Clean', - ID: 'test-id-1', - }, - { - fileName: '2of2_test.pdf', - created: '2024-01-01T14:52:00.827602Z', - virusScannerResult: 'Clean', - ID: 'test-id-2', - }, - { - fileName: '1of1_test.pdf', - created: '2024-02-01T14:52:00.827602Z', - virusScannerResult: 'Clean', - ID: 'test-id-3', - }, + buildSearchResult({ fileName: '1of2_test.pdf', ID: 'test-id-1' }), + buildSearchResult({ fileName: '2of2_test.pdf', ID: 'test-id-2' }), + buildSearchResult({ fileName: '1of1_test.pdf', ID: 'test-id-3' }), ]; describe('LloydGeorgeDownloadComplete', () => { diff --git a/app/src/components/blocks/_lloydGeorge/lloydGeorgeSelectDownloadStage/LloydGeorgeSelectDownloadStage.tsx b/app/src/components/blocks/_lloydGeorge/lloydGeorgeSelectDownloadStage/LloydGeorgeSelectDownloadStage.tsx index 6614997d4..127adae52 100644 --- a/app/src/components/blocks/_lloydGeorge/lloydGeorgeSelectDownloadStage/LloydGeorgeSelectDownloadStage.tsx +++ b/app/src/components/blocks/_lloydGeorge/lloydGeorgeSelectDownloadStage/LloydGeorgeSelectDownloadStage.tsx @@ -18,6 +18,7 @@ import { isMock } from '../../../../helpers/utils/isLocal'; import LloydGeorgeSelectSearchResults from '../lloydGeorgeSelectSearchResults/LloydGeorgeSelectSearchResults'; import PatientSummary from '../../../generic/patientSummary/PatientSummary'; import LloydGeorgeDownloadStage from '../lloydGeorgeDownloadAllStage/LloydGeorgeDownloadStage'; +import { buildSearchResult } from '../../../../helpers/test/testBuilders'; export type Props = { setStage: Dispatch>; @@ -62,48 +63,8 @@ function LloydGeorgeSelectDownloadStage({ const error = e as AxiosError; if (isMock(error)) { setSearchResults([ - { - fileName: '2of3_testy_test.pdf', - created: '2024-05-07T14:52:00.827602Z', - virusScannerResult: 'Clean', - ID: 'test-id-2', - }, - { - fileName: '1of3_testy_test.pdf', - created: '2024-05-07T14:52:00.827602Z', - virusScannerResult: 'Clean', - ID: 'test-id', - }, - { - fileName: '3of3_testy_test.pdf', - created: '2024-05-07T14:52:00.827602Z', - virusScannerResult: 'Clean', - ID: 'test-id-3', - }, - { - fileName: '2of3_earlier_creation_date.pdf', - created: '2024-05-07T13:52:00.827602Z', - virusScannerResult: 'Clean', - ID: 'earlier-test-id-2', - }, - { - fileName: '1of3_earlier_creation_date.pdf', - created: '2024-05-07T13:52:00.827602Z', - virusScannerResult: 'Clean', - ID: 'earlier-test-id', - }, - { - fileName: '3of3_earlier_creation_date.pdf', - created: '2024-05-07T13:52:00.827602Z', - virusScannerResult: 'Clean', - ID: 'earlier-test-id-3', - }, - { - fileName: '11of20_earlier_creation_date.pdf', - created: '2024-05-07T13:52:00.827602Z', - virusScannerResult: 'Clean', - ID: 'test-id-3', - }, + buildSearchResult(), + buildSearchResult({ fileName: 'fileName2.pdf', ID: '1234qwer-241ewewr-2' }), ]); setSubmissionSearchState(SEARCH_AND_DOWNLOAD_STATE.SEARCH_SUCCEEDED); } else if (error.response?.status === 403) {