Skip to content

Commit

Permalink
feature/8890-ClosedClaimsDetailAlert (#8946)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Wright <[email protected]>
  • Loading branch information
Sparowhawk and timwright12 authored Jul 23, 2024
1 parent 92e269f commit 08b3a92
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 24 deletions.
28 changes: 14 additions & 14 deletions VAMobile/e2e/tests/Claims.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,6 @@ describe('Claims Screen', () => {
await element(by.text('Close')).tap()
})

it('Verify what should I do if disagreement information', async () => {
await element(by.id(ClaimsE2eIdConstants.CLAIMS_DETAILS_SCREEN_ID)).scrollTo('bottom')
await element(by.id(`What should I do if I disagree with V-A 's decision on my disability claim?`)).tap()
await expect(
element(by.label('What should I do if I disagree with your decision on my V-A disability claim?')),
).toExist()
await element(by.id('ClaimsDecisionReviewOptionsTestID')).tap()
await element(by.text(CommonE2eIdConstants.LEAVING_APP_LEAVE_TEXT)).tap()
await setTimeout(5000)
await device.takeScreenshot('DecisionReviewOptionsWebsite')
await device.launchApp({ newInstance: false })
await element(by.text('Close')).tap()
})

it('open claim: verify that the need help? section information', async () => {
await expect(element(by.text('Need help?'))).toExist()
await expect(
Expand Down Expand Up @@ -314,13 +300,26 @@ describe('Claims Screen', () => {

it('verify the status details page of closed claim with decision letter', async () => {
await element(by.id(ClaimsE2eIdConstants.CLOSED_CLAIM_DECISION_LETTER_ID)).tap()
await expect(element(by.text('Decision letter ready'))).toExist()
await expect(element(by.text('We decided your claim on April 09, 2021'))).toExist()
await expect(
element(by.text('You can download your decision letter in the app. We also mailed you this letter.')),
).toExist()
await expect(element(by.id(ClaimsE2eIdConstants.GET_CLAIMS_LETTER_BUTTON_ID))).toExist()
})

it('Verify what should I do if disagreement information', async () => {
await element(by.id(ClaimsE2eIdConstants.CLAIMS_DETAILS_SCREEN_ID)).scrollTo('bottom')
await element(by.id('Learn what to do if you disagree with our decision')).atIndex(0).tap()
await expect(element(by.text('Learn what to do if you disagree with our decision')).atIndex(0)).toExist()
await element(by.id('ClaimsDecisionReviewOptionsTestID')).tap()
await element(by.text(CommonE2eIdConstants.LEAVING_APP_LEAVE_TEXT)).tap()
await setTimeout(5000)
await device.takeScreenshot('DecisionReviewOptionsWebsite')
await device.launchApp({ newInstance: false })
await element(by.text('Close')).tap()
})

it('closed claim: verify that the need help? section display information', async () => {
await expect(element(by.text('Need help?'))).toExist()
await expect(
Expand All @@ -339,6 +338,7 @@ describe('Claims Screen', () => {
})

it('verify details 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@ import { useTranslation } from 'react-i18next'
import { useFocusEffect } from '@react-navigation/native'
import { StackScreenProps } from '@react-navigation/stack/lib/typescript/src/types'

import { SegmentedControl } from '@department-of-veterans-affairs/mobile-component-library'
import { Alert, ButtonVariants, SegmentedControl } from '@department-of-veterans-affairs/mobile-component-library'
import { AlertProps } from '@department-of-veterans-affairs/mobile-component-library/src/components/Alert/Alert'
import { ButtonProps } from '@department-of-veterans-affairs/mobile-component-library/src/components/Button/Button'
import { useQueryClient } from '@tanstack/react-query'
import { TFunction } from 'i18next'

import { useAuthorizedServices } from 'api/authorizedServices/getAuthorizedServices'
import { useClaim } from 'api/claimsAndAppeals'
import { claimsAndAppealsKeys } from 'api/claimsAndAppeals/queryKeys'
import { useDecisionLetters } from 'api/decisionLetters'
import { ClaimAttributesData, ClaimData } from 'api/types'
import { Box, ErrorComponent, FeatureLandingTemplate, LoadingComponent, TextView } from 'components'
import { Box, ErrorComponent, FeatureLandingTemplate, LinkWithAnalytics, LoadingComponent, TextView } from 'components'
import { Events } from 'constants/analytics'
import { ClaimTypeConstants } from 'constants/claims'
import { NAMESPACE } from 'constants/namespaces'
import { BenefitsStackParamList } from 'screens/BenefitsScreen/BenefitsStackScreens'
import { ScreenIDTypesConstants } from 'store/api/types/Screens'
import { logAnalyticsEvent } from 'utils/analytics'
import { formatDateMMMMDDYYYY } from 'utils/formattingUtils'
import { useBeforeNavBackListener, useTheme } from 'utils/hooks'
import { useBeforeNavBackListener, useRouteNavigation, useTheme } from 'utils/hooks'
import { registerReviewEvent } from 'utils/inAppReviews'
import { featureEnabled } from 'utils/remoteConfig'
import { screenContentAllowed } from 'utils/waygateConfig'
Expand All @@ -37,7 +41,7 @@ type ClaimDetailsScreenProps = StackScreenProps<BenefitsStackParamList, 'ClaimDe
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 [selectedTab, setSelectedTab] = useState(0)

Expand All @@ -51,6 +55,7 @@ function ClaimDetailsScreen({ navigation, route }: ClaimDetailsScreenProps) {
error: claimError,
refetch: refetchClaim,
} = useClaim(claimID, abortSignal, { enabled: screenContentAllowed('WG_ClaimDetailsScreen') })
const { data: decisionLetterData } = useDecisionLetters()
const { data: userAuthorizedServices } = useAuthorizedServices()
const { attributes } = claim || ({} as ClaimData)
const { dateFiled } = attributes || ({} as ClaimAttributesData)
Expand Down Expand Up @@ -125,6 +130,73 @@ function ClaimDetailsScreen({ navigation, route }: ClaimDetailsScreenProps) {
t('claimDetails.viewYourClaim', { tabName: t('claimDetails.details') }),
]

const onDecisionLetterPress = () => {
logAnalyticsEvent(Events.vama_ddl_status_click())
navigateTo('ClaimLettersScreen')
}

const getActiveClosedClaimInformationAlertOrSubmitButton = () => {
if (claimType === ClaimTypeConstants.CLOSED) {
const isDecisionLetterReady =
(featureEnabled('decisionLettersWaygate') &&
userAuthorizedServices?.decisionLetters &&
claim?.attributes.decisionLetterSent &&
(decisionLetterData?.data.length || 0) > 0) ||
false

const buttonProps: ButtonProps = {
buttonType: ButtonVariants.Primary,
label: t('claimDetails.getClaimLetters'),
onPress: onDecisionLetterPress,
}

const alertProps: AlertProps = {
variant: 'info',
header: isDecisionLetterReady ? t('claims.decisionLetterReady') : t('claims.decisionLetterMailed'),
description: isDecisionLetterReady ? t('claims.decisionLetterReady.alertBody') : undefined,
primaryButton: isDecisionLetterReady ? buttonProps : undefined,
expandable: isDecisionLetterReady,
}

if (isDecisionLetterReady) {
alertProps.initializeExpanded = isDecisionLetterReady
}

return (
<Box mt={theme.dimensions.standardMarginBetween}>
<Alert {...alertProps} />
</Box>
)
}
return <></>
}

function renderActiveClosedClaimStatusHelpLink() {
const whatShouldOnPress = () => {
logAnalyticsEvent(Events.vama_claim_disag(claimID, claimType, attributes.phase))
navigateTo('WhatDoIDoIfDisagreement', {
claimID: claimID,
claimType: claimType,
claimStep: attributes.phase,
})
}

if (claimType === ClaimTypeConstants.CLOSED) {
return (
<Box my={theme.dimensions.condensedMarginBetween} mx={theme.dimensions.gutter}>
<LinkWithAnalytics
type="custom"
text={t('claimDetails.learnWhatToDoIfDisagree')}
testID={t('claimDetails.learnWhatToDoIfDisagree')}
onPress={whatShouldOnPress}
/>
</Box>
)
}

return <></>
}

return (
<FeatureLandingTemplate
backLabel={backLabel}
Expand All @@ -146,6 +218,7 @@ function ClaimDetailsScreen({ navigation, route }: ClaimDetailsScreenProps) {
{t('claimDetails.titleWithType', { type: getClaimType(claim, t).toLowerCase() })}
</TextView>
<TextView variant="MobileBody">{t('claimDetails.receivedOn', { date: formattedReceivedDate })}</TextView>
{getActiveClosedClaimInformationAlertOrSubmitButton()}
<Box mt={theme.dimensions.standardMarginBetween}>
<SegmentedControl
labels={controlLabels}
Expand All @@ -159,6 +232,7 @@ function ClaimDetailsScreen({ navigation, route }: ClaimDetailsScreenProps) {
{claim && selectedTab === 0 && <ClaimStatus claim={claim || ({} as ClaimData)} claimType={claimType} />}
{claim && selectedTab === 1 && <ClaimDetails claim={claim} />}
</Box>
{renderActiveClosedClaimStatusHelpLink()}
<Box mt={theme.dimensions.condensedMarginBetween}>
<NeedHelpData />
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ context('WhatDoIDoIfDisagreement', () => {
})

it('Renders WhatDoIDoIfDisagreement', () => {
expect(
screen.getByText('What should I do if I disagree with your decision on my VA disability claim?'),
).toBeTruthy()
expect(screen.getByText('Learn what to do if you disagree with our decision')).toBeTruthy()
expect(
screen.getByText(
'If you disagree with a claim decision that you received on or after February 19, 2019, you can ask us to review the decision. You have 3 decision review options to choose from.',
'If you disagree with our decision, you can ask for a decision review. You have 3 decision review options to choose from.',
),
).toBeTruthy()
expect(screen.getByText('Learn more about decision reviews and appeals')).toBeTruthy()
Expand Down
7 changes: 5 additions & 2 deletions VAMobile/src/translations/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@
"claimDetails.details": "Details",
"claimDetails.estimatedDecisionDate": "Estimated decision date:",
"claimDetails.getClaimLetters": "Get claim letters",
"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.receivedOn": "Received {{date}}",
Expand Down Expand Up @@ -449,7 +450,9 @@
"claimPhase.youHaveFileRequest_plural": "You have {{count}} file requests from VA",
"claims.appealFor": "{{displayTitle}} updated on {{date}}",
"claims.claimFor": "Claim for {{displayTitle}} updated on {{date}}",
"claims.decisionLetterMailed": "Decision letter mailed",
"claims.decisionLetterReady": "Decision letter ready",
"claims.decisionLetterReady.alertBody": "You can download your decision letter and other claim letters in the app.",
"claims.defaultClaimType": "disability compensation",
"claims.title": "Claims",
"claims.viewYourActiveClaims": "Review your active claims and appeals",
Expand All @@ -466,8 +469,8 @@
"claimsAndAppeals.loadingClaimsAndAppeals": "Loading your claims and appeals...",
"claimsAndAppeals.noClaimsAndAppealsAccess.body": "We're sorry. We can't find any claims for you in our records. If you think this is an error, call the VA benefits hotline.",
"claimsAndAppeals.noClaimsAndAppealsAccess.title": "We can't find any claims information for you",
"claimsDetails.whatDoIDoIfDisagreement.content": "If you disagree with a claim decision that you received on or after February 19, 2019, you can ask us to review the decision. You have 3 decision review options to choose from. ",
"claimsDetails.whatDoIDoIfDisagreement.header": "What should I do if I disagree with your decision on my VA disability claim?",
"claimsDetails.whatDoIDoIfDisagreement.content": "If you disagree with our decision, you can ask for a decision review. You have 3 decision review options to choose from.",
"claimsDetails.whatDoIDoIfDisagreement.header": "Learn what to do if you disagree with our decision",
"claimsDetails.whatDoIDoIfDisagreement.learnAboutDecisionReview": "Learn more about decision reviews and appeals",
"claimsHistory.title": "Claims history",
"claimsTab.active": "Active",
Expand Down

0 comments on commit 08b3a92

Please sign in to comment.