diff --git a/app/forms/idv/state_id_form.rb b/app/forms/idv/state_id_form.rb index 2225225344a..3f80e517ca3 100644 --- a/app/forms/idv/state_id_form.rb +++ b/app/forms/idv/state_id_form.rb @@ -13,8 +13,9 @@ def self.model_name ActiveModel::Name.new(self, nil, 'StateId') end - def initialize(pii) + def initialize(pii, capture_secondary_id_enabled:) @pii = pii + @capture_secondary_id_enabled = capture_secondary_id_enabled end def submit(params) @@ -35,6 +36,9 @@ def submit(params) private + attr_reader :capture_secondary_id_enabled + alias_method :capture_secondary_id_enabled?, :capture_secondary_id_enabled + def consume_params(params) params.each do |key, value| raise_invalid_state_id_parameter_error(key) unless ATTRIBUTES.include?(key.to_sym) diff --git a/app/services/idv/steps/in_person/state_id_step.rb b/app/services/idv/steps/in_person/state_id_step.rb index f87327898c1..872387abe32 100644 --- a/app/services/idv/steps/in_person/state_id_step.rb +++ b/app/services/idv/steps/in_person/state_id_step.rb @@ -104,7 +104,10 @@ def flow_params end def form - @form ||= Idv::StateIdForm.new(current_user) + @form ||= Idv::StateIdForm.new( + current_user, + capture_secondary_id_enabled: capture_secondary_id_enabled?, + ) end def form_submit diff --git a/app/validators/idv/form_state_id_validator.rb b/app/validators/idv/form_state_id_validator.rb index 6e409bd9916..cb993bae471 100644 --- a/app/validators/idv/form_state_id_validator.rb +++ b/app/validators/idv/form_state_id_validator.rb @@ -11,6 +11,11 @@ module FormStateIdValidator :state_id_number, presence: true + validates :identity_doc_address1, + :identity_doc_city, + presence: true, + if: :capture_secondary_id_enabled? + validates_with UspsInPersonProofing::TransliterableValidator, fields: [:first_name, :last_name, :identity_doc_city], reject_chars: /[^A-Za-z\-' ]/, diff --git a/spec/features/idv/in_person_spec.rb b/spec/features/idv/in_person_spec.rb index dd494493791..1c76a2dba32 100644 --- a/spec/features/idv/in_person_spec.rb +++ b/spec/features/idv/in_person_spec.rb @@ -456,7 +456,7 @@ complete_location_step expect(page).to have_current_path(idv_in_person_step_path(step: :state_id), wait: 10) - fill_out_state_id_form_ok(double_address_verification: double_address_verification) + fill_out_state_id_form_ok(capture_secondary_id_enabled: capture_secondary_id_enabled) fill_in t('in_person_proofing.form.state_id.first_name'), with: 'T0mmy "Lee"' fill_in t('in_person_proofing.form.state_id.last_name'), with: 'Джейкоб' fill_in t('in_person_proofing.form.state_id.address1'), with: '#1 $treet' @@ -531,7 +531,7 @@ expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address2_hint')) # change state selection - fill_out_state_id_form_ok(double_address_verification: true) + fill_out_state_id_form_ok(capture_secondary_id_enabled: true) expect(page).not_to have_content(I18n.t('in_person_proofing.form.state_id.address1_hint')) expect(page).not_to have_content(I18n.t('in_person_proofing.form.state_id.address2_hint')) @@ -693,7 +693,9 @@ complete_location_step(user) end it 'successfully proceeds through the flow' do - complete_state_id_step(user, same_address_as_id: false, double_address_verification: true) + complete_state_id_step( + user, same_address_as_id: false, capture_secondary_id_enabled: true + ) complete_address_step(user, double_address_verification: true) @@ -732,7 +734,9 @@ end it 'skips the address page' do - complete_state_id_step(user, same_address_as_id: true, double_address_verification: true) + complete_state_id_step( + user, same_address_as_id: true, capture_secondary_id_enabled: true + ) # skip address step complete_ssn_step(user) # Ensure the page submitted successfully @@ -740,7 +744,9 @@ end it 'can redo the address page form even if that page is skipped' do - complete_state_id_step(user, same_address_as_id: true, double_address_verification: true) + complete_state_id_step( + user, same_address_as_id: true, capture_secondary_id_enabled: true + ) # skip address step complete_ssn_step(user) # click update address button on the verify page @@ -753,7 +759,9 @@ end it 'allows user to update their residential address as different from their state id' do - complete_state_id_step(user, same_address_as_id: true, double_address_verification: true) + complete_state_id_step( + user, same_address_as_id: true, capture_secondary_id_enabled: true + ) complete_ssn_step(user) # click "update residential address" @@ -797,7 +805,9 @@ it 'does not update their previous selection of "Yes, I live at the address on my state-issued ID"' do - complete_state_id_step(user, same_address_as_id: true, double_address_verification: true) + complete_state_id_step( + user, same_address_as_id: true, capture_secondary_id_enabled: true + ) # skip address step complete_ssn_step(user) # expect to be on verify page @@ -829,7 +839,9 @@ end it 'does not update their previous selection of "No, I live at a different address"' do - complete_state_id_step(user, same_address_as_id: false, double_address_verification: true) + complete_state_id_step( + user, same_address_as_id: false, capture_secondary_id_enabled: true + ) # expect to be on address page expect(page).to have_content(t('in_person_proofing.headings.address')) # complete address step @@ -863,7 +875,9 @@ end it 'updates their previous selection from "Yes" TO "No, I live at a different address"' do - complete_state_id_step(user, same_address_as_id: true, double_address_verification: true) + complete_state_id_step( + user, same_address_as_id: true, capture_secondary_id_enabled: true + ) # skip address step complete_ssn_step(user) # click update state ID button on the verify page @@ -898,7 +912,9 @@ it 'updates their previous selection from "No" TO "Yes, I live at the address on my state-issued ID"' do - complete_state_id_step(user, same_address_as_id: false, double_address_verification: true) + complete_state_id_step( + user, same_address_as_id: false, capture_secondary_id_enabled: true + ) # expect to be on address page expect(page).to have_content(t('in_person_proofing.headings.address')) # complete address step diff --git a/spec/features/idv/steps/in_person/ssn_spec.rb b/spec/features/idv/steps/in_person/ssn_spec.rb index ef7e6a5fbd3..011f4ed029e 100644 --- a/spec/features/idv/steps/in_person/ssn_spec.rb +++ b/spec/features/idv/steps/in_person/ssn_spec.rb @@ -111,7 +111,7 @@ # location page complete_location_step(user) # state ID page - fill_out_state_id_form_ok(double_address_verification: true, same_address_as_id: false) + fill_out_state_id_form_ok(same_address_as_id: false, capture_secondary_id_enabled: true) click_idv_continue fill_out_address_form_ok(double_address_verification: true, same_address_as_id: false) click_idv_continue diff --git a/spec/features/idv/steps/in_person/state_id_step_spec.rb b/spec/features/idv/steps/in_person/state_id_step_spec.rb index d0109843d9c..a265174d37f 100644 --- a/spec/features/idv/steps/in_person/state_id_step_spec.rb +++ b/spec/features/idv/steps/in_person/state_id_step_spec.rb @@ -23,7 +23,7 @@ complete_prepare_step(user) complete_location_step(user) expect(page).to have_current_path(idv_in_person_step_path(step: :state_id), wait: 10) - fill_out_state_id_form_ok(double_address_verification: true, same_address_as_id: true) + fill_out_state_id_form_ok(same_address_as_id: true, capture_secondary_id_enabled: true) # blank out the zip code field fill_in t('in_person_proofing.form.state_id.zipcode'), with: '' # try to enter invalid input into the zip code field diff --git a/spec/features/idv/steps/in_person/verify_info_spec.rb b/spec/features/idv/steps/in_person/verify_info_spec.rb index e0872eef1cc..c4a4be66b56 100644 --- a/spec/features/idv/steps/in_person/verify_info_spec.rb +++ b/spec/features/idv/steps/in_person/verify_info_spec.rb @@ -7,10 +7,14 @@ let(:user) { user_with_2fa } let(:fake_analytics) { FakeAnalytics.new(user: user) } + let(:capture_secondary_id_enabled) { false } + let(:enrollment) { InPersonEnrollment.new(capture_secondary_id_enabled:) } before do allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics) + allow(user).to receive(:enrollment). + and_return(enrollment) end it 'provides back buttons for address, state ID, and SSN that discard changes', diff --git a/spec/forms/idv/state_id_form_spec.rb b/spec/forms/idv/state_id_form_spec.rb index 7cb107f7db5..a2d371c481d 100644 --- a/spec/forms/idv/state_id_form_spec.rb +++ b/spec/forms/idv/state_id_form_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' RSpec.describe Idv::StateIdForm do - let(:subject) { Idv::StateIdForm.new(pii) } + let(:subject) { Idv::StateIdForm.new(pii, capture_secondary_id_enabled:) } let(:valid_dob) do valid_d = Time.zone.today - IdentityConfig.store.idv_min_age_years.years - 1.day ActionController::Parameters.new( @@ -22,6 +22,7 @@ dob: valid_dob, identity_doc_address1: Faker::Address.street_address, identity_doc_address2: Faker::Address.secondary_address, + identity_doc_city: Faker::Address.city, identity_doc_zipcode: Faker::Address.zip_code, identity_doc_address_state: Faker::Address.state_abbr, same_address_as_id: 'true', @@ -36,6 +37,7 @@ dob: too_young_dob, identity_doc_address1: Faker::Address.street_address, identity_doc_address2: Faker::Address.secondary_address, + identity_doc_city: Faker::Address.city, identity_doc_zipcode: Faker::Address.zip_code, identity_doc_address_state: Faker::Address.state_abbr, same_address_as_id: 'true', @@ -51,6 +53,7 @@ dob: valid_dob, identity_doc_address1: Faker::Address.street_address, identity_doc_address2: Faker::Address.secondary_address, + identity_doc_city: Faker::Address.city, identity_doc_zipcode: Faker::Address.zip_code, identity_doc_address_state: Faker::Address.state_abbr, same_address_as_id: 'true', @@ -59,6 +62,7 @@ } end let(:pii) { nil } + let(:capture_secondary_id_enabled) { true } describe '#submit' do context 'when the form is valid' do it 'returns a successful form response' do diff --git a/spec/support/features/idv_step_helper.rb b/spec/support/features/idv_step_helper.rb index 4f14215840b..86b3b700e40 100644 --- a/spec/support/features/idv_step_helper.rb +++ b/spec/support/features/idv_step_helper.rb @@ -134,7 +134,7 @@ def complete_idv_steps_before_ssn(user = user_with_2fa) # location page complete_location_step(user) # state ID page - fill_out_state_id_form_ok(double_address_verification: true, same_address_as_id: true) + fill_out_state_id_form_ok(same_address_as_id: true, capture_secondary_id_enabled: true) click_idv_continue end diff --git a/spec/support/features/in_person_helper.rb b/spec/support/features/in_person_helper.rb index 672ea15dbec..8f856af732e 100644 --- a/spec/support/features/in_person_helper.rb +++ b/spec/support/features/in_person_helper.rb @@ -31,7 +31,7 @@ module InPersonHelper GOOD_IDENTITY_DOC_ZIPCODE = Idp::Constants::MOCK_IDV_APPLICANT_STATE_ID_ADDRESS[:identity_doc_zipcode] - def fill_out_state_id_form_ok(double_address_verification: false, same_address_as_id: false) + def fill_out_state_id_form_ok(same_address_as_id: false, capture_secondary_id_enabled: false) fill_in t('in_person_proofing.form.state_id.first_name'), with: GOOD_FIRST_NAME fill_in t('in_person_proofing.form.state_id.last_name'), with: GOOD_LAST_NAME year, month, day = GOOD_DOB.split('-') @@ -42,7 +42,7 @@ def fill_out_state_id_form_ok(double_address_verification: false, same_address_a from: t('in_person_proofing.form.state_id.state_id_jurisdiction') fill_in t('in_person_proofing.form.state_id.state_id_number'), with: GOOD_STATE_ID_NUMBER - if double_address_verification + if capture_secondary_id_enabled fill_in t('in_person_proofing.form.state_id.address1'), with: GOOD_IDENTITY_DOC_ADDRESS1 fill_in t('in_person_proofing.form.state_id.address2'), with: GOOD_IDENTITY_DOC_ADDRESS2 fill_in t('in_person_proofing.form.state_id.city'), with: GOOD_IDENTITY_DOC_CITY @@ -123,15 +123,15 @@ def complete_prepare_step(_user = nil) end def complete_state_id_step(_user = nil, same_address_as_id: true, - double_address_verification: false) + capture_secondary_id_enabled: false) # Wait for page to load before attempting to fill out form expect(page).to have_current_path(idv_in_person_step_path(step: :state_id), wait: 10) fill_out_state_id_form_ok( - double_address_verification: double_address_verification, same_address_as_id: same_address_as_id, + capture_secondary_id_enabled: capture_secondary_id_enabled, ) click_idv_continue - unless double_address_verification && same_address_as_id + unless capture_secondary_id_enabled && same_address_as_id expect(page).to have_current_path(idv_in_person_step_path(step: :address), wait: 10) expect_in_person_step_indicator_current_step(t('step_indicator.flows.idv.verify_info')) end