Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vebt 69 FE - VYE - Staging Review finding: Pre-fill information when user clicks edit #33052

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@ import {
} from 'platform/forms-system/src/js/web-component-fields';
import { blockURLsRegEx } from '../constants';

const initializeAddressLine1 = formData => {
return formData?.addressLine1 !== undefined
? formData?.addressLine1
: formData?.street?.trim();
};

const cleanZipCode = zipcode => {
let output = zipcode;
if (zipcode && zipcode.toString().length >= 5) {
const length = 5;
output = '';
for (let i = 0; i < length; i++) {
output += zipcode[i];
}
}
return output;
};

const MILITARY_STATES = new Set(ADDRESS_DATA.militaryStates);

const ADDRESS_FORM_VALUES = {
Expand Down Expand Up @@ -48,7 +66,7 @@ export const getFormSchema = (formData = {}) => {
minLength: 1,
maxLength: STREET_LINE_MAX_LENGTH,
pattern: blockURLsRegEx,
default: formData?.addressLine1,
default: initializeAddressLine1(formData),
},
addressLine2: {
type: 'string',
Expand Down Expand Up @@ -85,7 +103,7 @@ export const getFormSchema = (formData = {}) => {
zipCode: {
type: 'string',
pattern: '^\\d{5}$',
default: formData?.zipCode,
default: cleanZipCode(formData?.zipCode),
},
},
required: ['addressLine1', 'city'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ const ChangeOfAddressWrapper = ({ mailingAddress, loading, applicantName }) => {
formChange={addressData => updateAddressData(addressData)}
formPrefix={PREFIX}
formSubmit={saveAddressInfo}
formData={editFormData}
formData={newAddress}
>
<div className="button-container">
<LoadingButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ describe('Address Validations', () => {
.first()
.click();
cy.get('[id="VYE-mailing-address-button"]').click();
cy.get('input[name="root_addressLine1"]').clear();
cy.get('input[name="root_addressLine1"]').type('322 26th ave');
cy.get('input[name="root_city"]').clear();
cy.get('input[name="root_city"]').type('San Francisco');
cy.get('select[name="root_stateCode"]')
.last()
.select('California');
cy.get('input[name="root_zipCode"]').clear();
cy.get('input[name="root_zipCode"]').type('94121');
cy.get(
'[aria-label="save your mailing address for GI Bill benefits"]',
Expand All @@ -107,11 +110,14 @@ describe('Address Validations', () => {
.first()
.click();
cy.get('[id="VYE-mailing-address-button"]').click();
cy.get('input[name="root_addressLine1"]').clear();
cy.get('input[name="root_addressLine1"]').type('322 26th ave');
cy.get('input[name="root_city"]').clear();
cy.get('input[name="root_city"]').type('San Francisco');
cy.get('select[name="root_stateCode"]')
.last()
.select('California');
cy.get('input[name="root_zipCode"]').clear();
cy.get('input[name="root_zipCode"]').type('94121');
cy.get(
'[aria-label="save your mailing address for GI Bill benefits"]',
Expand All @@ -135,11 +141,14 @@ describe('Address Validations', () => {
.first()
.click();
cy.get('[id="VYE-mailing-address-button"]').click();
cy.get('input[name="root_addressLine1"]').clear();
cy.get('input[name="root_addressLine1"]').type('322 26th ave');
cy.get('input[name="root_city"]').clear();
cy.get('input[name="root_city"]').type('Oakland');
cy.get('select[name="root_stateCode"]')
.last()
.select('New York');
cy.get('input[name="root_zipCode"]').clear();
cy.get('input[name="root_zipCode"]').type('43576');
cy.get(
'[aria-label="save your mailing address for GI Bill benefits"]',
Expand All @@ -165,11 +174,14 @@ describe('Address Validations', () => {
.first()
.click();
cy.get('[id="VYE-mailing-address-button"]').click();
cy.get('input[name="root_addressLine1"]').clear();
cy.get('input[name="root_addressLine1"]').type('322 26th ave');
cy.get('input[name="root_city"]').clear();
cy.get('input[name="root_city"]').type('San Francisco');
cy.get('select[name="root_stateCode"]')
.last()
.select('California');
cy.get('input[name="root_zipCode"]').clear();
cy.get('input[name="root_zipCode"]').type('94121');
cy.get(
'[aria-label="save your mailing address for GI Bill benefits"]',
Expand All @@ -195,11 +207,14 @@ describe('Address Validations', () => {
.first()
.click();
cy.get('[id="VYE-mailing-address-button"]').click();
cy.get('input[name="root_addressLine1"]').clear();
cy.get('input[name="root_addressLine1"]').type('322 26th ave apt 45');
cy.get('input[name="root_city"]').clear();
cy.get('input[name="root_city"]').type('San Francisco');
cy.get('select[name="root_stateCode"]')
.last()
.select('California');
cy.get('input[name="root_zipCode"]').clear();
cy.get('input[name="root_zipCode"]').type('94121');
cy.get(
'[aria-label="save your mailing address for GI Bill benefits"]',
Expand All @@ -222,11 +237,14 @@ describe('Address Validations', () => {
.first()
.click();
cy.get('[id="VYE-mailing-address-button"]').click();
cy.get('input[name="root_addressLine1"]').clear();
cy.get('input[name="root_addressLine1"]').type('322 26th ave');
cy.get('input[name="root_city"]').clear();
cy.get('input[name="root_city"]').type('San Francisco');
cy.get('select[name="root_stateCode"]')
.last()
.select('California');
cy.get('input[name="root_zipCode"]').clear();
cy.get('input[name="root_zipCode"]').type('94121');
cy.get(
'[aria-label="save your mailing address for GI Bill benefits"]',
Expand Down Expand Up @@ -255,11 +273,14 @@ describe('Address Validations', () => {
.first()
.click();
cy.get('[id="VYE-mailing-address-button"]').click();
cy.get('input[name="root_addressLine1"]').clear();
cy.get('input[name="root_addressLine1"]').type('322 26th ave');
cy.get('input[name="root_city"]').clear();
cy.get('input[name="root_city"]').type('San Francisco');
cy.get('select[name="root_stateCode"]')
.last()
.select('California');
cy.get('input[name="root_zipCode"]').clear();
cy.get('input[name="root_zipCode"]').type('94121');
cy.get(
'[aria-label="save your mailing address for GI Bill benefits"]',
Expand Down
Loading