Skip to content

Commit

Permalink
feature/8942-ClaimFilesSegment (#9066)
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Bindbeutel <[email protected]>
  • Loading branch information
Sparowhawk and dumathane authored Jul 29, 2024
1 parent 66169fe commit 681d9c9
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 26 deletions.
13 changes: 4 additions & 9 deletions VAMobile/e2e/tests/Claims.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
})
})
2 changes: 1 addition & 1 deletion VAMobile/e2e/tests/Navigation.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClaimData>): void => {
const renderWithData = (featureFlag: boolean = false, claim?: Partial<ClaimData>): void => {
when(featureEnabled).calledWith('claimPhaseExpansion').mockReturnValue(featureFlag)
let queriesData: QueriesData | undefined
if (claim) {
queriesData = [
Expand Down Expand Up @@ -55,7 +59,7 @@ context('ClaimDetailsScreen', () => {
...claimData,
},
})
renderWithData({
renderWithData(false, {
...claimData,
})
await waitFor(() =>
Expand All @@ -71,14 +75,31 @@ context('ClaimDetailsScreen', () => {
...claimData,
},
})
renderWithData({
renderWithData(false, {
...claimData,
})
await waitFor(() => fireEvent.press(screen.getByText('Details')))
await waitFor(() => fireEvent.press(screen.getByText('Details')))

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', () => {
Expand All @@ -90,7 +111,7 @@ context('ClaimDetailsScreen', () => {
...claimData,
},
})
renderWithData({
renderWithData(false, {
...claimData,
})
await waitFor(() => expect(screen.getByRole('header', { name: 'Need help?' })).toBeTruthy())
Expand All @@ -114,7 +135,7 @@ context('ClaimDetailsScreen', () => {
...claimData,
},
})
renderWithData({
renderWithData(false, {
...claimData,
})
await waitFor(() => fireEvent.press(screen.getByText('Details')))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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
Expand Down Expand Up @@ -230,7 +234,8 @@ function ClaimDetailsScreen({ navigation, route }: ClaimDetailsScreenProps) {
</Box>
<Box mt={theme.dimensions.condensedMarginBetween}>
{claim && selectedTab === 0 && <ClaimStatus claim={claim || ({} as ClaimData)} claimType={claimType} />}
{claim && selectedTab === 1 && <ClaimDetails claim={claim} />}
{claim && selectedTab === 1 && !featureEnabled('claimPhaseExpansion') && <ClaimDetails claim={claim} />}
{claim && selectedTab === 1 && featureEnabled('claimPhaseExpansion') && <ClaimFiles claim={claim} />}
</Box>
{renderActiveClosedClaimStatusHelpLink()}
<Box mt={theme.dimensions.condensedMarginBetween}>
Expand Down
Original file line number Diff line number Diff line change
@@ -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(<ClaimFiles claim={claim} />)
}

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()
})
})
})
Original file line number Diff line number Diff line change
@@ -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<DefaultListItemObj> => {
const items: Array<DefaultListItemObj> = []

_.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 (
<Box>
<DefaultList items={files()} />
</Box>
)
}
return (
<Box mx={theme.dimensions.gutter} my={theme.dimensions.fullScreenContentButtonHeight}>
<TextView variant="MobileBodyBold" textAlign="center" accessibilityRole="header">
{t('claimDetails.noFiles')}
</TextView>
</Box>
)
}

export default ClaimFiles
9 changes: 0 additions & 9 deletions VAMobile/src/store/api/demo/mocks/claims.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions VAMobile/src/translations/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 681d9c9

Please sign in to comment.