diff --git a/app/controllers/idv/in_person/usps_locations_controller.rb b/app/controllers/idv/in_person/usps_locations_controller.rb index f1b97b207a8..67b1f10dc98 100644 --- a/app/controllers/idv/in_person/usps_locations_controller.rb +++ b/app/controllers/idv/in_person/usps_locations_controller.rb @@ -7,7 +7,6 @@ class UspsLocationsController < ApplicationController include RenderConditionConcern include UspsInPersonProofing include EffectiveUser - include UspsInPersonProofing check_or_render_not_found -> { InPersonConfig.enabled? } diff --git a/lib/idp/constants.rb b/lib/idp/constants.rb index 03b45648ce5..b12c884dbcd 100644 --- a/lib/idp/constants.rb +++ b/lib/idp/constants.rb @@ -165,5 +165,6 @@ module Vendors MOCK_IDV_APPLICANT_FULL_STATE_ID_JURISDICTION = 'North Dakota' MOCK_IDV_APPLICANT_FULL_STATE = 'Montana' MOCK_IDV_APPLICANT_FULL_IDENTITY_DOC_ADDRESS_STATE = 'Virginia' + MOCK_IDV_APPLICANT_STATE = 'MT' end end diff --git a/spec/features/idv/in_person_spec.rb b/spec/features/idv/in_person_spec.rb index a1b8568f59e..d520a987931 100644 --- a/spec/features/idv/in_person_spec.rb +++ b/spec/features/idv/in_person_spec.rb @@ -420,155 +420,6 @@ end end - context 'transliteration' do - before(:each) do - allow(IdentityConfig.store).to receive(:usps_ipp_transliteration_enabled). - and_return(true) - end - - let(:user) { user_with_2fa } - let(:enrollment) { InPersonEnrollment.new } - - before do - allow(user).to receive(:establishing_in_person_enrollment). - and_return(enrollment) - end - - it 'shows validation errors', - allow_browser_log: true do - sign_in_and_2fa_user - begin_in_person_proofing - complete_prepare_step - 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 - 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' - fill_in t('in_person_proofing.form.state_id.address2'), with: 'Gr@nd Lañe^' - fill_in t('in_person_proofing.form.state_id.city'), with: 'B3st C!ty' - click_idv_continue - - expect(page).to have_content( - I18n.t( - 'in_person_proofing.form.state_id.errors.unsupported_chars', - char_list: '", 0', - ), - ) - - expect(page).to have_content( - I18n.t( - 'in_person_proofing.form.state_id.errors.unsupported_chars', - char_list: 'Д, б, е, ж, й, к, о', - ), - ) - - expect(page).to have_content( - I18n.t( - 'in_person_proofing.form.state_id.errors.unsupported_chars', - char_list: '$', - ), - ) - - expect(page).to have_content( - I18n.t( - 'in_person_proofing.form.state_id.errors.unsupported_chars', - char_list: '@, ^', - ), - ) - - expect(page).to have_content( - I18n.t( - 'in_person_proofing.form.state_id.errors.unsupported_chars', - char_list: '!, 3', - ), - ) - - # re-fill state id form with good inputs - fill_in t('in_person_proofing.form.state_id.first_name'), - with: InPersonHelper::GOOD_FIRST_NAME - fill_in t('in_person_proofing.form.state_id.last_name'), - with: InPersonHelper::GOOD_LAST_NAME - fill_in t('in_person_proofing.form.state_id.address1'), - with: InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS1 - fill_in t('in_person_proofing.form.state_id.address2'), - with: InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS2 - fill_in t('in_person_proofing.form.state_id.city'), - with: InPersonHelper::GOOD_IDENTITY_DOC_CITY - click_idv_continue - - expect(page).to have_current_path(idv_in_person_step_path(step: :address), wait: 10) - end - - it 'shows hints when user selects Puerto Rico as state', - allow_browser_log: true do - sign_in_and_2fa_user - begin_in_person_proofing - complete_prepare_step - complete_location_step - expect(page).to have_current_path(idv_in_person_step_path(step: :state_id), wait: 10) - - # state id page - select 'Puerto Rico', - from: t('in_person_proofing.form.state_id.identity_doc_address_state') - - expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address1_hint')) - expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address2_hint')) - - # change state selection - fill_out_state_id_form_ok - 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')) - - # re-select puerto rico - select 'Puerto Rico', - from: t('in_person_proofing.form.state_id.identity_doc_address_state') - click_idv_continue - - expect(page).to have_current_path(idv_in_person_step_path(step: :address)) - - # address form - select 'Puerto Rico', - from: t('idv.form.state') - expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address1_hint')) - expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address2_hint')) - - # change selection - fill_out_address_form_ok - 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')) - - # re-select puerto rico - select 'Puerto Rico', - from: t('idv.form.state') - click_idv_continue - - # ssn page - expect(page).to have_current_path(idv_in_person_ssn_url) - complete_ssn_step - - # verify page - expect(page).to have_current_path(idv_in_person_verify_info_path) - expect(page).to have_text('PR').twice - - # update state ID - click_button t('idv.buttons.change_state_id_label') - - expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) - expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address1_hint')) - expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address2_hint')) - click_button t('forms.buttons.submit.update') - - # update address - click_button t('idv.buttons.change_address_label') - - expect(page).to have_content(t('in_person_proofing.headings.update_address')) - expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address1_hint')) - expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address2_hint')) - end - end - context 'same address as id is false', allow_browser_log: true do let(:user) { user_with_2fa } @@ -607,7 +458,7 @@ end end - context 'same address as id is true then update is selected on verify info pg', + context 'same address as id is true', allow_browser_log: true do let(:user) { user_with_2fa } @@ -618,32 +469,26 @@ complete_location_step(user) end - it 'can redo the address page form after it is skipped' do - complete_state_id_step(user, same_address_as_id: true) - # skip address step - complete_ssn_step(user) - # click update address button on the verify page - click_button t('idv.buttons.change_address_label') - expect(page).to have_content(t('in_person_proofing.headings.update_address')) - fill_out_address_form_ok(same_address_as_id: true) - click_button t('forms.buttons.submit.update') - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - 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) + # skip address step b/c residential address is same as state id address complete_ssn_step(user) - # click "update residential address" + # click update residential address click_button t('idv.buttons.change_address_label') expect(page).to have_content(t('in_person_proofing.headings.update_address')) - # change something in the address + # expect address page to have fields populated with address from state id + expect(page).to have_field( + t('idv.form.address1'), + with: InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS1, + ) + + # change part of the address fill_in t('idv.form.address1'), with: 'new address different from state address1' # click update click_button t('forms.buttons.submit.update') - # back to verify page + # verify page expect(page).to have_current_path(idv_in_person_verify_info_path) expect(page).to have_content(t('headings.verify')) expect(page).to have_text('new address different from state address1').once @@ -659,156 +504,38 @@ end end - context 'Updates are made on state ID page starting from Verify Your Information', - allow_browser_log: true do + context 'Outage alert enabled' do let(:user) { user_with_2fa } - before(:each) do - sign_in_and_2fa_user(user) - begin_in_person_proofing(user) - complete_prepare_step(user) - complete_location_step(user) - end - - 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) - # skip address step - complete_ssn_step(user) - # expect to be on verify page - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - # click update state ID button on the verify page - click_button t('idv.buttons.change_state_id_label') - # expect to be on the state ID page - expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) - # change address - fill_in t('in_person_proofing.form.state_id.address1'), with: '' - fill_in t('in_person_proofing.form.state_id.address1'), with: 'test update address' - click_button t('forms.buttons.submit.update') - # expect to be back on verify page - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - expect(page).to have_content(t('headings.verify')) - # expect to see state ID address update on verify twice - expect(page).to have_text('test update address').twice # for state id addr and addr update - # click update state id address - click_button t('idv.buttons.change_state_id_label') - # expect to be on the state ID page - expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) - # expect "Yes, I live at a different address" is checked" - expect(page).to have_checked_field( - t('in_person_proofing.form.state_id.same_address_as_id_yes'), - visible: false, - ) + before do + allow(IdentityConfig.store).to receive(:in_person_outage_message_enabled).and_return(true) 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) - # expect to be on address page - expect(page).to have_content(t('in_person_proofing.headings.address')) - # complete address step - complete_address_step(user) - complete_ssn_step(user) - # expect to be back on verify page - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - # click update state ID button on the verify page - click_button t('idv.buttons.change_state_id_label') - # expect to be on the state ID page - expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) - # change address - fill_in t('in_person_proofing.form.state_id.address1'), with: '' - fill_in t('in_person_proofing.form.state_id.address1'), with: 'test update address' - click_button t('forms.buttons.submit.update') - # expect to be back on verify page - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - expect(page).to have_content(t('headings.verify')) - # expect to see state ID address update on verify - expect(page).to have_text('test update address').once # only state id address update - # click update state id address - click_button t('idv.buttons.change_state_id_label') - # expect to be on the state ID page - expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) - expect(page).to have_checked_field( - t('in_person_proofing.form.state_id.same_address_as_id_no'), - visible: false, - ) - end + it 'allows the user to generate a barcode despite outage', allow_browser_log: true do + sign_in_and_2fa_user(user) + begin_in_person_proofing(user) - 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) - # skip address step - complete_ssn_step(user) - # click update state ID button on the verify page - click_button t('idv.buttons.change_state_id_label') - # expect to be on the state ID page - expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) - # change address - fill_in t('in_person_proofing.form.state_id.address1'), with: '' - fill_in t('in_person_proofing.form.state_id.address1'), with: 'test update address' - # change response to No - choose t('in_person_proofing.form.state_id.same_address_as_id_no') - click_button t('forms.buttons.submit.update') - # expect to be on address page - expect(page).to have_content(t('in_person_proofing.headings.address')) - # complete address step - complete_address_step(user) - # expect to be on verify page - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - # expect to see state ID address update on verify - expect(page).to have_text('test update address').once # only state id address update - # click update state id address - click_button t('idv.buttons.change_state_id_label') - # expect to be on the state ID page - expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) - # check that the "No, I live at a different address" is checked" - expect(page).to have_checked_field( - t('in_person_proofing.form.state_id.same_address_as_id_no'), - visible: false, + # alert is visible on prepare page + expect(page).to have_content( + t( + 'idv.failure.exceptions.in_person_outage_error_message.post_cta.body', + app_name: APP_NAME, + ), ) - end + complete_all_in_person_proofing_steps + complete_phone_step(user) + complete_enter_password_step(user) + acknowledge_and_confirm_personal_key - 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) - # expect to be on address page - expect(page).to have_content(t('in_person_proofing.headings.address')) - # complete address step - complete_address_step(user) - complete_ssn_step(user) - # expect to be on verify page - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - # click update state ID button on the verify page - click_button t('idv.buttons.change_state_id_label') - # expect to be on the state ID page - expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) - # change address - fill_in t('in_person_proofing.form.state_id.address1'), with: '' - fill_in t('in_person_proofing.form.state_id.address1'), with: 'test update address' - # change response to Yes - choose t('in_person_proofing.form.state_id.same_address_as_id_yes') - click_button t('forms.buttons.submit.update') - # expect to be back on verify page - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - # expect to see state ID address update on verify twice - expect(page).to have_text('test update address').twice # for state id addr and addr update - # click update state ID button on the verify page - click_button t('idv.buttons.change_state_id_label') - # expect to be on the state ID page - expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) - expect(page).to have_checked_field( - t('in_person_proofing.form.state_id.same_address_as_id_yes'), - visible: false, + # alert is visible on ready to verify page + expect(page).to have_content( + t('idv.failure.exceptions.in_person_outage_error_message.ready_to_verify.body'), ) + expect(page).to have_current_path(idv_in_person_ready_to_verify_path, wait: 10) end end - context 'when manual address entry is enabled for post office search' do + context 'when full form address entry is enabled for post office search' do let(:user) { user_with_2fa } before do diff --git a/spec/features/idv/steps/in_person/address_spec.rb b/spec/features/idv/steps/in_person/address_spec.rb index b6055711e5e..c98fa252f59 100644 --- a/spec/features/idv/steps/in_person/address_spec.rb +++ b/spec/features/idv/steps/in_person/address_spec.rb @@ -23,6 +23,7 @@ it 'allows the user to cancel and start over', allow_browser_log: true do complete_idv_steps_before_address + expect(page).to have_current_path(idv_in_person_proofing_address_url, wait: 10) expect(page).not_to have_content('forms.buttons.back') click_link t('links.cancel') @@ -55,6 +56,143 @@ expect(page).to have_text(InPersonHelper::GOOD_ADDRESS2) expect(page).to have_text(InPersonHelper::GOOD_CITY) expect(page).to have_text(InPersonHelper::GOOD_ZIPCODE) + expect(page).to have_text(Idp::Constants::MOCK_IDV_APPLICANT_STATE) + end + end + + context 'updating address page' do + it 'has form fields that are pre-populated', allow_browser_log: true do + user = user_with_2fa + complete_idv_steps_before_address(user) + fill_out_address_form_ok + click_idv_continue + complete_ssn_step(user) + + expect(page).to have_current_path(idv_in_person_verify_info_url, wait: 10) + click_link t('idv.buttons.change_address_label') + + # address page has fields that are pre-populated + expect(page).to have_content(t('in_person_proofing.headings.update_address')) + expect(page).to have_field(t('idv.form.address1'), with: InPersonHelper::GOOD_ADDRESS1) + expect(page).to have_field(t('idv.form.address2'), with: InPersonHelper::GOOD_ADDRESS2) + expect(page).to have_field(t('idv.form.city'), with: InPersonHelper::GOOD_CITY) + expect(page).to have_field(t('idv.form.zipcode'), with: InPersonHelper::GOOD_ZIPCODE) + expect(page).to have_field( + t('idv.form.state'), + with: Idp::Constants::MOCK_IDV_APPLICANT_STATE, + ) + end + end + + context 'Transliterable Validation' do + before(:each) do + allow(IdentityConfig.store).to receive(:usps_ipp_transliteration_enabled). + and_return(true) + end + + it 'shows validation errors', + allow_browser_log: true do + complete_idv_steps_before_address + + fill_out_address_form_ok(same_address_as_id: false) + fill_in t('idv.form.address1'), with: '#1 $treet' + fill_in t('idv.form.address2'), with: 'Gr@nd Lañe^' + fill_in t('idv.form.city'), with: 'N3w C!ty' + click_idv_continue + + expect(page).to have_content( + I18n.t( + 'in_person_proofing.form.address.errors.unsupported_chars', + char_list: '$', + ), + ) + + expect(page).to have_content( + I18n.t( + 'in_person_proofing.form.address.errors.unsupported_chars', + char_list: '@, ^', + ), + ) + + expect(page).to have_content( + I18n.t( + 'in_person_proofing.form.address.errors.unsupported_chars', + char_list: '!, 3', + ), + ) + + select InPersonHelper::GOOD_STATE, from: t('idv.form.state') + fill_in t('idv.form.address1'), + with: InPersonHelper::GOOD_ADDRESS1 + fill_in t('idv.form.address2'), + with: InPersonHelper::GOOD_ADDRESS2 + fill_in t('idv.form.city'), + with: InPersonHelper::GOOD_CITY + fill_in t('idv.form.zipcode'), + with: InPersonHelper::GOOD_ZIPCODE + click_idv_continue + + expect(page).to have_current_path(idv_in_person_ssn_url, wait: 10) + end + end + + context 'Validation' do + it 'validates zip code input', allow_browser_log: true do + complete_idv_steps_before_address + + fill_out_address_form_ok + # blank out the zip code field + fill_in t('idv.form.zipcode'), with: '' + # try to enter invalid input into the zip code field + fill_in t('idv.form.zipcode'), with: 'invalid input' + expect(page).to have_field(t('idv.form.zipcode'), with: '') + # enter valid characters, but invalid length + fill_in t('idv.form.zipcode'), with: '123' + click_idv_continue + expect(page).to have_css('.usa-error-message', text: t('idv.errors.pattern_mismatch.zipcode')) + # enter a valid zip and make sure we can continue + fill_in t('idv.form.zipcode'), with: '123456789' + expect(page).to have_field(t('idv.form.zipcode'), with: '12345-6789') + click_idv_continue + expect(page).to have_current_path(idv_in_person_ssn_url) + end + end + + context 'State selection' do + it 'shows address hint when user selects state that has a specific hint', + allow_browser_log: true do + complete_idv_steps_before_address + + # address form + select 'Puerto Rico', + from: t('idv.form.state') + expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address1_hint')) + expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address2_hint')) + + # change selection + fill_out_address_form_ok(same_address_as_id: false) + 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')) + + # re-select puerto rico + select 'Puerto Rico', + from: t('idv.form.state') + click_idv_continue + + # ssn page + expect(page).to have_current_path(idv_in_person_ssn_url) + complete_ssn_step + + # verify page + expect(page).to have_current_path(idv_in_person_verify_info_path, wait: 10) + expect(page).to have_text('PR') + + # update address + click_link t('idv.buttons.change_address_label') + + expect(page).to have_content(t('in_person_proofing.headings.update_address')) + expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address1_hint')) + expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address2_hint')) end end end 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 aa774a0477a..2b761fba616 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 @@ -8,28 +8,454 @@ allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) end - it 'validates zip code input', allow_browser_log: true do - user = user_with_2fa - - sign_in_and_2fa_user(user) - begin_in_person_proofing(user) - 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(same_address_as_id: 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 - fill_in t('in_person_proofing.form.state_id.zipcode'), with: 'invalid input' - expect(page).to have_field(t('in_person_proofing.form.state_id.zipcode'), with: '') - # enter valid characters, but invalid length - fill_in t('in_person_proofing.form.state_id.zipcode'), with: '123' - click_idv_continue - expect(page).to have_css('.usa-error-message', text: t('idv.errors.pattern_mismatch.zipcode')) - # enter a valid zip and make sure we can continue - fill_in t('in_person_proofing.form.state_id.zipcode'), with: '123456789' - expect(page).to have_field(t('in_person_proofing.form.state_id.zipcode'), with: '12345-6789') - click_idv_continue - expect(page).to have_current_path(idv_in_person_ssn_url) + context 'when visiting state id for the first time' do + it 'displays correct heading and button text', allow_browser_log: true do + complete_steps_before_state_id_step + + expect(page).to have_content(t('forms.buttons.continue')) + expect(page).to have_content( + t( + 'in_person_proofing.headings.state_id_milestone_2', + ).tr(' ', ' '), + ) + end + + it 'allows the user to cancel and start over', allow_browser_log: true do + complete_steps_before_state_id_step + + expect(page).not_to have_content('forms.buttons.back') + + click_link t('links.cancel') + click_on t('idv.cancel.actions.start_over') + expect(page).to have_current_path(idv_welcome_path) + end + + it 'allows the user to cancel and return', allow_browser_log: true do + complete_steps_before_state_id_step + + expect(page).not_to have_content('forms.buttons.back') + + click_link t('links.cancel') + click_on t('idv.cancel.actions.keep_going') + expect(page).to have_current_path(idv_in_person_step_path(step: :state_id), wait: 10) + end + + it 'allows user to submit valid inputs on form', allow_browser_log: true do + complete_steps_before_state_id_step + fill_out_state_id_form_ok(same_address_as_id: true) + click_idv_continue + + expect(page).to have_current_path(idv_in_person_ssn_url, wait: 10) + complete_ssn_step + + expect_in_person_step_indicator_current_step(t('step_indicator.flows.idv.verify_info')) + expect(page).to have_current_path(idv_in_person_verify_info_url) + expect(page).to have_text(InPersonHelper::GOOD_FIRST_NAME) + expect(page).to have_text(InPersonHelper::GOOD_LAST_NAME) + expect(page).to have_text(InPersonHelper::GOOD_DOB_FORMATTED_EVENT) + expect(page).to have_text(InPersonHelper::GOOD_STATE_ID_NUMBER) + expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS1) + expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS2) + expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_CITY) + expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_ZIPCODE) + end + end + + context 'updating state id page' do + it 'has form fields that are pre-populated', allow_browser_log: true do + complete_steps_before_state_id_step + + fill_out_state_id_form_ok(same_address_as_id: true) + click_idv_continue + expect(page).to have_current_path(idv_in_person_ssn_url, wait: 10) + complete_ssn_step + expect(page).to have_current_path(idv_in_person_verify_info_url, wait: 10) + click_button t('idv.buttons.change_state_id_label') + + # state id page has fields that are pre-populated + expect(page).to have_current_path(idv_in_person_step_path(step: :state_id), wait: 10) + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + expect(page).to have_field( + t('in_person_proofing.form.state_id.first_name'), + with: InPersonHelper::GOOD_FIRST_NAME, + ) + expect(page).to have_field( + t('in_person_proofing.form.state_id.last_name'), + with: InPersonHelper::GOOD_LAST_NAME, + ) + expect(page).to have_field(t('components.memorable_date.month'), with: '10') + expect(page).to have_field(t('components.memorable_date.day'), with: '6') + expect(page).to have_field(t('components.memorable_date.year'), with: '1938') + expect(page).to have_field( + t('in_person_proofing.form.state_id.state_id_jurisdiction'), + with: Idp::Constants::MOCK_IDV_APPLICANT[:state_id_jurisdiction], + ) + expect(page).to have_field( + t('in_person_proofing.form.state_id.state_id_number'), + with: InPersonHelper::GOOD_STATE_ID_NUMBER, + ) + expect(page).to have_field( + t('in_person_proofing.form.state_id.address1'), + with: InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS1, + ) + expect(page).to have_field( + t('in_person_proofing.form.state_id.address2'), + with: InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS2, + ) + expect(page).to have_field( + t('in_person_proofing.form.state_id.city'), + with: InPersonHelper::GOOD_IDENTITY_DOC_CITY, + ) + expect(page).to have_field( + t('in_person_proofing.form.state_id.zipcode'), + with: InPersonHelper::GOOD_IDENTITY_DOC_ZIPCODE, + ) + expect(page).to have_field( + t('in_person_proofing.form.state_id.identity_doc_address_state'), + with: Idp::Constants::MOCK_IDV_APPLICANT[:state_id_jurisdiction], + ) + expect(page).to have_checked_field( + t('in_person_proofing.form.state_id.same_address_as_id_yes'), + visible: false, + ) + end + + context 'same address as id', + allow_browser_log: true do + let(:user) { user_with_2fa } + + before(:each) do + sign_in_and_2fa_user(user) + begin_in_person_proofing(user) + complete_prepare_step(user) + complete_location_step(user) + end + + 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) + # skip address step + complete_ssn_step(user) + # expect to be on verify page + expect(page).to have_content(t('headings.verify')) + expect(page).to have_current_path(idv_in_person_verify_info_path) + # click update state ID button on the verify page + click_button t('idv.buttons.change_state_id_label') + # expect to be on the state ID page + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + # change address + fill_in t('in_person_proofing.form.state_id.address1'), with: '' + fill_in t('in_person_proofing.form.state_id.address1'), with: 'test update address' + click_button t('forms.buttons.submit.update') + # expect to be back on verify page + expect(page).to have_content(t('headings.verify')) + expect(page).to have_current_path(idv_in_person_verify_info_path) + expect(page).to have_content(t('headings.verify')) + # expect to see state ID address update on verify twice + expect(page).to have_text('test update address').twice # for state id addr and addr update + # click update state id address + click_button t('idv.buttons.change_state_id_label') + # expect to be on the state ID page + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + # expect "Yes, I live at a different address" is checked" + expect(page).to have_checked_field( + t('in_person_proofing.form.state_id.same_address_as_id_yes'), + visible: false, + ) + 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) + # expect to be on address page + expect(page).to have_content(t('in_person_proofing.headings.address')) + # complete address step + complete_address_step(user) + complete_ssn_step(user) + # expect to be back on verify page + expect(page).to have_content(t('headings.verify')) + expect(page).to have_current_path(idv_in_person_verify_info_path) + # click update state ID button on the verify page + click_button t('idv.buttons.change_state_id_label') + # expect to be on the state ID page + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + # change address + fill_in t('in_person_proofing.form.state_id.address1'), with: '' + fill_in t('in_person_proofing.form.state_id.address1'), with: 'test update address' + click_button t('forms.buttons.submit.update') + # expect to be back on verify page + expect(page).to have_content(t('headings.verify')) + expect(page).to have_current_path(idv_in_person_verify_info_path) + expect(page).to have_content(t('headings.verify')) + # expect to see state ID address update on verify + expect(page).to have_text('test update address').once # only state id address update + # click update state id address + click_button t('idv.buttons.change_state_id_label') + # expect to be on the state ID page + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + expect(page).to have_checked_field( + t('in_person_proofing.form.state_id.same_address_as_id_no'), + visible: false, + ) + 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) + # skip address step + complete_ssn_step(user) + # click update state ID button on the verify page + click_button t('idv.buttons.change_state_id_label') + # expect to be on the state ID page + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + # change address + fill_in t('in_person_proofing.form.state_id.address1'), with: '' + fill_in t('in_person_proofing.form.state_id.address1'), with: 'test update address' + # change response to No + choose t('in_person_proofing.form.state_id.same_address_as_id_no') + click_button t('forms.buttons.submit.update') + # expect to be on address page + expect(page).to have_content(t('in_person_proofing.headings.address')) + # complete address step + complete_address_step(user) + # expect to be on verify page + expect(page).to have_content(t('headings.verify')) + expect(page).to have_current_path(idv_in_person_verify_info_path) + # expect to see state ID address update on verify + expect(page).to have_text('test update address').once # only state id address update + # click update state id address + click_button t('idv.buttons.change_state_id_label') + # expect to be on the state ID page + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + # check that the "No, I live at a different address" is checked" + expect(page).to have_checked_field( + t('in_person_proofing.form.state_id.same_address_as_id_no'), + visible: false, + ) + end + + 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) + # expect to be on address page + expect(page).to have_content(t('in_person_proofing.headings.address')) + # complete address step + complete_address_step(user) + complete_ssn_step(user) + # expect to be on verify page + expect(page).to have_content(t('headings.verify')) + expect(page).to have_current_path(idv_in_person_verify_info_path) + # click update state ID button on the verify page + click_button t('idv.buttons.change_state_id_label') + # expect to be on the state ID page + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + # change address + fill_in t('in_person_proofing.form.state_id.address1'), with: '' + fill_in t('in_person_proofing.form.state_id.address1'), with: 'test update address' + # change response to Yes + choose t('in_person_proofing.form.state_id.same_address_as_id_yes') + click_button t('forms.buttons.submit.update') + # expect to be back on verify page + expect(page).to have_content(t('headings.verify')) + expect(page).to have_current_path(idv_in_person_verify_info_path) + # expect to see state ID address update on verify twice + expect(page).to have_text('test update address').twice # for state id addr and addr update + # click update state ID button on the verify page + click_button t('idv.buttons.change_state_id_label') + # expect to be on the state ID page + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + expect(page).to have_checked_field( + t('in_person_proofing.form.state_id.same_address_as_id_yes'), + visible: false, + ) + end + end + end + + context 'Validation' do + it 'validates zip code input', allow_browser_log: true do + complete_steps_before_state_id_step + + fill_out_state_id_form_ok(same_address_as_id: true) + fill_in t('in_person_proofing.form.state_id.zipcode'), with: '' + fill_in t('in_person_proofing.form.state_id.zipcode'), with: 'invalid input' + expect(page).to have_field(t('in_person_proofing.form.state_id.zipcode'), with: '') + + # enter valid characters, but invalid length + fill_in t('in_person_proofing.form.state_id.zipcode'), with: '123' + click_idv_continue + expect(page).to have_css('.usa-error-message', text: t('idv.errors.pattern_mismatch.zipcode')) + + # enter a valid zip and make sure we can continue + fill_in t('in_person_proofing.form.state_id.zipcode'), with: '123456789' + expect(page).to have_field(t('in_person_proofing.form.state_id.zipcode'), with: '12345-6789') + click_idv_continue + expect(page).to have_current_path(idv_in_person_ssn_url) + end + + it 'shows error for dob under minimum age', allow_browser_log: true do + complete_steps_before_state_id_step + + fill_in t('components.memorable_date.month'), with: '1' + fill_in t('components.memorable_date.day'), with: '1' + fill_in t('components.memorable_date.year'), with: Time.zone.now.strftime('%Y') + click_idv_continue + expect(page).to have_content( + t( + 'in_person_proofing.form.state_id.memorable_date.errors.date_of_birth.range_min_age', + app_name: APP_NAME, + ), + ) + + year = (Time.zone.now - 13.years).strftime('%Y') + fill_in t('components.memorable_date.year'), with: year + click_idv_continue + expect(page).not_to have_content( + t( + 'in_person_proofing.form.state_id.memorable_date.errors.date_of_birth.range_min_age', + app_name: APP_NAME, + ), + ) + end + end + + context 'Transliterable Validation' do + before(:each) do + allow(IdentityConfig.store).to receive(:usps_ipp_transliteration_enabled). + and_return(true) + end + + it 'shows validation errors', + allow_browser_log: true do + complete_steps_before_state_id_step + + fill_out_state_id_form_ok + 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' + fill_in t('in_person_proofing.form.state_id.address2'), with: 'Gr@nd Lañe^' + fill_in t('in_person_proofing.form.state_id.city'), with: 'N3w C!ty' + click_idv_continue + + expect(page).to have_content( + I18n.t( + 'in_person_proofing.form.state_id.errors.unsupported_chars', + char_list: '", 0', + ), + ) + + expect(page).to have_content( + I18n.t( + 'in_person_proofing.form.state_id.errors.unsupported_chars', + char_list: 'Д, б, е, ж, й, к, о', + ), + ) + + expect(page).to have_content( + I18n.t( + 'in_person_proofing.form.state_id.errors.unsupported_chars', + char_list: '$', + ), + ) + + expect(page).to have_content( + I18n.t( + 'in_person_proofing.form.state_id.errors.unsupported_chars', + char_list: '@, ^', + ), + ) + + expect(page).to have_content( + I18n.t( + 'in_person_proofing.form.state_id.errors.unsupported_chars', + char_list: '!, 3', + ), + ) + + fill_in t('in_person_proofing.form.state_id.first_name'), + with: InPersonHelper::GOOD_FIRST_NAME + fill_in t('in_person_proofing.form.state_id.last_name'), + with: InPersonHelper::GOOD_LAST_NAME + fill_in t('in_person_proofing.form.state_id.address1'), + with: InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS1 + fill_in t('in_person_proofing.form.state_id.address2'), + with: InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS2 + fill_in t('in_person_proofing.form.state_id.city'), + with: InPersonHelper::GOOD_IDENTITY_DOC_CITY + click_idv_continue + + expect(page).to have_current_path(idv_in_person_step_path(step: :address), wait: 10) + end + end + + context 'State selection' do + it 'shows address hint when user selects state that has a specific hint', + allow_browser_log: true do + complete_steps_before_state_id_step + + # state id page + select 'Puerto Rico', + from: t('in_person_proofing.form.state_id.identity_doc_address_state') + + expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address1_hint')) + expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address2_hint')) + + # change state selection + fill_out_state_id_form_ok(same_address_as_id: 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')) + + # re-select puerto rico + select 'Puerto Rico', + from: t('in_person_proofing.form.state_id.identity_doc_address_state') + click_idv_continue + + # ssn page + expect(page).to have_current_path(idv_in_person_ssn_url) + complete_ssn_step + + # verify page + expect(page).to have_current_path(idv_in_person_verify_info_path) + expect(page).to have_text('PR') + + # update state ID + click_button t('idv.buttons.change_state_id_label') + + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address1_hint')) + expect(page).to have_content(I18n.t('in_person_proofing.form.state_id.address2_hint')) + end + + it 'shows id number hint when user selects issuing state that has a specific hint', + allow_browser_log: true do + complete_steps_before_state_id_step + + # expect default hint to be present + expect(page).to have_content(t('in_person_proofing.form.state_id.state_id_number_hint')) + + select 'Texas', + from: t('in_person_proofing.form.state_id.state_id_jurisdiction') + expect(page).to have_content(t('in_person_proofing.form.state_id.state_id_number_texas_hint')) + expect(page).not_to have_content(t('in_person_proofing.form.state_id.state_id_number_hint')) + + select 'Florida', + from: t('in_person_proofing.form.state_id.state_id_jurisdiction') + expect(page).not_to have_content( + t('in_person_proofing.form.state_id.state_id_number_texas_hint'), + ) + expect(page).not_to have_content(t('in_person_proofing.form.state_id.state_id_number_hint')) + expect(page).to have_content( + t('in_person_proofing.form.state_id.state_id_number_florida_hint'), + ) + + # select a state without a state specific hint + select 'Ohio', + from: t('in_person_proofing.form.state_id.state_id_jurisdiction') + expect(page).to have_content(t('in_person_proofing.form.state_id.state_id_number_hint')) + expect(page).not_to have_content( + t('in_person_proofing.form.state_id.state_id_number_texas_hint'), + ) + expect(page).not_to have_content( + t('in_person_proofing.form.state_id.state_id_number_florida_hint'), + ) + end end end diff --git a/spec/support/features/in_person_helper.rb b/spec/support/features/in_person_helper.rb index 367a0ec9839..f8967ef86a5 100644 --- a/spec/support/features/in_person_helper.rb +++ b/spec/support/features/in_person_helper.rb @@ -147,6 +147,15 @@ def complete_verify_step(_user = nil) click_idv_submit_default end + def complete_steps_before_state_id_step + sign_in_and_2fa_user + begin_in_person_proofing + complete_prepare_step + complete_location_step + + expect(page).to have_current_path(idv_in_person_step_path(step: :state_id), wait: 10) + end + def complete_all_in_person_proofing_steps(user = user_with_2fa, same_address_as_id: true) complete_prepare_step(user) complete_location_step(user)