From 681d9c99ccc1a619420d19f55d5b064ea03fe7cd Mon Sep 17 00:00:00 2001 From: Dylan Nienberg <87150991+Sparowhawk@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:23:38 -0500 Subject: [PATCH] feature/8942-ClaimFilesSegment (#9066) Co-authored-by: Jon Bindbeutel --- VAMobile/e2e/tests/Claims.e2e.ts | 13 +-- VAMobile/e2e/tests/Navigation.e2e.ts | 2 +- .../ClaimDetailsScreen.test.tsx | 31 +++++-- .../ClaimDetailsScreen/ClaimDetailsScreen.tsx | 9 ++- .../ClaimFiles/ClaimFiles.test.tsx | 30 +++++++ .../ClaimFiles/ClaimFiles.tsx | 81 +++++++++++++++++++ VAMobile/src/store/api/demo/mocks/claims.json | 9 --- VAMobile/src/translations/en/common.json | 4 + 8 files changed, 153 insertions(+), 26 deletions(-) create mode 100644 VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimFiles/ClaimFiles.test.tsx create mode 100644 VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimFiles/ClaimFiles.tsx diff --git a/VAMobile/e2e/tests/Claims.e2e.ts b/VAMobile/e2e/tests/Claims.e2e.ts index a8ed2a84c78..5b875573686 100644 --- a/VAMobile/e2e/tests/Claims.e2e.ts +++ b/VAMobile/e2e/tests/Claims.e2e.ts @@ -59,7 +59,7 @@ describe('Claims Screen', () => { it('Verify the claim status detail page', async () => { await element(by.id(ClaimsE2eIdConstants.CLAIM_3_ID)).tap() await expect(element(by.text('Status'))).toExist() - await expect(element(by.text('Details'))).toExist() + await expect(element(by.text('Files'))).toExist() await expect(element(by.id(ClaimsE2eIdConstants.CLAIM_1_STATUS_STEP_1_ID))).toExist() await expect(element(by.id(ClaimsE2eIdConstants.CLAIM_1_STATUS_STEP_2_ID))).toExist() await expect(element(by.id(ClaimsE2eIdConstants.CLAIM_1_STATUS_STEP_3_ID))).toExist() @@ -337,14 +337,9 @@ describe('Claims Screen', () => { } }) - it('verify details tab infomation', async () => { + it('verify files tab infomation', async () => { await element(by.id(ClaimsE2eIdConstants.CLAIMS_DETAILS_SCREEN_ID)).scrollTo('top') - await element(by.text('Details')).tap() - await expect(element(by.text('Claim type'))).toExist() - await expect(element(by.text('Compensation'))).toExist() - await expect(element(by.text("What you've claimed"))).toExist() - await expect(element(by.text('Date received'))).toExist() - await expect(element(by.text('January 01, 2021')).atIndex(0)).toExist() - await expect(element(by.text('Your representative for VA claims'))).toExist() + await element(by.text('Files')).tap() + await expect(element(by.text("This claim doesn't have any files yet."))).toExist() }) }) diff --git a/VAMobile/e2e/tests/Navigation.e2e.ts b/VAMobile/e2e/tests/Navigation.e2e.ts index 7d46f1f2b52..0fb790894de 100644 --- a/VAMobile/e2e/tests/Navigation.e2e.ts +++ b/VAMobile/e2e/tests/Navigation.e2e.ts @@ -48,7 +48,7 @@ const navigationDic = { ], 'Dental disability - More information needed', ], - ['Claims.e2e', ['Claims', 'Claims history', 'Received July 20, 2021', 'Details'], 'Claim type'], + ['Claims.e2e', ['Claims', 'Claims history', 'Received July 20, 2021', 'Files'], 'JESSE_GRAY_600246732_526.pdf'], [['Appeals.e2e', 'AppealsExpanded.e2e'], ['Claims', 'Claims history', 'Received July 17, 2008'], 'Appeal details'], [ ['Appeals.e2e', 'AppealsExpanded.e2e'], diff --git a/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.test.tsx b/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.test.tsx index 428407bce7f..6e2e4475e65 100644 --- a/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.test.tsx +++ b/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.test.tsx @@ -7,12 +7,16 @@ import { claimsAndAppealsKeys } from 'api/claimsAndAppeals' import { ClaimData } from 'api/types' import * as api from 'store/api' import { QueriesData, context, mockNavProps, render, waitFor, when } from 'testUtils' +import { featureEnabled } from 'utils/remoteConfig' import { claim as claimData } from '../claimData' import ClaimDetailsScreen from './ClaimDetailsScreen' +jest.mock('utils/remoteConfig') + context('ClaimDetailsScreen', () => { - const renderWithData = (claim?: Partial): void => { + const renderWithData = (featureFlag: boolean = false, claim?: Partial): void => { + when(featureEnabled).calledWith('claimPhaseExpansion').mockReturnValue(featureFlag) let queriesData: QueriesData | undefined if (claim) { queriesData = [ @@ -55,7 +59,7 @@ context('ClaimDetailsScreen', () => { ...claimData, }, }) - renderWithData({ + renderWithData(false, { ...claimData, }) await waitFor(() => @@ -71,7 +75,7 @@ context('ClaimDetailsScreen', () => { ...claimData, }, }) - renderWithData({ + renderWithData(false, { ...claimData, }) await waitFor(() => fireEvent.press(screen.getByText('Details'))) @@ -79,6 +83,23 @@ context('ClaimDetailsScreen', () => { await waitFor(() => expect(screen.getByText('Claim type')).toBeTruthy()) }) + + it('should display the Files component', async () => { + when(api.get as jest.Mock) + .calledWith(`/v0/claim/0`, {}, expect.anything()) + .mockResolvedValue({ + data: { + ...claimData, + }, + }) + renderWithData(true, { + ...claimData, + }) + await waitFor(() => fireEvent.press(screen.getByText('Files'))) + await waitFor(() => fireEvent.press(screen.getByText('Files'))) + + await waitFor(() => expect(screen.getByText('Mark_Webb_600156928_526.pdf')).toBeTruthy()) + }) }) describe('need help section', () => { @@ -90,7 +111,7 @@ context('ClaimDetailsScreen', () => { ...claimData, }, }) - renderWithData({ + renderWithData(false, { ...claimData, }) await waitFor(() => expect(screen.getByRole('header', { name: 'Need help?' })).toBeTruthy()) @@ -114,7 +135,7 @@ context('ClaimDetailsScreen', () => { ...claimData, }, }) - renderWithData({ + renderWithData(false, { ...claimData, }) await waitFor(() => fireEvent.press(screen.getByText('Details'))) diff --git a/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.tsx b/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.tsx index b28ec16997d..0d00377bd11 100644 --- a/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.tsx +++ b/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimDetailsScreen.tsx @@ -30,6 +30,7 @@ import { screenContentAllowed } from 'utils/waygateConfig' import NeedHelpData from '../NeedHelpData/NeedHelpData' import ClaimDetails from './ClaimDetails/ClaimDetails' +import ClaimFiles from './ClaimFiles/ClaimFiles' import ClaimStatus from './ClaimStatus/ClaimStatus' export const getClaimType = (claim: ClaimData | undefined, translation: TFunction): string => { @@ -42,7 +43,10 @@ function ClaimDetailsScreen({ navigation, route }: ClaimDetailsScreenProps) { const theme = useTheme() const { t } = useTranslation(NAMESPACE.COMMON) const navigateTo = useRouteNavigation() - const controlLabels = [t('claimDetails.status'), t('claimDetails.details')] + const controlLabels = [ + t('claimDetails.status'), + featureEnabled('claimPhaseExpansion') ? t('files') : t('claimDetails.details'), + ] const [selectedTab, setSelectedTab] = useState(0) const { claimID, claimType } = route.params @@ -230,7 +234,8 @@ function ClaimDetailsScreen({ navigation, route }: ClaimDetailsScreenProps) { {claim && selectedTab === 0 && } - {claim && selectedTab === 1 && } + {claim && selectedTab === 1 && !featureEnabled('claimPhaseExpansion') && } + {claim && selectedTab === 1 && featureEnabled('claimPhaseExpansion') && } {renderActiveClosedClaimStatusHelpLink()} diff --git a/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimFiles/ClaimFiles.test.tsx b/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimFiles/ClaimFiles.test.tsx new file mode 100644 index 00000000000..0591a4656fa --- /dev/null +++ b/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimFiles/ClaimFiles.test.tsx @@ -0,0 +1,30 @@ +import React from 'react' + +import { screen } from '@testing-library/react-native' + +import { ClaimData } from 'api/types' +import { context, render } from 'testUtils' + +import { claim as claimData } from '../../claimData' +import ClaimFiles from './ClaimFiles' + +jest.mock('utils/remoteConfig') + +context('ClaimDetailsScreen', () => { + const renderWithData = (claim: ClaimData): void => { + render() + } + + describe('When there are files to display', () => { + it('it should render correctly', async () => { + renderWithData(claimData) + expect(screen.getAllByText('filter-sketch.pdf')).toBeTruthy() + expect(screen.getAllByText('Request type: other_documents_list')).toBeTruthy() + expect(screen.getAllByText('Received: July 16, 2020')).toBeTruthy() + + expect(screen.getByText('Mark_Webb_600156928_526.pdf')).toBeTruthy() + expect(screen.getByText('Document type: L533')).toBeTruthy() + expect(screen.getByText('Received: June 06, 2019')).toBeTruthy() + }) + }) +}) diff --git a/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimFiles/ClaimFiles.tsx b/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimFiles/ClaimFiles.tsx new file mode 100644 index 00000000000..1cf92ab655c --- /dev/null +++ b/VAMobile/src/screens/BenefitsScreen/ClaimsScreen/ClaimDetailsScreen/ClaimFiles/ClaimFiles.tsx @@ -0,0 +1,81 @@ +import React from 'react' +import { useTranslation } from 'react-i18next' + +import { useIsFocused } from '@react-navigation/native' + +import _ from 'underscore' + +import { ClaimData } from 'api/types' +import { Box, DefaultList, DefaultListItemObj, TextLine, TextView } from 'components' +import { NAMESPACE } from 'constants/namespaces' +import { formatDateMMMMDDYYYY } from 'utils/formattingUtils' +import { useTheme } from 'utils/hooks' + +type ClaimFilesProps = { + claim: ClaimData +} + +function ClaimFiles({ claim }: ClaimFilesProps) { + const { t } = useTranslation(NAMESPACE.COMMON) + const theme = useTheme() + const isFocused = useIsFocused() + const { attributes } = claim + const events = attributes.eventsTimeline.filter( + (event) => (event.filename && event.filename.length > 0) || (event.documents && event.documents.length > 0), + ) + const files = (): Array => { + const items: Array = [] + + _.forEach(events, (event) => { + if (event.filename) { + const textLines: TextLine[] = [{ text: event.filename, variant: 'MobileBodyBold' }] + if (event.type) { + textLines.push({ text: t('appointmentList.requestType', { type: event.type }) }) + } + if (event.documentType) { + textLines.push({ text: t('appointmentList.documentType', { type: event.documentType }) }) + } + if (event.uploadDate) { + textLines.push({ text: t('appointmentList.received', { date: formatDateMMMMDDYYYY(event.uploadDate) }) }) + } + items.push({ textLines: textLines }) + } else { + _.forEach(event.documents || [], (document) => { + if (document.filename) { + const textLines: TextLine[] = [{ text: document.filename, variant: 'MobileBodyBold' }] + if (document.fileType) { + textLines.push({ text: t('appointmentList.requestType', { type: document.fileType }) }) + } + if (document.documentType) { + textLines.push({ text: t('appointmentList.documentType', { type: document.documentType }) }) + } + if (document.uploadDate) { + textLines.push({ + text: t('appointmentList.received', { date: formatDateMMMMDDYYYY(document.uploadDate) }), + }) + } + items.push({ textLines: textLines }) + } + }) + } + }) + return items + } + const filesList = files() + if (isFocused && filesList.length > 0) { + return ( + + + + ) + } + return ( + + + {t('claimDetails.noFiles')} + + + ) +} + +export default ClaimFiles diff --git a/VAMobile/src/store/api/demo/mocks/claims.json b/VAMobile/src/store/api/demo/mocks/claims.json index b65951f8b1b..6f21efcae1a 100644 --- a/VAMobile/src/store/api/demo/mocks/claims.json +++ b/VAMobile/src/store/api/demo/mocks/claims.json @@ -3774,15 +3774,6 @@ "contentionList": ["Asthma, bronchial (Increase)", "hypertension (New)"], "vaRepresentative": null, "eventsTimeline": [ - { - "trackedItemId": null, - "fileType": "VA 21-526EZ, Fully Developed Claim (Compensation)", - "documentType": null, - "filename": "Jesse_Gray_600461886_526.pdf", - "uploadDate": "2023-12-04", - "type": "other_documents_list", - "date": "2023-12-04" - }, { "type": "phase1", "date": "2023-12-04" diff --git a/VAMobile/src/translations/en/common.json b/VAMobile/src/translations/en/common.json index 335642128b8..02c6cbe1597 100644 --- a/VAMobile/src/translations/en/common.json +++ b/VAMobile/src/translations/en/common.json @@ -200,8 +200,10 @@ "apply": "Apply", "applyForHealthCare": "Apply for VA health care on VA.gov", "appointmentDetails.loading": "Loading your appointment details...", + "appointmentList.documentType": "Document type: {{type}}", "appointmentList.inPerson": "In person", "appointmentList.phoneOnly": "Phone", + "appointmentList.received": "Received: {{date}}", "appointmentList.requestType": "Request type: {{type}}", "appointments": "Appointments", "appointments.activityButton.subText": "{{count}} in the next {{dayCount}} days", @@ -407,6 +409,7 @@ "claimDetails.learnWhatToDoIfDisagree": "Learn what to do if you disagree with our decision", "claimDetails.needHelp": "Need help?", "claimDetails.noEstimatedDecisionDate": "Claim completion dates aren't available right now.", + "claimDetails.noFiles": "This claim doesn't have any files yet.", "claimDetails.receivedOn": "Received {{date}}", "claimDetails.reviewLocations": "Review locations", "claimDetails.reviewLocationsA11yHint": "Navigates you to the V-A claim exam page. This page will open in your device's browser", @@ -678,6 +681,7 @@ "errors.networkConnection.header": "The app can't be loaded.", "field": "Field", "file.removeFile": "Remove file?", + "files": "Files", "fileFolder": "File folder", "fileRemoved": "File removed", "fileRequest.askForYourClaimEvaluationBody": "Please review the evaluation details if you are ready for us to begin evaluating your claim",