From cf1bba70e3b71b277f534c7f6ac569b0ca5ef159 Mon Sep 17 00:00:00 2001 From: Sean Midgley <57480791+Midge-dev@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:00:04 -0800 Subject: [PATCH] Dependents | 81671: QA fixes (1st round) (#34064) * issue #8 * Remove deceased location view * everything else * tests round 1 * tests round 2 * tests round 3 * tests final * clean up --- .../currentMarriageInformationPartThree.js | 17 ++- .../spouseMarriageHistoryArrayPages.js | 84 +++++++---- .../veteranMarriageHistoryArrayPages.js | 84 +++++++---- .../chapters/report-add-child/placeOfBirth.js | 23 +-- .../deceasedDependentArrayPages.js | 66 ++++++--- .../formerSpouseInformationPartTwo.js | 19 ++- src/applications/686c-674/config/helpers.js | 12 ++ .../currentMarriageInformation.unit.spec.jsx | 6 +- ...ouseMarriageHistoryArrayPages.unit.spec.js | 131 ++++++++++++++++- ...eranMarriageHistoryArrayPages.unit.spec.js | 133 +++++++++++++++++- .../deceasedDependentsArray.unit.spec.js | 71 +++++----- .../e2e/686C-674-ancilliary.cypress.spec.js | 14 +- .../tests/e2e/686C-674.cypress.spec.js | 14 +- .../e2e/fixtures/spouse-child-all-fields.json | 5 +- .../e2e/fixtures/spouse-report-divorce.json | 8 +- 15 files changed, 527 insertions(+), 160 deletions(-) diff --git a/src/applications/686c-674/config/chapters/report-add-a-spouse/current-marriage-information/currentMarriageInformationPartThree.js b/src/applications/686c-674/config/chapters/report-add-a-spouse/current-marriage-information/currentMarriageInformationPartThree.js index 65df2095f9cd..fbc6891bda04 100644 --- a/src/applications/686c-674/config/chapters/report-add-a-spouse/current-marriage-information/currentMarriageInformationPartThree.js +++ b/src/applications/686c-674/config/chapters/report-add-a-spouse/current-marriage-information/currentMarriageInformationPartThree.js @@ -28,17 +28,28 @@ export const uiSchema = { }, 'ui:webComponentField': VaTextInputField, }, - state: { 'ui:title': 'State', 'ui:webComponentField': VaSelectField, + 'ui:errorMessages': { + required: 'Select a state', + }, 'ui:required': formData => !formData?.currentMarriageInformation?.outsideUsa, + 'ui:options': { + hideIf: formData => formData?.currentMarriageInformation?.outsideUsa, + }, + }, + country: { + 'ui:title': 'Country', + 'ui:webComponentField': VaSelectField, 'ui:errorMessages': { - required: 'Select a state', + required: 'Select a country', }, + 'ui:required': formData => + formData?.currentMarriageInformation?.outsideUsa, 'ui:options': { - hideIf: form => form?.currentMarriageInformation?.outsideUsa, + hideIf: formData => !formData?.currentMarriageInformation?.outsideUsa, }, }, }, diff --git a/src/applications/686c-674/config/chapters/report-add-a-spouse/spouseMarriageHistoryArrayPages.js b/src/applications/686c-674/config/chapters/report-add-a-spouse/spouseMarriageHistoryArrayPages.js index fe9e4d4e0308..4e567b06c95a 100644 --- a/src/applications/686c-674/config/chapters/report-add-a-spouse/spouseMarriageHistoryArrayPages.js +++ b/src/applications/686c-674/config/chapters/report-add-a-spouse/spouseMarriageHistoryArrayPages.js @@ -47,8 +47,12 @@ export const spouseMarriageHistoryOptions = { !item?.endLocation?.location?.city || (item?.startLocation?.outsideUsa === false && !item?.startLocation?.location?.state) || + (item?.startLocation?.outsideUsa === true && + !item?.startLocation?.location?.country) || (item?.endLocation?.outsideUsa === false && - !item?.endLocation?.location?.state), + !item?.endLocation?.location?.state) || + (item?.endLocation?.outsideUsa === true && + !item?.endLocation?.location?.country), maxItems: 20, text: { summaryTitle: 'Review your spouse’s former marriages', @@ -195,9 +199,7 @@ export const formerMarriageEndDatePage = { export const formerMarriageStartLocationPage = { uiSchema: { - ...arrayBuilderItemSubsequentPageTitleUI(() => { - return 'Spouse’s former marriage'; - }), + ...arrayBuilderItemSubsequentPageTitleUI(() => 'Spouse’s former marriage'), startLocation: { 'ui:title': 'Where did they get married?', 'ui:options': { @@ -220,24 +222,35 @@ export const formerMarriageStartLocationPage = { state: { 'ui:title': 'State', 'ui:webComponentField': VaSelectField, - 'ui:required': (formData, index) => { - // See above comment - const isEditMode = formData?.startLocation?.outsideUsa; - const isAddMode = - formData?.spouseMarriageHistory?.[index]?.startLocation - ?.outsideUsa; - - return !isAddMode && !isEditMode; + 'ui:errorMessages': { + required: 'Select a state', }, + 'ui:required': (formData, index) => + !( + formData?.spouseMarriageHistory?.[index]?.startLocation + ?.outsideUsa || formData?.startLocation?.outsideUsa + ), 'ui:options': { hideIf: (formData, index) => - // See above comment - formData?.startLocation?.outsideUsa || formData?.spouseMarriageHistory?.[index]?.startLocation - ?.outsideUsa, + ?.outsideUsa || formData?.startLocation?.outsideUsa, }, + }, + country: { + 'ui:title': 'Country', + 'ui:webComponentField': VaSelectField, 'ui:errorMessages': { - required: 'Select a state', + required: 'Select a country', + }, + 'ui:required': (formData, index) => + formData?.spouseMarriageHistory?.[index]?.startLocation + ?.outsideUsa || formData?.startLocation?.outsideUsa, + 'ui:options': { + hideIf: (formData, index) => + !( + formData?.spouseMarriageHistory?.[index]?.startLocation + ?.outsideUsa || formData?.startLocation?.outsideUsa + ), }, }, }, @@ -253,9 +266,7 @@ export const formerMarriageStartLocationPage = { export const formerMarriageEndLocationPage = { uiSchema: { - ...arrayBuilderItemSubsequentPageTitleUI(() => { - return 'Spouse’s former marriage'; - }), + ...arrayBuilderItemSubsequentPageTitleUI(() => 'Spouse’s former marriage'), endLocation: { 'ui:title': 'Where did the marriage end?', 'ui:options': { @@ -281,22 +292,35 @@ export const formerMarriageEndLocationPage = { state: { 'ui:title': 'State', 'ui:webComponentField': VaSelectField, - 'ui:required': (formData, index) => { - // See above comment - const isEditMode = formData?.endLocation?.outsideUsa; - const isAddMode = - formData?.spouseMarriageHistory?.[index]?.endLocation?.outsideUsa; - - return !isAddMode && !isEditMode; + 'ui:errorMessages': { + required: 'Select a state', }, + 'ui:required': (formData, index) => + !( + formData?.spouseMarriageHistory?.[index]?.endLocation + ?.outsideUsa || formData?.endLocation?.outsideUsa + ), 'ui:options': { hideIf: (formData, index) => - // See above comment - formData?.endLocation?.outsideUsa || - formData?.spouseMarriageHistory?.[index]?.endLocation?.outsideUsa, + formData?.spouseMarriageHistory?.[index]?.endLocation + ?.outsideUsa || formData?.endLocation?.outsideUsa, }, + }, + country: { + 'ui:title': 'Country', + 'ui:webComponentField': VaSelectField, 'ui:errorMessages': { - required: 'Select a state', + required: 'Select a country', + }, + 'ui:required': (formData, index) => + formData?.spouseMarriageHistory?.[index]?.endLocation?.outsideUsa || + formData?.endLocation?.outsideUsa, + 'ui:options': { + hideIf: (formData, index) => + !( + formData?.spouseMarriageHistory?.[index]?.endLocation + ?.outsideUsa || formData?.endLocation?.outsideUsa + ), }, }, }, diff --git a/src/applications/686c-674/config/chapters/report-add-a-spouse/veteranMarriageHistoryArrayPages.js b/src/applications/686c-674/config/chapters/report-add-a-spouse/veteranMarriageHistoryArrayPages.js index b13a06bb9a34..19c33526a414 100644 --- a/src/applications/686c-674/config/chapters/report-add-a-spouse/veteranMarriageHistoryArrayPages.js +++ b/src/applications/686c-674/config/chapters/report-add-a-spouse/veteranMarriageHistoryArrayPages.js @@ -47,8 +47,12 @@ export const veteranMarriageHistoryOptions = { !item?.endLocation?.location?.city || (item?.startLocation?.outsideUsa === false && !item?.startLocation?.location?.state) || + (item?.startLocation?.outsideUsa === true && + !item?.startLocation?.location?.country) || (item?.endLocation?.outsideUsa === false && - !item?.endLocation?.location?.state), + !item?.endLocation?.location?.state) || + (item?.endLocation?.outsideUsa === true && + !item?.endLocation?.location?.country), maxItems: 20, text: { getItemName: item => @@ -194,9 +198,7 @@ export const vetFormerMarriageEndDatePage = { export const vetFormerMarriageStartLocationPage = { uiSchema: { - ...arrayBuilderItemSubsequentPageTitleUI(() => { - return 'Your former marriage'; - }), + ...arrayBuilderItemSubsequentPageTitleUI(() => 'Your former marriage'), startLocation: { 'ui:title': 'Where did they get married?', 'ui:options': { @@ -219,24 +221,35 @@ export const vetFormerMarriageStartLocationPage = { state: { 'ui:title': 'State', 'ui:webComponentField': VaSelectField, - 'ui:required': (formData, index) => { - // See above comment - const isEditMode = formData?.startLocation?.outsideUsa; - const isAddMode = - formData?.veteranMarriageHistory?.[index]?.startLocation - ?.outsideUsa; - - return !isAddMode && !isEditMode; + 'ui:errorMessages': { + required: 'Select a state', }, + 'ui:required': (formData, index) => + !( + formData?.veteranMarriageHistory?.[index]?.startLocation + ?.outsideUsa || formData?.startLocation?.outsideUsa + ), 'ui:options': { hideIf: (formData, index) => - // See above comment - formData?.startLocation?.outsideUsa || formData?.veteranMarriageHistory?.[index]?.startLocation - ?.outsideUsa, + ?.outsideUsa || formData?.startLocation?.outsideUsa, }, + }, + country: { + 'ui:title': 'Country', + 'ui:webComponentField': VaSelectField, 'ui:errorMessages': { - required: 'Select a state', + required: 'Select a country', + }, + 'ui:required': (formData, index) => + formData?.veteranMarriageHistory?.[index]?.startLocation + ?.outsideUsa || formData?.startLocation?.outsideUsa, + 'ui:options': { + hideIf: (formData, index) => + !( + formData?.veteranMarriageHistory?.[index]?.startLocation + ?.outsideUsa || formData?.startLocation?.outsideUsa + ), }, }, }, @@ -252,9 +265,7 @@ export const vetFormerMarriageStartLocationPage = { export const vetFormerMarriageEndLocationPage = { uiSchema: { - ...arrayBuilderItemSubsequentPageTitleUI(() => { - return 'Your former marriage'; - }), + ...arrayBuilderItemSubsequentPageTitleUI(() => 'Your former marriage'), endLocation: { 'ui:title': 'Where did the marriage end?', 'ui:options': { @@ -280,24 +291,35 @@ export const vetFormerMarriageEndLocationPage = { state: { 'ui:title': 'State', 'ui:webComponentField': VaSelectField, - 'ui:required': (formData, index) => { - // See above comment - const isEditMode = formData?.endLocation?.outsideUsa; - const isAddMode = - formData?.veteranMarriageHistory?.[index]?.endLocation - ?.outsideUsa; - - return !isAddMode && !isEditMode; + 'ui:errorMessages': { + required: 'Select a state', }, + 'ui:required': (formData, index) => + !( + formData?.veteranMarriageHistory?.[index]?.endLocation + ?.outsideUsa || formData?.endLocation?.outsideUsa + ), 'ui:options': { hideIf: (formData, index) => - // See above comment - formData?.endLocation?.outsideUsa || formData?.veteranMarriageHistory?.[index]?.endLocation - ?.outsideUsa, + ?.outsideUsa || formData?.endLocation?.outsideUsa, }, + }, + country: { + 'ui:title': 'Country', + 'ui:webComponentField': VaSelectField, 'ui:errorMessages': { - required: 'Select a state', + required: 'Select a country', + }, + 'ui:required': (formData, index) => + formData?.veteranMarriageHistory?.[index]?.endLocation + ?.outsideUsa || formData?.endLocation?.outsideUsa, + 'ui:options': { + hideIf: (formData, index) => + !( + formData?.veteranMarriageHistory?.[index]?.endLocation + ?.outsideUsa || formData?.endLocation?.outsideUsa + ), }, }, }, diff --git a/src/applications/686c-674/config/chapters/report-add-child/placeOfBirth.js b/src/applications/686c-674/config/chapters/report-add-child/placeOfBirth.js index 0242dd5bd46c..6a8912d5e449 100644 --- a/src/applications/686c-674/config/chapters/report-add-child/placeOfBirth.js +++ b/src/applications/686c-674/config/chapters/report-add-child/placeOfBirth.js @@ -23,27 +23,32 @@ export const placeOfBirth = { state: { 'ui:title': 'State', 'ui:webComponentField': VaSelectField, - 'ui:required': formData => { - return formData?.birthLocation?.outsideUsa; - }, 'ui:errorMessages': { required: 'Select a state', }, 'ui:options': { - hideIf: formData => { - return formData?.birthLocation?.outsideUsa; - }, + hideIf: formData => formData?.birthLocation?.outsideUsa, + }, + 'ui:required': formData => !formData?.birthLocation?.outsideUsa, + }, + country: { + 'ui:title': 'Country', + 'ui:webComponentField': VaSelectField, + 'ui:errorMessages': { + required: 'Select a country', + }, + 'ui:options': { + hideIf: formData => !formData?.birthLocation?.outsideUsa, }, + 'ui:required': formData => formData?.birthLocation?.outsideUsa, }, postalCode: { 'ui:title': 'Postal Code', 'ui:webComponentField': VaTextInputField, - 'ui:required': formData => { - return !formData?.birthLocation?.outsideUsa; - }, 'ui:errorMessages': { required: 'Enter a postal code', }, + 'ui:required': formData => !formData?.birthLocation?.outsideUsa, }, }, }, diff --git a/src/applications/686c-674/config/chapters/report-dependent-death/deceasedDependentArrayPages.js b/src/applications/686c-674/config/chapters/report-dependent-death/deceasedDependentArrayPages.js index 6acf21b27254..9f459c88e350 100644 --- a/src/applications/686c-674/config/chapters/report-dependent-death/deceasedDependentArrayPages.js +++ b/src/applications/686c-674/config/chapters/report-dependent-death/deceasedDependentArrayPages.js @@ -1,4 +1,3 @@ -import { format, parseISO } from 'date-fns'; import { capitalize } from 'lodash'; import { titleUI, @@ -45,22 +44,30 @@ export const deceasedDependentOptions = { !item?.dependentDeathLocation?.location?.city || !item?.dependentDeathDate || (item?.dependentDeathLocation?.outsideUsa === false && - !item?.dependentDeathLocation?.location?.state), + !item?.dependentDeathLocation?.location?.state) || + (item?.dependentDeathLocation?.outsideUsa === true && + !item?.dependentDeathLocation?.location?.country), maxItems: 20, text: { - getItemName: item => - `${capitalize(item.fullName?.first) || ''} ${capitalize( - item.fullName?.last, - ) || ''}`, - cardDescription: item => { - const birthDate = item?.birthDate - ? format(parseISO(item.birthDate), 'MM/dd/yyyy') - : 'Unknown'; - const dependentDeathDate = item?.dependentDeathDate - ? format(parseISO(item.dependentDeathDate), 'MM/dd/yyyy') - : 'Unknown'; + getItemName: item => { + const dependentType = item?.dependentType; + + if (!dependentType) { + return 'Unknown'; + } + + const label = relationshipLabels[dependentType]; + + if (label) { + return label; + } - return `${birthDate} - ${dependentDeathDate}`; + return 'Unknown'; // Default if `dependentType` is null for some reason + }, + cardDescription: item => { + const firstName = capitalize(item?.fullName?.first || ''); + const lastName = capitalize(item?.fullName?.last || ''); + return `${firstName} ${lastName}`.trim(); }, summaryTitle: 'Review your dependents who have died', }, @@ -233,17 +240,32 @@ export const deceasedDependentLocationOfDeathPage = { 'ui:errorMessages': { required: 'Enter a state', }, - 'ui:required': (formData, index) => { - const isEditMode = formData?.dependentDeathLocation?.outsideUsa; - const isAddMode = - formData?.deaths?.[index]?.dependentDeathLocation?.outsideUsa; - - return !isAddMode && !isEditMode; + 'ui:required': (formData, index) => + !( + formData?.deaths?.[index]?.dependentDeathLocation?.outsideUsa || + formData?.dependentDeathLocation?.outsideUsa + ), + 'ui:options': { + hideIf: (formData, index) => + formData?.deaths?.[index]?.dependentDeathLocation?.outsideUsa || + formData?.dependentDeathLocation?.outsideUsa, + }, + }, + country: { + 'ui:title': 'Select a country', + 'ui:webComponentField': VaSelectField, + 'ui:errorMessages': { + required: 'Select a country', }, + 'ui:required': (formData, index) => + formData?.deaths?.[index]?.dependentDeathLocation?.outsideUsa || + formData?.dependentDeathLocation?.outsideUsa, 'ui:options': { hideIf: (formData, index) => - formData?.dependentDeathLocation?.outsideUsa || - formData?.deaths?.[index]?.dependentDeathLocation?.outsideUsa, + !( + formData?.deaths?.[index]?.dependentDeathLocation?.outsideUsa || + formData?.dependentDeathLocation?.outsideUsa + ), }, }, }, diff --git a/src/applications/686c-674/config/chapters/report-divorce/former-spouse-information/formerSpouseInformationPartTwo.js b/src/applications/686c-674/config/chapters/report-divorce/former-spouse-information/formerSpouseInformationPartTwo.js index c34d2bbc2c9a..f0347f478185 100644 --- a/src/applications/686c-674/config/chapters/report-divorce/former-spouse-information/formerSpouseInformationPartTwo.js +++ b/src/applications/686c-674/config/chapters/report-divorce/former-spouse-information/formerSpouseInformationPartTwo.js @@ -45,23 +45,36 @@ export const uiSchema = { 'ui:required': () => true, 'ui:autocomplete': 'address-level2', 'ui:errorMessages': { - required: 'Enter the city where you were married', + required: 'Enter the city where this occurred', }, 'ui:webComponentField': VaTextInputField, }, state: { 'ui:title': 'State', 'ui:webComponentField': VaSelectField, - 'ui:required': formData => - !formData?.reportDivorce?.divorceLocation?.outsideUsa, 'ui:errorMessages': { required: 'Select a state', }, + 'ui:required': formData => + !formData?.reportDivorce?.divorceLocation?.outsideUsa, 'ui:options': { hideIf: formData => formData?.reportDivorce?.divorceLocation?.outsideUsa, }, }, + country: { + 'ui:title': 'Country', + 'ui:webComponentField': VaSelectField, + 'ui:errorMessages': { + required: 'Select a country', + }, + 'ui:required': formData => + formData?.reportDivorce?.divorceLocation?.outsideUsa, + 'ui:options': { + hideIf: formData => + !formData?.reportDivorce?.divorceLocation?.outsideUsa, + }, + }, }, }, reasonMarriageEnded: radioUI({ diff --git a/src/applications/686c-674/config/helpers.js b/src/applications/686c-674/config/helpers.js index a40d6cb055fb..de8d76951df7 100644 --- a/src/applications/686c-674/config/helpers.js +++ b/src/applications/686c-674/config/helpers.js @@ -206,6 +206,8 @@ const filteredStates = constants.states.USA.filter( const STATE_VALUES = filteredStates.map(state => state.value); const STATE_NAMES = filteredStates.map(state => state.label); +const COUNTRY_VALUES = constants.countries.map(country => country.value); +const COUNTRY_NAMES = constants.countries.map(country => country.label); export const customLocationSchema = { type: 'object', @@ -224,6 +226,11 @@ export const customLocationSchema = { enum: STATE_VALUES, enumNames: STATE_NAMES, }, + country: { + type: 'string', + enum: COUNTRY_VALUES, + enumNames: COUNTRY_NAMES, + }, }, }, }, @@ -243,6 +250,11 @@ export const customLocationSchemaStatePostal = { enum: STATE_VALUES, enumNames: STATE_NAMES, }, + country: { + type: 'string', + enum: COUNTRY_VALUES, + enumNames: COUNTRY_NAMES, + }, postalCode: { type: 'string', }, diff --git a/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/currentMarriageInformation.unit.spec.jsx b/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/currentMarriageInformation.unit.spec.jsx index dca1fe7f3903..09918672ddb5 100644 --- a/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/currentMarriageInformation.unit.spec.jsx +++ b/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/currentMarriageInformation.unit.spec.jsx @@ -124,7 +124,7 @@ describe('686 current marriage information: Marriage start location', () => { expect($$('option', container).length).to.equal(59); }); - it('should render w/o select field if Outside US is checked', () => { + it('should render country select field if Outside US is checked', () => { const { container } = render( { expect($$('va-checkbox', container).length).to.equal(1); expect($$('va-text-input', container).length).to.equal(1); - expect($$('va-select', container).length).to.equal(0); - expect($$('option', container).length).to.equal(0); + expect($$('va-select', container).length).to.equal(1); + expect($$('option', container).length).to.equal(228); }); }); diff --git a/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/spouseMarriageHistoryArrayPages.unit.spec.js b/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/spouseMarriageHistoryArrayPages.unit.spec.js index 06d3466e43e9..9df40b717478 100644 --- a/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/spouseMarriageHistoryArrayPages.unit.spec.js +++ b/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/spouseMarriageHistoryArrayPages.unit.spec.js @@ -82,7 +82,7 @@ describe('spouseMarriageHistoryOptions', () => { .be.true; }); - it('should return false if all required fields are present', () => { + it('should return false if all required fields are present (inside USA, with state)', () => { const completeItem = { fullName: { first: 'John', last: 'Doe' }, startDate: '1991-02-19', @@ -101,17 +101,138 @@ describe('spouseMarriageHistoryOptions', () => { .false; }); - it('should handle locations outside the USA where state is not required', () => { - const itemOutsideUsa = { + it('should return false if all required fields are present (outside USA, with country)', () => { + const completeItemOutsideUsa = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { + location: { city: 'Paris', country: 'France' }, + outsideUsa: true, + }, + endLocation: { + location: { city: 'Berlin', country: 'Germany' }, + outsideUsa: true, + }, + }; + expect( + spouseMarriageHistoryOptions.isItemIncomplete(completeItemOutsideUsa), + ).to.be.false; + }); + + it('should return true if startLocation city is missing', () => { + const itemMissingStartLocationCity = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { location: {}, outsideUsa: true }, + endLocation: { + location: { city: 'Berlin', country: 'Germany' }, + outsideUsa: true, + }, + }; + expect( + spouseMarriageHistoryOptions.isItemIncomplete( + itemMissingStartLocationCity, + ), + ).to.be.true; + }); + + it('should return true if startLocation state is missing (inside USA)', () => { + const itemMissingStartLocationState = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { location: { city: 'Some City' }, outsideUsa: false }, + endLocation: { + location: { city: 'Berlin', country: 'Germany' }, + outsideUsa: true, + }, + }; + expect( + spouseMarriageHistoryOptions.isItemIncomplete( + itemMissingStartLocationState, + ), + ).to.be.true; + }); + + it('should return true if startLocation country is missing (outside USA)', () => { + const itemMissingStartLocationCountry = { fullName: { first: 'Jane', last: 'Smith' }, startDate: '1995-06-15', endDate: '2005-06-15', reasonMarriageEnded: 'Annulment', startLocation: { location: { city: 'Paris' }, outsideUsa: true }, + endLocation: { + location: { city: 'Berlin', country: 'Germany' }, + outsideUsa: true, + }, + }; + expect( + spouseMarriageHistoryOptions.isItemIncomplete( + itemMissingStartLocationCountry, + ), + ).to.be.true; + }); + + it('should return true if endLocation city is missing', () => { + const itemMissingEndLocationCity = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { + location: { city: 'Paris', country: 'France' }, + outsideUsa: true, + }, + endLocation: { location: {}, outsideUsa: true }, + }; + expect( + spouseMarriageHistoryOptions.isItemIncomplete( + itemMissingEndLocationCity, + ), + ).to.be.true; + }); + + it('should return true if endLocation state is missing (inside USA)', () => { + const itemMissingEndLocationState = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { + location: { city: 'Paris', country: 'France' }, + outsideUsa: true, + }, + endLocation: { location: { city: 'Berlin' }, outsideUsa: false }, + }; + expect( + spouseMarriageHistoryOptions.isItemIncomplete( + itemMissingEndLocationState, + ), + ).to.be.true; + }); + + it('should return true if endLocation country is missing (outside USA)', () => { + const itemMissingEndLocationCountry = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { + location: { city: 'Paris', country: 'France' }, + outsideUsa: true, + }, endLocation: { location: { city: 'Berlin' }, outsideUsa: true }, }; - expect(spouseMarriageHistoryOptions.isItemIncomplete(itemOutsideUsa)).to - .be.false; + expect( + spouseMarriageHistoryOptions.isItemIncomplete( + itemMissingEndLocationCountry, + ), + ).to.be.true; }); }); diff --git a/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/veteranMarriageHistoryArrayPages.unit.spec.js b/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/veteranMarriageHistoryArrayPages.unit.spec.js index 08cc1e68e5e5..2f683dc950b2 100644 --- a/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/veteranMarriageHistoryArrayPages.unit.spec.js +++ b/src/applications/686c-674/tests/config/chapters/report-add-a-spouse/veteranMarriageHistoryArrayPages.unit.spec.js @@ -71,7 +71,7 @@ describe('veteranMarriageHistoryOptions', () => { describe('isItemIncomplete', () => { it('should return true if any required fields are missing', () => { const incompleteItem = { - fullName: { first: 'John' }, + fullName: { first: 'John' }, // Missing last name startDate: '1991-02-19', endDate: '2000-02-19', reasonMarriageEnded: 'Divorce', @@ -82,7 +82,7 @@ describe('veteranMarriageHistoryOptions', () => { .be.true; }); - it('should return false if all required fields are present', () => { + it('should return false if all required fields are present (inside USA, with state)', () => { const completeItem = { fullName: { first: 'John', last: 'Doe' }, startDate: '1991-02-19', @@ -101,17 +101,138 @@ describe('veteranMarriageHistoryOptions', () => { .false; }); - it('should handle locations outside the USA where state is not required', () => { - const itemOutsideUsa = { + it('should return false if all required fields are present (outside USA, with country)', () => { + const completeItemOutsideUsa = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { + location: { city: 'Paris', country: 'France' }, + outsideUsa: true, + }, + endLocation: { + location: { city: 'Berlin', country: 'Germany' }, + outsideUsa: true, + }, + }; + expect( + veteranMarriageHistoryOptions.isItemIncomplete(completeItemOutsideUsa), + ).to.be.false; + }); + + it('should return true if startLocation city is missing', () => { + const itemMissingStartLocationCity = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { location: {}, outsideUsa: true }, + endLocation: { + location: { city: 'Berlin', country: 'Germany' }, + outsideUsa: true, + }, + }; + expect( + veteranMarriageHistoryOptions.isItemIncomplete( + itemMissingStartLocationCity, + ), + ).to.be.true; + }); + + it('should return true if startLocation state is missing (inside USA)', () => { + const itemMissingStartLocationState = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { location: { city: 'Some City' }, outsideUsa: false }, + endLocation: { + location: { city: 'Berlin', country: 'Germany' }, + outsideUsa: true, + }, + }; + expect( + veteranMarriageHistoryOptions.isItemIncomplete( + itemMissingStartLocationState, + ), + ).to.be.true; + }); + + it('should return true if startLocation country is missing (outside USA)', () => { + const itemMissingStartLocationCountry = { fullName: { first: 'Jane', last: 'Smith' }, startDate: '1995-06-15', endDate: '2005-06-15', reasonMarriageEnded: 'Annulment', startLocation: { location: { city: 'Paris' }, outsideUsa: true }, + endLocation: { + location: { city: 'Berlin', country: 'Germany' }, + outsideUsa: true, + }, + }; + expect( + veteranMarriageHistoryOptions.isItemIncomplete( + itemMissingStartLocationCountry, + ), + ).to.be.true; + }); + + it('should return true if endLocation city is missing', () => { + const itemMissingEndLocationCity = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { + location: { city: 'Paris', country: 'France' }, + outsideUsa: true, + }, + endLocation: { location: {}, outsideUsa: true }, + }; + expect( + veteranMarriageHistoryOptions.isItemIncomplete( + itemMissingEndLocationCity, + ), + ).to.be.true; + }); + + it('should return true if endLocation state is missing (inside USA)', () => { + const itemMissingEndLocationState = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { + location: { city: 'Paris', country: 'France' }, + outsideUsa: true, + }, + endLocation: { location: { city: 'Berlin' }, outsideUsa: false }, + }; + expect( + veteranMarriageHistoryOptions.isItemIncomplete( + itemMissingEndLocationState, + ), + ).to.be.true; + }); + + it('should return true if endLocation country is missing (outside USA)', () => { + const itemMissingEndLocationCountry = { + fullName: { first: 'Jane', last: 'Smith' }, + startDate: '1995-06-15', + endDate: '2005-06-15', + reasonMarriageEnded: 'Annulment', + startLocation: { + location: { city: 'Paris', country: 'France' }, + outsideUsa: true, + }, endLocation: { location: { city: 'Berlin' }, outsideUsa: true }, }; - expect(veteranMarriageHistoryOptions.isItemIncomplete(itemOutsideUsa)).to - .be.false; + expect( + veteranMarriageHistoryOptions.isItemIncomplete( + itemMissingEndLocationCountry, + ), + ).to.be.true; }); }); diff --git a/src/applications/686c-674/tests/config/chapters/report-dependent-death/deceasedDependentsArray.unit.spec.js b/src/applications/686c-674/tests/config/chapters/report-dependent-death/deceasedDependentsArray.unit.spec.js index 21c43605d161..b9e683be711d 100644 --- a/src/applications/686c-674/tests/config/chapters/report-dependent-death/deceasedDependentsArray.unit.spec.js +++ b/src/applications/686c-674/tests/config/chapters/report-dependent-death/deceasedDependentsArray.unit.spec.js @@ -7,6 +7,7 @@ import { DefinitionTester } from 'platform/testing/unit/schemaform-utils'; import { $$ } from 'platform/forms-system/src/js/utilities/ui'; import { deceasedDependentOptions } from '../../../../config/chapters/report-dependent-death/deceasedDependentArrayPages'; import formConfig from '../../../../config/form'; +import { relationshipLabels } from '../../../../config/chapters/report-dependent-death/helpers'; const defaultStore = createCommonStore(); @@ -30,6 +31,7 @@ describe('deceasedDependentOptions', () => { dependentType: 'spouse', dependentDeathLocation: { location: { city: 'Some City' }, + outsideUsa: false, }, dependentDeathDate: '1991-01-19', }; @@ -44,7 +46,8 @@ describe('deceasedDependentOptions', () => { birthDate: '1991-02-19', dependentType: 'spouse', dependentDeathLocation: { - location: { city: 'Some City' }, + location: { city: 'Some City', state: 'Some State' }, + outsideUsa: false, }, dependentDeathDate: '1991-01-19', }; @@ -52,7 +55,7 @@ describe('deceasedDependentOptions', () => { .false; }); - it('should return true if state is missing and outsideUsa is false', () => { + it('should return true if "outsideUsa" is true but "country" is missing', () => { const incompleteItem = { fullName: { first: 'John', last: 'Doe' }, ssn: '333445555', @@ -60,7 +63,7 @@ describe('deceasedDependentOptions', () => { dependentType: 'spouse', dependentDeathLocation: { location: { city: 'Some City' }, - outsideUsa: false, + outsideUsa: true, }, dependentDeathDate: '1991-01-19', }; @@ -68,73 +71,71 @@ describe('deceasedDependentOptions', () => { .true; }); - it('should return false if state is missing but outsideUsa is true', () => { - const completeItemWithoutState = { + it('should return false if "outsideUsa" is true and "country" is present', () => { + const completeItem = { fullName: { first: 'John', last: 'Doe' }, ssn: '333445555', birthDate: '1991-02-19', dependentType: 'spouse', dependentDeathLocation: { - location: { city: 'Some City' }, + location: { city: 'Some City', country: 'Some Country' }, outsideUsa: true, }, dependentDeathDate: '1991-01-19', }; - expect( - deceasedDependentOptions.isItemIncomplete(completeItemWithoutState), - ).to.be.false; + expect(deceasedDependentOptions.isItemIncomplete(completeItem)).to.be + .false; }); }); describe('text.getItemName', () => { - it('should return the full name of the item', () => { - const item = { - fullName: { first: 'John', last: 'Doe' }, - }; + it('should return the relationship label if dependentType is valid', () => { + const item = { dependentType: 'spouse' }; expect(deceasedDependentOptions.text.getItemName(item)).to.equal( - 'John Doe', + relationshipLabels.spouse, ); }); - it('should return an empty string if first or last name is missing', () => { - const incompleteItem = { fullName: { first: 'John' } }; - expect( - deceasedDependentOptions.text.getItemName(incompleteItem), - ).to.equal('John '); + it('should return "Unknown" if dependentType is missing', () => { + const item = {}; + expect(deceasedDependentOptions.text.getItemName(item)).to.equal( + 'Unknown', + ); + }); - const missingBoth = { fullName: {} }; - expect(deceasedDependentOptions.text.getItemName(missingBoth)).to.equal( - ' ', + it('should return "Unknown" if dependentType is invalid', () => { + const item = { dependentType: 'invalidType' }; + expect(deceasedDependentOptions.text.getItemName(item)).to.equal( + 'Unknown', ); }); }); describe('text.cardDescription', () => { - it('should return formatted birth and death dates', () => { + it('should return a formatted full name with capitalized first and last names', () => { const item = { - birthDate: '1991-02-19', - dependentDeathDate: '1991-01-19', + fullName: { first: 'john', last: 'doe' }, }; expect(deceasedDependentOptions.text.cardDescription(item)).to.equal( - '02/19/1991 - 01/19/1991', + 'John Doe', ); }); - it('should return "Unknown" if birth or death date is missing', () => { - const missingBirthDate = { dependentDeathDate: '1991-01-19' }; + it('should handle missing first or last name gracefully', () => { + const missingLastName = { fullName: { first: 'John' } }; expect( - deceasedDependentOptions.text.cardDescription(missingBirthDate), - ).to.equal('Unknown - 01/19/1991'); + deceasedDependentOptions.text.cardDescription(missingLastName), + ).to.equal('John'); - const missingDeathDate = { birthDate: '1991-02-19' }; + const missingFirstName = { fullName: { last: 'Doe' } }; expect( - deceasedDependentOptions.text.cardDescription(missingDeathDate), - ).to.equal('02/19/1991 - Unknown'); + deceasedDependentOptions.text.cardDescription(missingFirstName), + ).to.equal('Doe'); - const missingBoth = {}; + const missingBoth = { fullName: {} }; expect( deceasedDependentOptions.text.cardDescription(missingBoth), - ).to.equal('Unknown - Unknown'); + ).to.equal(''); }); }); }); diff --git a/src/applications/686c-674/tests/e2e/686C-674-ancilliary.cypress.spec.js b/src/applications/686c-674/tests/e2e/686C-674-ancilliary.cypress.spec.js index 02141289ba79..764f11218d77 100644 --- a/src/applications/686c-674/tests/e2e/686C-674-ancilliary.cypress.spec.js +++ b/src/applications/686c-674/tests/e2e/686C-674-ancilliary.cypress.spec.js @@ -73,12 +73,18 @@ const testConfig = createTestConfig( }); }, - 'current-marriage-information': ({ afterHook }) => { + 'current-marriage-information/location-of-marriage': ({ afterHook }) => { afterHook(() => { cy.fillPage(); - cy.get('#root_currentMarriageInformation_location_country').select( - 'Argentina', - ); + cy.get( + 'select#options[name="root_currentMarriageInformation_location_country"]', + { timeout: 1000 }, + ) + .should('be.visible') + .should('not.be.disabled'); + cy.get( + 'select#options[name="root_currentMarriageInformation_location_country"]', + ).select('AUS'); cy.get('.usa-button-primary').click(); }); }, diff --git a/src/applications/686c-674/tests/e2e/686C-674.cypress.spec.js b/src/applications/686c-674/tests/e2e/686C-674.cypress.spec.js index c574cd2b6f36..32ece60a6c10 100644 --- a/src/applications/686c-674/tests/e2e/686C-674.cypress.spec.js +++ b/src/applications/686c-674/tests/e2e/686C-674.cypress.spec.js @@ -88,12 +88,18 @@ const testConfig = createTestConfig( }); }, - 'current-marriage-information': ({ afterHook }) => { + 'current-marriage-information/location-of-marriage': ({ afterHook }) => { afterHook(() => { cy.fillPage(); - cy.get('#root_currentMarriageInformation_location_country').select( - 'Argentina', - ); + cy.get( + 'select#options[name="root_currentMarriageInformation_location_country"]', + { timeout: 1000 }, + ) + .should('be.visible') + .should('not.be.disabled'); + cy.get( + 'select#options[name="root_currentMarriageInformation_location_country"]', + ).select('AUS'); cy.get('.usa-button-primary').click(); }); }, diff --git a/src/applications/686c-674/tests/e2e/fixtures/spouse-child-all-fields.json b/src/applications/686c-674/tests/e2e/fixtures/spouse-child-all-fields.json index 05e4b56a4563..1be60a499fa0 100644 --- a/src/applications/686c-674/tests/e2e/fixtures/spouse-child-all-fields.json +++ b/src/applications/686c-674/tests/e2e/fixtures/spouse-child-all-fields.json @@ -78,7 +78,8 @@ "startLocation": { "outsideUsa": true, "location": { - "city": "Foreign city" + "city": "Foreign city", + "country": "AUS" } }, "endLocation": { @@ -111,7 +112,7 @@ "outsideUsa": true, "location": { "city": "Fakesville", - "state": "CA" + "country": "AUS" }, "date": "2009-04-01", "type": "CIVIL", diff --git a/src/applications/686c-674/tests/e2e/fixtures/spouse-report-divorce.json b/src/applications/686c-674/tests/e2e/fixtures/spouse-report-divorce.json index 75cc3b3a08fd..6fd761b9e50a 100644 --- a/src/applications/686c-674/tests/e2e/fixtures/spouse-report-divorce.json +++ b/src/applications/686c-674/tests/e2e/fixtures/spouse-report-divorce.json @@ -11,7 +11,8 @@ "startLocation": { "outsideUsa": true, "location": { - "city": "Foreign city" + "city": "Foreign city", + "country": "AUS" } }, "endLocation": { @@ -38,7 +39,8 @@ "startLocation": { "outsideUsa": true, "location": { - "city": "Foreign city" + "city": "Fakesville", + "country": "AUS" } }, "endLocation": { @@ -71,7 +73,7 @@ "outsideUsa": true, "location": { "city": "Fakesville", - "state": "CA" + "country": "AUS" }, "date": "2009-04-01", "type": "CIVIL",