From c3052a74f649e13cd3440de68a032d6f3a3ba85d Mon Sep 17 00:00:00 2001 From: jvcAdHoc <144135615+jvcAdHoc@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:52:34 -0500 Subject: [PATCH] [96896] Appoint a Rep dynamic authorizations (#33248) * dynamic authorizations * add unit tests for auth components * cleanup use of props and redux --- .../AddressAuthorizationDescription.jsx | 23 +++ .../components/AddressAuthorizationPolicy.jsx | 56 +++++++ .../InsideVAAuthorizationDescription.jsx | 23 +++ .../MedicalAuthorizationDescription.jsx | 28 ++++ .../components/MedicalAuthorizationPolicy.jsx | 62 ++++++++ .../MedicalSelectAuthorizationDescription.jsx | 22 +++ .../OutsideVAAuthorizationDescription.jsx | 23 +++ .../OutsideVAAuthorizationNameDescription.jsx | 23 +++ .../OutsideVAAuthorizationUnsureNote.jsx | 31 ++++ .../pages/authorizations/authorizeAddress.js | 55 ++----- .../pages/authorizations/authorizeInsideVA.js | 35 ++--- .../pages/authorizations/authorizeMedical.js | 62 ++------ .../authorizations/authorizeMedicalSelect.js | 18 +-- .../authorizations/authorizeOutsideVA.js | 40 ++--- .../authorizations/authorizeOutsideVANames.js | 31 +--- ...ressAuthorizationDescription.unit.spec.jsx | 88 +++++++++++ .../AddressAuthorizationPolicy.unit.spec.jsx | 143 ++++++++++++++++++ ...deVAAuthorizationDescription.unit.spec.jsx | 88 +++++++++++ ...icalAuthorizationDescription.unit.spec.jsx | 88 +++++++++++ .../MedicalAuthorizationPolicy.unit.spec.jsx | 143 ++++++++++++++++++ ...lectAuthorizationDescription.unit.spec.jsx | 88 +++++++++++ ...deVAAuthorizationDescription.unit.spec.jsx | 88 +++++++++++ ...AuthorizationNameDescription.unit.spec.jsx | 88 +++++++++++ ...ideVAAuthorizationUnsureNote.unit.spec.jsx | 114 ++++++++++++++ .../tests/fixtures/sparseFormDataExamples.js | 32 ++++ .../utilities/helpers.js | 4 +- 26 files changed, 1311 insertions(+), 185 deletions(-) create mode 100644 src/applications/representative-appoint/components/AddressAuthorizationDescription.jsx create mode 100644 src/applications/representative-appoint/components/AddressAuthorizationPolicy.jsx create mode 100644 src/applications/representative-appoint/components/InsideVAAuthorizationDescription.jsx create mode 100644 src/applications/representative-appoint/components/MedicalAuthorizationDescription.jsx create mode 100644 src/applications/representative-appoint/components/MedicalAuthorizationPolicy.jsx create mode 100644 src/applications/representative-appoint/components/MedicalSelectAuthorizationDescription.jsx create mode 100644 src/applications/representative-appoint/components/OutsideVAAuthorizationDescription.jsx create mode 100644 src/applications/representative-appoint/components/OutsideVAAuthorizationNameDescription.jsx create mode 100644 src/applications/representative-appoint/components/OutsideVAAuthorizationUnsureNote.jsx create mode 100644 src/applications/representative-appoint/tests/components/AddressAuthorizationDescription.unit.spec.jsx create mode 100644 src/applications/representative-appoint/tests/components/AddressAuthorizationPolicy.unit.spec.jsx create mode 100644 src/applications/representative-appoint/tests/components/InsideVAAuthorizationDescription.unit.spec.jsx create mode 100644 src/applications/representative-appoint/tests/components/MedicalAuthorizationDescription.unit.spec.jsx create mode 100644 src/applications/representative-appoint/tests/components/MedicalAuthorizationPolicy.unit.spec.jsx create mode 100644 src/applications/representative-appoint/tests/components/MedicalSelectAuthorizationDescription.unit.spec.jsx create mode 100644 src/applications/representative-appoint/tests/components/OutsideVAAuthorizationDescription.unit.spec.jsx create mode 100644 src/applications/representative-appoint/tests/components/OutsideVAAuthorizationNameDescription.unit.spec.jsx create mode 100644 src/applications/representative-appoint/tests/components/OutsideVAAuthorizationUnsureNote.unit.spec.jsx create mode 100644 src/applications/representative-appoint/tests/fixtures/sparseFormDataExamples.js diff --git a/src/applications/representative-appoint/components/AddressAuthorizationDescription.jsx b/src/applications/representative-appoint/components/AddressAuthorizationDescription.jsx new file mode 100644 index 000000000000..39f558bba5e8 --- /dev/null +++ b/src/applications/representative-appoint/components/AddressAuthorizationDescription.jsx @@ -0,0 +1,23 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { getRepType } from '../utilities/helpers'; + +const AddressAuthorizationDescription = ({ formData }) => { + return ( + <> +

Authorization to change your address

+

+ This accredited {getRepType(formData['view:selectedRepresentative'])}{' '} + can help you change the address on your VA records. If the address on + your VA records is incorrect or outdated, it may take us longer to + contact you and process your benefit claims. +

+ + ); +}; + +AddressAuthorizationDescription.propTypes = { + formData: PropTypes.object, +}; + +export { AddressAuthorizationDescription }; diff --git a/src/applications/representative-appoint/components/AddressAuthorizationPolicy.jsx b/src/applications/representative-appoint/components/AddressAuthorizationPolicy.jsx new file mode 100644 index 000000000000..725f9a18a11a --- /dev/null +++ b/src/applications/representative-appoint/components/AddressAuthorizationPolicy.jsx @@ -0,0 +1,56 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { connect } from 'react-redux'; +import { getFormNumber } from '../utilities/helpers'; + +const AddressAuthorizationPolicy = props => { + const { formData } = props; + + return ( +
+ + + {getFormNumber(formData) === '21-22' ? ( +

+ I authorize any official representative of the + organization named in Item 15 to act on my behalf to change my + address in my VA records. This authorization does not extend to + any other organization without my further written consent. This + authorization will remain in effect until the earlier of the + following events: (1) I revoke this authorization by filing a + written revocation with VA; or (2) I appoint another + representative, or (3) I have been determined unable to manage my + financial affairs and the individual or organization named in Item + 16A is not my appointed fiduciary. +

+ ) : ( +

+ I authorize the individual named in Item 16A to + act on my behalf to change my address in my VA records. This + authorization does not extend to any other individual without my + further written consent. This authorization will remain in effect + until the earlier of the following events: (1) I revoke this + authorization by filing a written revocation with VA; or (2) I + revoke the appointment of the individual named in Item 16A, either + by explicit revocation or the appointment of another + representative. +

+ )} +
+
+
+ ); +}; + +AddressAuthorizationPolicy.propTypes = { + formData: PropTypes.object, +}; + +const mapStateToProps = state => ({ + formData: state.form?.data || {}, +}); + +export default connect( + mapStateToProps, + null, +)(AddressAuthorizationPolicy); diff --git a/src/applications/representative-appoint/components/InsideVAAuthorizationDescription.jsx b/src/applications/representative-appoint/components/InsideVAAuthorizationDescription.jsx new file mode 100644 index 000000000000..034000c15d70 --- /dev/null +++ b/src/applications/representative-appoint/components/InsideVAAuthorizationDescription.jsx @@ -0,0 +1,23 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { getRepType } from '../utilities/helpers'; + +const InsideVAAuthorizationDescription = ({ formData }) => { + return ( + <> +

Authorization for access through VA’s systems

+

+ This accredited {getRepType(formData['view:selectedRepresentative'])}{' '} + may work with their team to help you file a claim or request a decision + review. Some of their team members may need to access your records + through VA’s information technology systems. +

+ + ); +}; + +InsideVAAuthorizationDescription.propTypes = { + formData: PropTypes.object, +}; + +export { InsideVAAuthorizationDescription }; diff --git a/src/applications/representative-appoint/components/MedicalAuthorizationDescription.jsx b/src/applications/representative-appoint/components/MedicalAuthorizationDescription.jsx new file mode 100644 index 000000000000..5222907882a1 --- /dev/null +++ b/src/applications/representative-appoint/components/MedicalAuthorizationDescription.jsx @@ -0,0 +1,28 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { getRepType } from '../utilities/helpers'; + +const MedicalAuthorizationDescription = ({ formData }) => { + return ( + <> +

Authorization to access certain medical records

+

+ This accredited {getRepType(formData['view:selectedRepresentative'])}{' '} + may need to access certain medical records to help you. You can + authorize them to access all or some of these types of records: +

+ + + ); +}; + +MedicalAuthorizationDescription.propTypes = { + formData: PropTypes.object, +}; + +export { MedicalAuthorizationDescription }; diff --git a/src/applications/representative-appoint/components/MedicalAuthorizationPolicy.jsx b/src/applications/representative-appoint/components/MedicalAuthorizationPolicy.jsx new file mode 100644 index 000000000000..66a56392191e --- /dev/null +++ b/src/applications/representative-appoint/components/MedicalAuthorizationPolicy.jsx @@ -0,0 +1,62 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { connect } from 'react-redux'; +import { getFormNumber } from '../utilities/helpers'; + +const MedicalAuthorizationPolicy = props => { + const { formData } = props; + + return ( +
+ + + {getFormNumber(formData) === '21-22' ? ( +

+ I authorize the VA facility having custody of my + VA claimant records to disclose to the service organization named + in Item 15 all treatment records relating to drug abuse, + alcoholism or alcohol abuse, infection with the human + immunodeficiency virus (HIV), or sickle cell anemia. Redisclosure + of these records by my service organization representative, other + than to VA or the Court of Appeals for Veterans Claims, is not + authorized without my further written consent. This authorization + will remain in effect until the earlier of the following events: + (1) I revoke this authorization by filing a written revocation + with VA; or (2) I revoke the appointment of the service + organization named in Item 15, by explicit revocation or the + appointment of another representative. +

+ ) : ( +

+ I authorize the VA facility having custody of my + VA claimant records to disclose to the individual named in Item + 16A, and the firm/organization/individual(s) named in Item 19 (if + approved by VA for affiliated access) all treatment records + relating to drug abuse, alcoholism or alcohol abuse, infection + with the human immunodeficiency virus (HIV), or sickle cell + anemia. Redisclosure of further written consent. This + authorization will remain in effect until the earlier of the + following events: (1) I revoke this authorization by filing a + written revocation with VA; or (2) I revoke the appointment of the + individual named in Item 16A, either by explicit revocation or the + appointment of another representative. representative. +

+ )} +
+
+
+ ); +}; + +MedicalAuthorizationPolicy.propTypes = { + formData: PropTypes.object, +}; + +const mapStateToProps = state => ({ + formData: state.form?.data || {}, +}); + +export default connect( + mapStateToProps, + null, +)(MedicalAuthorizationPolicy); diff --git a/src/applications/representative-appoint/components/MedicalSelectAuthorizationDescription.jsx b/src/applications/representative-appoint/components/MedicalSelectAuthorizationDescription.jsx new file mode 100644 index 000000000000..bc57f10d57ab --- /dev/null +++ b/src/applications/representative-appoint/components/MedicalSelectAuthorizationDescription.jsx @@ -0,0 +1,22 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { getRepType } from '../utilities/helpers'; + +const MedicalSelectAuthorizationDescription = ({ formData }) => { + return ( + <> +

Authorization to access certain medical records

+

+ You’ve authorized this accredited{' '} + {getRepType(formData['view:selectedRepresentative'])} to access some of + your medical records. +

+ + ); +}; + +MedicalSelectAuthorizationDescription.propTypes = { + formData: PropTypes.object, +}; + +export { MedicalSelectAuthorizationDescription }; diff --git a/src/applications/representative-appoint/components/OutsideVAAuthorizationDescription.jsx b/src/applications/representative-appoint/components/OutsideVAAuthorizationDescription.jsx new file mode 100644 index 000000000000..75b51ebb10b5 --- /dev/null +++ b/src/applications/representative-appoint/components/OutsideVAAuthorizationDescription.jsx @@ -0,0 +1,23 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { getRepType } from '../utilities/helpers'; + +const OutsideVAAuthorizationDescription = ({ formData }) => { + return ( + <> +

Authorization for access outside of VA’s systems

+

+ This accredited {getRepType(formData['view:selectedRepresentative'])}{' '} + may work with their team to help you file a claim or request a decision + review. Some of their team members may need to access your records + outside of VA’s information technology systems. +

+ + ); +}; + +OutsideVAAuthorizationDescription.propTypes = { + formData: PropTypes.object, +}; + +export { OutsideVAAuthorizationDescription }; diff --git a/src/applications/representative-appoint/components/OutsideVAAuthorizationNameDescription.jsx b/src/applications/representative-appoint/components/OutsideVAAuthorizationNameDescription.jsx new file mode 100644 index 000000000000..597e955c9ff5 --- /dev/null +++ b/src/applications/representative-appoint/components/OutsideVAAuthorizationNameDescription.jsx @@ -0,0 +1,23 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { getRepType } from '../utilities/helpers'; + +const OutsideVAAuthorizationNameDescription = ({ formData }) => { + return ( + <> +

Authorization for access outside of VA’s systems

+

+ You’ve authorized this accredited{' '} + {getRepType(formData['view:selectedRepresentative'])} + ’s team to access your records outside of VA’s information technology + systems. +

+ + ); +}; + +OutsideVAAuthorizationNameDescription.propTypes = { + formData: PropTypes.object, +}; + +export { OutsideVAAuthorizationNameDescription }; diff --git a/src/applications/representative-appoint/components/OutsideVAAuthorizationUnsureNote.jsx b/src/applications/representative-appoint/components/OutsideVAAuthorizationUnsureNote.jsx new file mode 100644 index 000000000000..ded7e11ae50e --- /dev/null +++ b/src/applications/representative-appoint/components/OutsideVAAuthorizationUnsureNote.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { connect } from 'react-redux'; +import { getRepType } from '../utilities/helpers'; + +const OutsideVAAuthorizationUnsureNote = props => { + const { formData } = props; + + return ( + <> +

+ Note: If you’re not sure who to enter, ask the + accredited {getRepType(formData['view:selectedRepresentative'])} you’re + appointing.{' '} +

+ + ); +}; + +OutsideVAAuthorizationUnsureNote.propTypes = { + formData: PropTypes.object, +}; + +const mapStateToProps = state => ({ + formData: state.form?.data || {}, +}); + +export default connect( + mapStateToProps, + null, +)(OutsideVAAuthorizationUnsureNote); diff --git a/src/applications/representative-appoint/pages/authorizations/authorizeAddress.js b/src/applications/representative-appoint/pages/authorizations/authorizeAddress.js index 373a3be501f8..bee4af6a2de1 100644 --- a/src/applications/representative-appoint/pages/authorizations/authorizeAddress.js +++ b/src/applications/representative-appoint/pages/authorizations/authorizeAddress.js @@ -3,58 +3,25 @@ import { radioSchema, radioUI, } from '~/platform/forms-system/src/js/web-component-patterns'; +import AddressAuthorizationPolicy from '../../components/AddressAuthorizationPolicy'; +import { AddressAuthorizationDescription } from '../../components/AddressAuthorizationDescription'; import { authorizationNote } from '../../content/authorizeMedical'; -import { representativeTypeMap } from '../../utilities/helpers'; +import { getRepType } from '../../utilities/helpers'; export const uiSchema = { - 'ui:description': ({ formData }) => { - return ( - <> -

Authorization to change your address

-

- This accredited{' '} - {representativeTypeMap[formData.repTypeRadio] || 'representative'} can - help you change the address on your VA records. If the address on your - VA records is incorrect or outdated, it may take us longer to contact - you and process your benefit claims. -

- - ); - }, + 'ui:description': ({ formData }) => ( + + ), 'view:addressAuthorizationPolicy': { - 'ui:description': () => { - return ( -
- - -

- I authorize any official representative of the - organization named in Item 15 to act on my behalf to change my - address in my VA records. This authorization does not extend to - any other organization without my further written consent. This - authorization will remain in effect until the earlier of the - following events: (1) I revoke this authorization by filing a - written revocation with VA; or (2) I appoint another - representative, or (3) I have been determined unable to manage - my financial affairs and the individual or organization named in - Item 16A is not my appointed fiduciary. -

-
-
-
- ); - }, + 'ui:description': , }, authorizeAddressRadio: radioUI({ title: 'Do you authorize this accredited representative to change your address on VA records?', updateUiSchema: formData => { - const title = `Do you authorize this accredited ${representativeTypeMap[ - (formData?.repTypeRadio) - ] || 'representative'} to change your address on VA records?`; + const title = `Do you authorize this accredited ${getRepType( + formData['view:selectedRepresentative'], + )} to change your address on VA records?`; return { 'ui:title': title }; }, }), @@ -74,7 +41,7 @@ export const schema = { }, authorizeAddressRadio: radioSchema([ `Yes, they can change my address if it’s incorrect or outdated`, - `No, they can't change my address`, + `No, they can’t change my address`, ]), 'view:authorizationNote3': { type: 'object', diff --git a/src/applications/representative-appoint/pages/authorizations/authorizeInsideVA.js b/src/applications/representative-appoint/pages/authorizations/authorizeInsideVA.js index f541066251ed..a5e5e072fce8 100644 --- a/src/applications/representative-appoint/pages/authorizations/authorizeInsideVA.js +++ b/src/applications/representative-appoint/pages/authorizations/authorizeInsideVA.js @@ -4,25 +4,15 @@ import { radioUI, } from '~/platform/forms-system/src/js/web-component-patterns'; import { authorizationNote } from '../../content/authorizeMedical'; -import { representativeTypeMap } from '../../utilities/helpers'; +import { getRepType } from '../../utilities/helpers'; +import { InsideVAAuthorizationDescription } from '../../components/InsideVAAuthorizationDescription'; /** @type {UISchemaOptions} */ export const uiSchema = { - 'ui:description': ({ formData }) => { - return ( - <> -

Authorization for access through VA’s systems

-

- This accredited{' '} - {representativeTypeMap[formData.repTypeRadio] || `representative`} may - work with their team to help you file a claim or request a decision - review. Some of their team members may need to access your records - through VA’s information technology systems. -

- - ); - }, + 'ui:description': ({ formData }) => ( + + ), 'view:insideVAAuthorizationPolicy': { 'ui:description': () => { return ( @@ -36,10 +26,10 @@ export const uiSchema = { If the individual in Item 16A is an accredited agent or attorney who has been approved by VA for access to VA information technology (IT) systems in accordance with 38 CFR 1.600 to - 1.603, I AUTHORIZE VA to disclose all of my records (other than - as provided in Items 20 and 21) to the associate attorneys, - claims agents, and support staff affiliated with my - representative. + 1.603, I AUTHORIZE VA to disclose all of my + records (other than as provided in Items 20 and 21) to the + associate attorneys, claims agents, and support staff affiliated + with my representative.

@@ -51,10 +41,9 @@ export const uiSchema = { title: 'Do you authorize this accredited representative’s team to access your records through VA’s information technology systems?', updateUiSchema: formData => { - const title = `Do you authorize this accredited ${representativeTypeMap[ - (formData?.repTypeRadio) - ] || - 'representative'}'s team to access your records through VA's information technology systems?`; + const title = `Do you authorize this accredited ${getRepType( + formData['view:selectedRepresentative'], + )}’s team to access your records through VA’s information technology systems?`; return { 'ui:title': title }; }, }), diff --git a/src/applications/representative-appoint/pages/authorizations/authorizeMedical.js b/src/applications/representative-appoint/pages/authorizations/authorizeMedical.js index 3fcca207a0de..0ebddc37661c 100644 --- a/src/applications/representative-appoint/pages/authorizations/authorizeMedical.js +++ b/src/applications/representative-appoint/pages/authorizations/authorizeMedical.js @@ -3,67 +3,25 @@ import { radioSchema, radioUI, } from '~/platform/forms-system/src/js/web-component-patterns'; +import MedicalAuthorizationPolicy from '../../components/MedicalAuthorizationPolicy'; import { authorizationNote } from '../../content/authorizeMedical'; -import { representativeTypeMap } from '../../utilities/helpers'; +import { getRepType } from '../../utilities/helpers'; +import { MedicalAuthorizationDescription } from '../../components/MedicalAuthorizationDescription'; export const uiSchema = { - 'ui:description': ({ formData }) => { - return ( - <> -

Authorization to access certain medical records

-

- This accredited{' '} - {representativeTypeMap[formData.repTypeRadio] || 'representative'} may - need to access certain medical records to help you. You can authorize - them to access all or some of these types of records: -

-
    -
  • Alcoholism and alcohol abuse records
  • -
  • Drug abuse records
  • -
  • HIV (human immunodeficiency virus) records
  • -
  • Sickle cell anemia records
  • -
- - ); - }, + 'ui:description': ({ formData }) => ( + + ), 'view:authorizationPolicy': { - 'ui:description': () => { - return ( -
- - -

- I authorize the VA facility having custody of - my VA claimant records to disclose to the service organization - named in Item 15 all treatment records relating to drug abuse, - alcoholism or alcohol abuse, infection with the human - immunodeficiency virus (HIV), or sickle cell anemia. - Redisclosure of these records by my service organization - representative, other than to VA or the Court of Appeals for - Veterans Claims, is not authorized without my further written - consent. This authorization will remain in effect until the - earlier of the following events: (1) I revoke this authorization - by filing a written revocation with VA; or (2) I revoke the - appointment of the service organization named in Item 15, by - explicit revocation or the appointment of another - representative. -

-
-
-
- ); - }, + 'ui:description': , }, authorizationRadio: radioUI({ title: 'Do you authorize this accredited representative to access your medical records?', updateUiSchema: formData => { - const title = `Do you authorize this accredited ${representativeTypeMap[ - (formData?.repTypeRadio) - ] || 'representative'} to access your medical records?`; + const title = `Do you authorize this accredited ${getRepType( + formData['view:selectedRepresentative'], + )} to access your medical records?`; return { 'ui:title': title }; }, }), diff --git a/src/applications/representative-appoint/pages/authorizations/authorizeMedicalSelect.js b/src/applications/representative-appoint/pages/authorizations/authorizeMedicalSelect.js index 74bec81b287e..001fece92b48 100644 --- a/src/applications/representative-appoint/pages/authorizations/authorizeMedicalSelect.js +++ b/src/applications/representative-appoint/pages/authorizations/authorizeMedicalSelect.js @@ -4,22 +4,12 @@ import { checkboxGroupUI, } from '~/platform/forms-system/src/js/web-component-patterns'; import { authorizationNote } from '../../content/authorizeMedical'; -import { representativeTypeMap } from '../../utilities/helpers'; +import { MedicalSelectAuthorizationDescription } from '../../components/MedicalSelectAuthorizationDescription'; export const uiSchema = { - 'ui:description': ({ formData }) => { - return ( - <> -

Authorization to access certain medical records

-

- You’ve authorized this accredited{' '} - {representativeTypeMap[formData.repTypeRadio] || `representative`} to - access some of your medical records. -

- - ); - }, - + 'ui:description': ({ formData }) => ( + + ), authorizeMedicalSelectCheckbox: checkboxGroupUI({ title: 'Select the types of records they can access', required: true, diff --git a/src/applications/representative-appoint/pages/authorizations/authorizeOutsideVA.js b/src/applications/representative-appoint/pages/authorizations/authorizeOutsideVA.js index 3b6602827abf..be0efa0ff3d0 100644 --- a/src/applications/representative-appoint/pages/authorizations/authorizeOutsideVA.js +++ b/src/applications/representative-appoint/pages/authorizations/authorizeOutsideVA.js @@ -1,27 +1,17 @@ import React from 'react'; +import PropTypes from 'prop-types'; import { radioSchema, radioUI, } from '~/platform/forms-system/src/js/web-component-patterns'; -import PropTypes from 'prop-types'; import { authorizationNote } from '../../content/authorizeMedical'; -import { representativeTypeMap } from '../../utilities/helpers'; +import { getRepType } from '../../utilities/helpers'; +import { OutsideVAAuthorizationDescription } from '../../components/OutsideVAAuthorizationDescription'; export const uiSchema = { - 'ui:description': ({ formData }) => { - return ( - <> -

Authorization for access outside of VA’s systems

-

- This accredited{' '} - {representativeTypeMap[formData.repTypeRadio] || `representative`} may - work with their team to help you file a claim or request a decision - review. Some of their team members may need to access your records - outside of VA’s information technology systems. -

- - ); - }, + 'ui:description': ({ formData }) => ( + + ), 'view:outsideVAAuthorizationPolicy': { 'ui:description': () => { return ( @@ -33,11 +23,12 @@ export const uiSchema = { >

If the individual in Item 16A is an accredited agent or - attorney, I AUTHORIZE VA to disclose all my records (other than - as provided in Items 20 and 21) to the following individuals - named as administrative employees of my representative. This - applies to disclosures, outside of those made via access to VA - electronic IT systems contemplated by 38 CFR 1.600 to 1.603. + attorney, I AUTHORIZE VA to disclose all my + records (other than as provided in Items 20 and 21) to the + following individuals named as administrative employees of my + representative. This applies to disclosures, outside of those + made via access to VA electronic IT systems contemplated by 38 + CFR 1.600 to 1.603.

@@ -49,10 +40,9 @@ export const uiSchema = { title: 'Do you authorize this accredited representative’s team to access your records outside of VA’s information technology systems?', updateUiSchema: formData => { - const title = `Do you authorize this accredited ${representativeTypeMap[ - (formData?.repTypeRadio) - ] || - 'representative'}'s team to access your records through VA's information technology systems?`; + const title = `Do you authorize this accredited ${getRepType( + formData['view:selectedRepresentative'], + )}’s team to access your records through VA’s information technology systems?`; return { 'ui:title': title }; }, }), diff --git a/src/applications/representative-appoint/pages/authorizations/authorizeOutsideVANames.js b/src/applications/representative-appoint/pages/authorizations/authorizeOutsideVANames.js index 7df8983a7871..f203b72e922a 100644 --- a/src/applications/representative-appoint/pages/authorizations/authorizeOutsideVANames.js +++ b/src/applications/representative-appoint/pages/authorizations/authorizeOutsideVANames.js @@ -3,22 +3,13 @@ import { textSchema, textUI, } from '~/platform/forms-system/src/js/web-component-patterns'; -import { representativeTypeMap } from '../../utilities/helpers'; +import OutsideVAAuthorizationUnsureNote from '../../components/OutsideVAAuthorizationUnsureNote'; +import { OutsideVAAuthorizationNameDescription } from '../../components/OutsideVAAuthorizationNameDescription'; export const uiSchema = { - 'ui:description': ({ formData }) => { - return ( - <> -

Authorization for access outside of VA’s systems

-

- You’ve authorized this accredited{' '} - {representativeTypeMap[formData.repTypeRadio] || 'representative'} - ’s team to access your records outside of VA’s information technology - systems. -

- - ); - }, + 'ui:description': ({ formData }) => ( + + ), authorizeNamesTextArea: { ...textUI({ title: `Enter the name of each team member who can access your records @@ -27,17 +18,7 @@ export const uiSchema = { }), }, 'view:unsureNote': { - 'ui:description': formData => { - return ( - <> -

- Note: If you’re not sure who to enter, ask the - accredited {formData.repTypeRadio || 'representative'} you’re - appointing.{' '} -

- - ); - }, + 'ui:description': , }, }; diff --git a/src/applications/representative-appoint/tests/components/AddressAuthorizationDescription.unit.spec.jsx b/src/applications/representative-appoint/tests/components/AddressAuthorizationDescription.unit.spec.jsx new file mode 100644 index 000000000000..ac0fe5b57be9 --- /dev/null +++ b/src/applications/representative-appoint/tests/components/AddressAuthorizationDescription.unit.spec.jsx @@ -0,0 +1,88 @@ +import React from 'react'; +import { expect } from 'chai'; +import { render } from '@testing-library/react'; +import { $ } from 'platform/forms-system/src/js/utilities/ui'; +import { agent, attorney, org, vso } from '../fixtures/sparseFormDataExamples'; +import { AddressAuthorizationDescription } from '../../components/AddressAuthorizationDescription'; + +describe('', () => { + it('should render component', () => { + const formData = vso; + + const { container } = render( + , + ); + + expect(container).to.exist; + }); + + context('when the selected representative is an attorney', () => { + it('should include "Attorney"', () => { + const formData = attorney; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Attorney'); + }); + }); + + context('when the selected representative is a claims agent', () => { + it('should include "Claims Agent"', () => { + const formData = agent; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Claims Agent'); + }); + }); + + context('when the selected representative is a vso representative', () => { + it('should include "VSO Representative"', () => { + const formData = vso; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); + + context('when the selected representative is an organization', () => { + it('should include "Organization"', () => { + const formData = org; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Organization'); + }); + }); + + context('when there is no selected rep', () => { + it('should include "VSO Representative"', () => { + const formData = {}; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); +}); diff --git a/src/applications/representative-appoint/tests/components/AddressAuthorizationPolicy.unit.spec.jsx b/src/applications/representative-appoint/tests/components/AddressAuthorizationPolicy.unit.spec.jsx new file mode 100644 index 000000000000..1866f5ee507b --- /dev/null +++ b/src/applications/representative-appoint/tests/components/AddressAuthorizationPolicy.unit.spec.jsx @@ -0,0 +1,143 @@ +import React from 'react'; +import { expect } from 'chai'; +import { Provider } from 'react-redux'; +import { render } from '@testing-library/react'; +import { agent, attorney, org, vso } from '../fixtures/sparseFormDataExamples'; +import AddressAuthorizationPolicy from '../../components/AddressAuthorizationPolicy'; + +describe('', () => { + const getProps = ({ formData = {} } = {}) => { + return { + mockStore: { + getState: () => ({ + form: { + data: formData, + }, + }), + subscribe: () => {}, + dispatch: () => ({}), + }, + }; + }; + + it('should render component', () => { + const { mockStore } = getProps({ formData: vso }); + + const { container } = render( + + + , + ); + expect(container).to.exist; + }); + + context('when the selected representative is an organization', () => { + it('should use the 21-22 policy', () => { + const { mockStore } = getProps({ formData: org }); + + const { container } = render( + + + , + ); + + const usedPolicy = container.querySelector( + '[data-testid="address-authorization-policy-2122"]', + ); + const unusedPolicy = container.querySelector( + '[data-testid="address-authorization-policy-2122a"]', + ); + + expect(usedPolicy).to.exist; + expect(unusedPolicy).not.to.exist; + }); + }); + + context('when the selected representative is a vso representative', () => { + it('should use the 21-22 policy', () => { + const { mockStore } = getProps({ formData: vso }); + + const { container } = render( + + + , + ); + + const usedPolicy = container.querySelector( + '[data-testid="address-authorization-policy-2122"]', + ); + const unusedPolicy = container.querySelector( + '[data-testid="address-authorization-policy-2122a"]', + ); + + expect(usedPolicy).to.exist; + expect(unusedPolicy).not.to.exist; + }); + }); + + context('when the selected representative is an attorney', () => { + it('should use the 21-22a policy', () => { + const { mockStore } = getProps({ formData: attorney }); + + const { container } = render( + + + , + ); + + const usedPolicy = container.querySelector( + '[data-testid="address-authorization-policy-2122a"]', + ); + const unusedPolicy = container.querySelector( + '[data-testid="address-authorization-policy-2122"]', + ); + + expect(usedPolicy).to.exist; + expect(unusedPolicy).not.to.exist; + }); + }); + + context('when the selected representative is a claims agent', () => { + it('should use the 21-22a policy', () => { + const { mockStore } = getProps({ formData: agent }); + + const { container } = render( + + + , + ); + + const usedPolicy = container.querySelector( + '[data-testid="address-authorization-policy-2122a"]', + ); + const unusedPolicy = container.querySelector( + '[data-testid="address-authorization-policy-2122"]', + ); + + expect(usedPolicy).to.exist; + expect(unusedPolicy).not.to.exist; + }); + }); + + context('when there is no selected representative', () => { + it('should use the 21-22a policy', () => { + const { mockStore } = getProps(); + + const { container } = render( + + + , + ); + + const usedPolicy = container.querySelector( + '[data-testid="address-authorization-policy-2122a"]', + ); + const unusedPolicy = container.querySelector( + '[data-testid="address-authorization-policy-2122"]', + ); + + expect(usedPolicy).to.exist; + expect(unusedPolicy).not.to.exist; + }); + }); +}); diff --git a/src/applications/representative-appoint/tests/components/InsideVAAuthorizationDescription.unit.spec.jsx b/src/applications/representative-appoint/tests/components/InsideVAAuthorizationDescription.unit.spec.jsx new file mode 100644 index 000000000000..8b023d74cbfe --- /dev/null +++ b/src/applications/representative-appoint/tests/components/InsideVAAuthorizationDescription.unit.spec.jsx @@ -0,0 +1,88 @@ +import React from 'react'; +import { expect } from 'chai'; +import { render } from '@testing-library/react'; +import { $ } from 'platform/forms-system/src/js/utilities/ui'; +import { InsideVAAuthorizationDescription } from '../../components/InsideVAAuthorizationDescription'; +import { agent, attorney, org, vso } from '../fixtures/sparseFormDataExamples'; + +describe('', () => { + it('should render component', () => { + const formData = vso; + + const { container } = render( + , + ); + + expect(container).to.exist; + }); + + context('when the selected representative is an attorney', () => { + it('should include "Attorney"', () => { + const formData = attorney; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Attorney'); + }); + }); + + context('when the selected representative is a claims agent', () => { + it('should include "Claims Agent"', () => { + const formData = agent; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Claims Agent'); + }); + }); + + context('when the selected representative is a vso representative', () => { + it('should include "VSO Representative"', () => { + const formData = vso; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); + + context('when the selected representative is an organization', () => { + it('should include "Organization"', () => { + const formData = org; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Organization'); + }); + }); + + context('when there is no selected rep', () => { + it('should include "VSO Representative"', () => { + const formData = {}; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); +}); diff --git a/src/applications/representative-appoint/tests/components/MedicalAuthorizationDescription.unit.spec.jsx b/src/applications/representative-appoint/tests/components/MedicalAuthorizationDescription.unit.spec.jsx new file mode 100644 index 000000000000..a818bc0f881d --- /dev/null +++ b/src/applications/representative-appoint/tests/components/MedicalAuthorizationDescription.unit.spec.jsx @@ -0,0 +1,88 @@ +import React from 'react'; +import { expect } from 'chai'; +import { render } from '@testing-library/react'; +import { $ } from 'platform/forms-system/src/js/utilities/ui'; +import { MedicalAuthorizationDescription } from '../../components/MedicalAuthorizationDescription'; +import { agent, attorney, org, vso } from '../fixtures/sparseFormDataExamples'; + +describe('', () => { + it('should render component', () => { + const formData = vso; + + const { container } = render( + , + ); + + expect(container).to.exist; + }); + + context('when the selected representative is an attorney', () => { + it('should include "Attorney"', () => { + const formData = attorney; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Attorney'); + }); + }); + + context('when the selected representative is a claims agent', () => { + it('should include "Claims Agent"', () => { + const formData = agent; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Claims Agent'); + }); + }); + + context('when the selected representative is a vso representative', () => { + it('should include "VSO Representative"', () => { + const formData = vso; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); + + context('when the selected representative is an organization', () => { + it('should include "Organization"', () => { + const formData = org; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Organization'); + }); + }); + + context('when there is no selected rep', () => { + it('should include "VSO Representative"', () => { + const formData = {}; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); +}); diff --git a/src/applications/representative-appoint/tests/components/MedicalAuthorizationPolicy.unit.spec.jsx b/src/applications/representative-appoint/tests/components/MedicalAuthorizationPolicy.unit.spec.jsx new file mode 100644 index 000000000000..54e14a76de11 --- /dev/null +++ b/src/applications/representative-appoint/tests/components/MedicalAuthorizationPolicy.unit.spec.jsx @@ -0,0 +1,143 @@ +import React from 'react'; +import { expect } from 'chai'; +import { Provider } from 'react-redux'; +import { render } from '@testing-library/react'; +import { agent, attorney, org, vso } from '../fixtures/sparseFormDataExamples'; +import MedicalAuthorizationPolicy from '../../components/MedicalAuthorizationPolicy'; + +describe('', () => { + const getProps = ({ formData = {} } = {}) => { + return { + mockStore: { + getState: () => ({ + form: { + data: formData, + }, + }), + subscribe: () => {}, + dispatch: () => ({}), + }, + }; + }; + + it('should render component', () => { + const { mockStore } = getProps({ formData: vso }); + + const { container } = render( + + + , + ); + expect(container).to.exist; + }); + + context('when the selected representative is an organization', () => { + it('should use the 21-22 policy', () => { + const { mockStore } = getProps({ formData: org }); + + const { container } = render( + + + , + ); + + const usedPolicy = container.querySelector( + '[data-testid="medical-authorization-policy-2122"]', + ); + const unusedPolicy = container.querySelector( + '[data-testid="medical-authorization-policy-2122a"]', + ); + + expect(usedPolicy).to.exist; + expect(unusedPolicy).not.to.exist; + }); + }); + + context('when the selected representative is a vso representative', () => { + it('should use the 21-22 policy', () => { + const { mockStore } = getProps({ formData: vso }); + + const { container } = render( + + + , + ); + + const usedPolicy = container.querySelector( + '[data-testid="medical-authorization-policy-2122"]', + ); + const unusedPolicy = container.querySelector( + '[data-testid="medical-authorization-policy-2122a"]', + ); + + expect(usedPolicy).to.exist; + expect(unusedPolicy).not.to.exist; + }); + }); + + context('when the selected representative is an attorney', () => { + it('should use the 21-22a policy', () => { + const { mockStore } = getProps({ formData: attorney }); + + const { container } = render( + + + , + ); + + const usedPolicy = container.querySelector( + '[data-testid="medical-authorization-policy-2122a"]', + ); + const unusedPolicy = container.querySelector( + '[data-testid="medical-authorization-policy-2122"]', + ); + + expect(usedPolicy).to.exist; + expect(unusedPolicy).not.to.exist; + }); + }); + + context('when the selected representative is a claims agent', () => { + it('should use the 21-22a policy', () => { + const { mockStore } = getProps({ formData: agent }); + + const { container } = render( + + + , + ); + + const usedPolicy = container.querySelector( + '[data-testid="medical-authorization-policy-2122a"]', + ); + const unusedPolicy = container.querySelector( + '[data-testid="medical-authorization-policy-2122"]', + ); + + expect(usedPolicy).to.exist; + expect(unusedPolicy).not.to.exist; + }); + }); + + context('when there is no selected representative', () => { + it('should use the 21-22a policy', () => { + const { mockStore } = getProps(); + + const { container } = render( + + + , + ); + + const usedPolicy = container.querySelector( + '[data-testid="medical-authorization-policy-2122a"]', + ); + const unusedPolicy = container.querySelector( + '[data-testid="medical-authorization-policy-2122"]', + ); + + expect(usedPolicy).to.exist; + expect(unusedPolicy).not.to.exist; + }); + }); +}); diff --git a/src/applications/representative-appoint/tests/components/MedicalSelectAuthorizationDescription.unit.spec.jsx b/src/applications/representative-appoint/tests/components/MedicalSelectAuthorizationDescription.unit.spec.jsx new file mode 100644 index 000000000000..44e0aba24460 --- /dev/null +++ b/src/applications/representative-appoint/tests/components/MedicalSelectAuthorizationDescription.unit.spec.jsx @@ -0,0 +1,88 @@ +import React from 'react'; +import { expect } from 'chai'; +import { render } from '@testing-library/react'; +import { $ } from 'platform/forms-system/src/js/utilities/ui'; +import { MedicalSelectAuthorizationDescription } from '../../components/MedicalSelectAuthorizationDescription'; +import { agent, attorney, org, vso } from '../fixtures/sparseFormDataExamples'; + +describe('', () => { + it('should render component', () => { + const formData = vso; + + const { container } = render( + , + ); + + expect(container).to.exist; + }); + + context('when the selected representative is an attorney', () => { + it('should include "Attorney"', () => { + const formData = attorney; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Attorney'); + }); + }); + + context('when the selected representative is a claims agent', () => { + it('should include "Claims Agent"', () => { + const formData = agent; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Claims Agent'); + }); + }); + + context('when the selected representative is a vso representative', () => { + it('should include "VSO Representative"', () => { + const formData = vso; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); + + context('when the selected representative is an organization', () => { + it('should include "Organization"', () => { + const formData = org; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Organization'); + }); + }); + + context('when there is no selected rep', () => { + it('should include "VSO Representative"', () => { + const formData = {}; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); +}); diff --git a/src/applications/representative-appoint/tests/components/OutsideVAAuthorizationDescription.unit.spec.jsx b/src/applications/representative-appoint/tests/components/OutsideVAAuthorizationDescription.unit.spec.jsx new file mode 100644 index 000000000000..db5ce4808509 --- /dev/null +++ b/src/applications/representative-appoint/tests/components/OutsideVAAuthorizationDescription.unit.spec.jsx @@ -0,0 +1,88 @@ +import React from 'react'; +import { expect } from 'chai'; +import { render } from '@testing-library/react'; +import { $ } from 'platform/forms-system/src/js/utilities/ui'; +import { OutsideVAAuthorizationDescription } from '../../components/OutsideVAAuthorizationDescription'; +import { agent, attorney, org, vso } from '../fixtures/sparseFormDataExamples'; + +describe('', () => { + it('should render component', () => { + const formData = vso; + + const { container } = render( + , + ); + + expect(container).to.exist; + }); + + context('when the selected representative is an attorney', () => { + it('should include "Attorney"', () => { + const formData = attorney; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Attorney'); + }); + }); + + context('when the selected representative is a claims agent', () => { + it('should include "Claims Agent"', () => { + const formData = agent; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Claims Agent'); + }); + }); + + context('when the selected representative is a vso representative', () => { + it('should include "VSO Representative"', () => { + const formData = vso; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); + + context('when the selected representative is an organization', () => { + it('should include "Organization"', () => { + const formData = org; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Organization'); + }); + }); + + context('when there is no selected rep', () => { + it('should include "VSO Representative"', () => { + const formData = {}; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); +}); diff --git a/src/applications/representative-appoint/tests/components/OutsideVAAuthorizationNameDescription.unit.spec.jsx b/src/applications/representative-appoint/tests/components/OutsideVAAuthorizationNameDescription.unit.spec.jsx new file mode 100644 index 000000000000..f8ea364a2ddf --- /dev/null +++ b/src/applications/representative-appoint/tests/components/OutsideVAAuthorizationNameDescription.unit.spec.jsx @@ -0,0 +1,88 @@ +import React from 'react'; +import { expect } from 'chai'; +import { render } from '@testing-library/react'; +import { $ } from 'platform/forms-system/src/js/utilities/ui'; +import { OutsideVAAuthorizationNameDescription } from '../../components/OutsideVAAuthorizationNameDescription'; +import { agent, attorney, org, vso } from '../fixtures/sparseFormDataExamples'; + +describe('', () => { + it('should render component', () => { + const formData = vso; + + const { container } = render( + , + ); + + expect(container).to.exist; + }); + + context('when the selected representative is an attorney', () => { + it('should include "Attorney"', () => { + const formData = attorney; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Attorney'); + }); + }); + + context('when the selected representative is a claims agent', () => { + it('should include "Claims Agent"', () => { + const formData = agent; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Claims Agent'); + }); + }); + + context('when the selected representative is a vso representative', () => { + it('should include "VSO Representative"', () => { + const formData = vso; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); + + context('when the selected representative is an organization', () => { + it('should include "Organization"', () => { + const formData = org; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Organization'); + }); + }); + + context('when there is no selected rep', () => { + it('should include "VSO Representative"', () => { + const formData = {}; + + const { container } = render( + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); +}); diff --git a/src/applications/representative-appoint/tests/components/OutsideVAAuthorizationUnsureNote.unit.spec.jsx b/src/applications/representative-appoint/tests/components/OutsideVAAuthorizationUnsureNote.unit.spec.jsx new file mode 100644 index 000000000000..6bfb168e9b00 --- /dev/null +++ b/src/applications/representative-appoint/tests/components/OutsideVAAuthorizationUnsureNote.unit.spec.jsx @@ -0,0 +1,114 @@ +import React from 'react'; +import { expect } from 'chai'; +import { Provider } from 'react-redux'; +import { render } from '@testing-library/react'; +import { $ } from 'platform/forms-system/src/js/utilities/ui'; +import { agent, attorney, org, vso } from '../fixtures/sparseFormDataExamples'; +import OutsideVAAuthorizationUnsureNote from '../../components/OutsideVAAuthorizationUnsureNote'; + +describe('', () => { + const getProps = ({ formData = {} } = {}) => { + return { + mockStore: { + getState: () => ({ + form: { + data: formData, + }, + }), + subscribe: () => {}, + dispatch: () => ({}), + }, + }; + }; + + it('should render component', () => { + const { mockStore } = getProps({ formData: vso }); + + const { container } = render( + + + , + ); + expect(container).to.exist; + }); + + context('when the selected representative is an attorney', () => { + it('should include "Attorney"', () => { + const { mockStore } = getProps({ formData: attorney }); + + const { container } = render( + + + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Attorney'); + }); + }); + + context('when the selected representative is a claims agent', () => { + it('should include "Claims Agent"', () => { + const { mockStore } = getProps({ formData: agent }); + + const { container } = render( + + + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Claims Agent'); + }); + }); + + context('when the selected representative is a vso representative', () => { + it('should include "VSO Representative"', () => { + const { props, mockStore } = getProps({ formData: vso }); + + const { container } = render( + + + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); + + context('when the selected representative is an organization', () => { + it('should include "Organization"', () => { + const { mockStore } = getProps({ formData: org }); + + const { container } = render( + + + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('Organization'); + }); + }); + + context('when there is no selected rep', () => { + it('should include "VSO Representative"', () => { + const { mockStore } = getProps(); + + const { container } = render( + + + , + ); + + const content = $('p', container); + + expect(content.textContent).to.contain('VSO Representative'); + }); + }); +}); diff --git a/src/applications/representative-appoint/tests/fixtures/sparseFormDataExamples.js b/src/applications/representative-appoint/tests/fixtures/sparseFormDataExamples.js new file mode 100644 index 000000000000..f09c9ab0e5e9 --- /dev/null +++ b/src/applications/representative-appoint/tests/fixtures/sparseFormDataExamples.js @@ -0,0 +1,32 @@ +export const attorney = { + 'view:selectedRepresentative': { + type: 'representative', + attributes: { + individualType: 'attorney', + }, + }, +}; + +export const agent = { + 'view:selectedRepresentative': { + type: 'representative', + attributes: { + individualType: 'claim_agents', + }, + }, +}; + +export const vso = { + 'view:selectedRepresentative': { + type: 'representative', + attributes: { + individualType: 'veteran_service_officer', + }, + }, +}; + +export const org = { + 'view:selectedRepresentative': { + type: 'organization', + }, +}; diff --git a/src/applications/representative-appoint/utilities/helpers.js b/src/applications/representative-appoint/utilities/helpers.js index bd15ad999fbc..c0a4e83669f1 100644 --- a/src/applications/representative-appoint/utilities/helpers.js +++ b/src/applications/representative-appoint/utilities/helpers.js @@ -102,7 +102,7 @@ export const getRepType = entity => { return 'Organization'; } - const repType = entity.attributes?.individualType; + const repType = entity?.attributes?.individualType; if (repType === 'attorney') { return 'Attorney'; @@ -123,7 +123,7 @@ export const getFormNumber = formData => { entityType === 'organization' || (['representative', 'individual'].includes(entityType) && ['representative', 'veteran_service_officer'].includes( - entity.attributes.individualType, + entity?.attributes?.individualType, )) ) { return '21-22';