diff --git a/spec/features/idv/steps/in_person/address_spec.rb b/spec/features/idv/steps/in_person/address_spec.rb index a3bb3a03ae3..42d5cbabb04 100644 --- a/spec/features/idv/steps/in_person/address_spec.rb +++ b/spec/features/idv/steps/in_person/address_spec.rb @@ -51,7 +51,6 @@ 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_ADDRESS1) - 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) @@ -72,7 +71,6 @@ # 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( @@ -82,8 +80,8 @@ end end - context 'Transliterable Validation' do - before(:each) do + context 'transliterable Validation' do + before do allow(IdentityConfig.store).to receive(:usps_ipp_transliteration_enabled). and_return(true) end @@ -134,7 +132,7 @@ end end - context 'Validation' do + context 'validation' do it 'validates zip code input', allow_browser_log: true do complete_idv_steps_before_address @@ -156,7 +154,7 @@ end end - context 'State selection' do + 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 diff --git a/spec/features/idv/steps/in_person/state_id_controller_spec.rb b/spec/features/idv/steps/in_person/state_id_spec.rb similarity index 62% rename from spec/features/idv/steps/in_person/state_id_controller_spec.rb rename to spec/features/idv/steps/in_person/state_id_spec.rb index 1bf4c26f9a7..b9ae0d07f62 100644 --- a/spec/features/idv/steps/in_person/state_id_controller_spec.rb +++ b/spec/features/idv/steps/in_person/state_id_spec.rb @@ -14,11 +14,7 @@ expect(page).to have_content(t('forms.buttons.continue')) expect(page).to have_content( - strip_nbsp( - t( - 'in_person_proofing.headings.state_id_milestone_2', - ), - ), + strip_nbsp(t('in_person_proofing.headings.state_id_milestone_2')), ) end @@ -122,157 +118,145 @@ ) end - context 'same address as id', - allow_browser_log: true do + context 'same_address_as_id', allow_browser_log: true do let(:user) { user_with_2fa } - before(:each) do + before 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_controller(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_link 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_link 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_controller(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_link 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_link 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_controller(user, same_address_as_id: true) - # skip address step - complete_ssn_step(user) - # click update state ID button on the verify page - click_link 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_link 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, - ) + context 'when the user answers "Yes" for same address as state ID' do + before do + complete_state_id_controller(user, same_address_as_id: true) + complete_ssn_step(user) + click_link t('idv.buttons.change_state_id_label') + end + + context 'when the user does not update the same address value' do + it 'does not change their previous selection' do + # 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 + # for state id address and address update + expect(page).to have_text('test update address').twice + # click update state id address + click_link 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 + end + + context 'when the user updates the same address value to "No"' do + it 'updates their selection to "No"' do + 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_link 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 + end end - it 'updates their previous selection from "No" TO "Yes, - I live at the address on my state-issued ID"' do - complete_state_id_controller(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_link 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_link 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, - ) + context 'when the user answers "No" for same address as state ID' do + before do + complete_state_id_controller(user, same_address_as_id: false) + complete_address_step(user) + complete_ssn_step(user) + click_link t('idv.buttons.change_state_id_label') + end + + context 'when the user does not update the same address value' do + it 'does not change their previous selection' do + # 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_link 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 + end + + context 'when the user updates the same address value to "Yes"' do + it 'updates their selection to "Yes"' do + # 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 + # for state id address and address update + expect(page).to have_text('test update address').twice + # click update state ID button on the verify page + click_link 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 end end - context 'Validation' do + context 'validation' do it 'validates zip code input', allow_browser_log: true do complete_steps_before_state_id_controller @@ -325,8 +309,8 @@ end end - context 'Transliterable Validation' do - before(:each) do + context 'transliterable validation' do + before do allow(IdentityConfig.store).to receive(:usps_ipp_transliteration_enabled). and_return(true) end @@ -394,7 +378,7 @@ end end - context 'State selection' do + 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_controller 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 deleted file mode 100644 index a4496cf623a..00000000000 --- a/spec/features/idv/steps/in_person/state_id_step_spec.rb +++ /dev/null @@ -1,471 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'doc auth IPP state ID step', js: true do - include IdvStepHelper - include InPersonHelper - - before do - allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) - end - - 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( - strip_nbsp( - t( - 'in_person_proofing.headings.state_id_milestone_2', - ), - ), - ) - 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_state_id_path, 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_path, wait: 10) - click_link 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_state_id_path, 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_link 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_link 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_link 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_link 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_link 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_link 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_link 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_link 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_address_url, 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_link 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 strip_tags( - t('in_person_proofing.form.state_id.state_id_number_florida_hint_html').gsub( - / /, ' ' - ), - ) - - # 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_html'), - ) - end - end -end 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 84bd305ce6e..528e6607973 100644 --- a/spec/features/idv/steps/in_person/verify_info_spec.rb +++ b/spec/features/idv/steps/in_person/verify_info_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' require 'axe-rspec' -RSpec.describe 'doc auth IPP VerifyInfo', js: true do +RSpec.describe 'doc auth IPP VerifyInfo', js: true, allow_browser_log: true do include IdvStepHelper include InPersonHelper @@ -16,165 +16,132 @@ and_return(enrollment) end - it 'provides back buttons for address, state ID, and SSN that discard changes', - allow_browser_log: true do - sign_in_and_2fa_user(user) - begin_in_person_proofing(user) - complete_prepare_step(user) - complete_location_step(user) - complete_state_id_controller(user) - complete_ssn_step(user) - - # verify page - 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_path) - expect(page).to have_content(t('headings.verify')) - 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).twice - expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS2).twice - expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_CITY).twice - expect(page).to have_text( - Idp::Constants::MOCK_IDV_APPLICANT[:state_id_jurisdiction], - count: 3, - ) - expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_ZIPCODE).twice - expect(page).to have_text(DocAuthHelper::GOOD_SSN_MASKED) - - # click update state ID button - click_link t('idv.buttons.change_state_id_label') - expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) - fill_in t('in_person_proofing.form.state_id.first_name'), with: 'bad first name' - click_doc_auth_back_link - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - expect(page).to have_text(InPersonHelper::GOOD_FIRST_NAME) - expect(page).not_to have_text('bad first name') - - # click update address link - click_link t('idv.buttons.change_address_label') - expect(page).to have_content(t('in_person_proofing.headings.update_address')) - fill_in t('idv.form.address1'), with: 'bad address' - click_doc_auth_back_link - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS1) - expect(page).not_to have_text('bad address') - - # click update ssn button - click_on t('idv.buttons.change_ssn_label') - expect(page).to have_content(t('doc_auth.headings.ssn_update')) - fill_out_ssn_form_fail - click_doc_auth_back_link - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - expect(page).to have_text(DocAuthHelper::GOOD_SSN_MASKED) - - complete_verify_step(user) - - # phone page - expect(page).to have_content(t('doc_auth.forms.doc_success')) - expect(page).to have_content(t('titles.idv.phone')) + context 'when visiting verify info for the first time' do + before do + complete_steps_before_info_verify(user) + end + + it 'displays all info submitted in the address, state ID and SSN steps' do + 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_path) + expect(page).to have_content(t('headings.verify')) + 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).twice + expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS2).twice + expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_CITY).twice + expect(page).to have_text( + Idp::Constants::MOCK_IDV_APPLICANT[:state_id_jurisdiction], + count: 3, + ) + expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_ZIPCODE).twice + expect(page).to have_text(DocAuthHelper::GOOD_SSN_MASKED) + end end - it 'returns the user to the verify info page when updates are made', - allow_browser_log: true do - sign_in_and_2fa_user(user) - begin_in_person_proofing(user) - complete_prepare_step(user) - complete_location_step(user) - complete_state_id_controller(user) - complete_ssn_step(user) - - # verify page - 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_path) - expect(page).to have_content(t('headings.verify')) - expect(page).to have_current_path(idv_in_person_verify_info_path) - 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).twice - expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS2).twice - expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_CITY).twice - expect(page).to have_text( - Idp::Constants::MOCK_IDV_APPLICANT[:state_id_jurisdiction], - count: 3, - ) - expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_ZIPCODE).twice - expect(page).to have_text(DocAuthHelper::GOOD_SSN_MASKED) - - # click update state ID button - click_link t('idv.buttons.change_state_id_label') - expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) - fill_in t('in_person_proofing.form.state_id.first_name'), with: 'Natalya' - 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) - expect(page).to have_text('Natalya') - expect(page).not_to have_text('bad first name') - - # click update address link - click_link t('idv.buttons.change_address_label') - expect(page).to have_content(t('in_person_proofing.headings.update_address')) - fill_in t('idv.form.address1'), with: '987 Fake St.' - 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) - expect(page).to have_text('987 Fake St.') - expect(page).not_to have_text('bad address') - - # click update ssn button - click_on t('idv.buttons.change_ssn_label') - expect(page).to have_content(t('doc_auth.headings.ssn_update')) - fill_in t('idv.form.ssn_label'), with: '900-12-2345' - 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) - expect(page).to have_text('9**-**-***5') - - complete_verify_step(user) - - # phone page - expect(page).to have_content(t('doc_auth.forms.doc_success')) - expect(page).to have_content(t('titles.idv.phone')) + context 'when performing updates for the address, state ID, and SSN info' do + before do + complete_steps_before_info_verify(user) + end + + it 'provides a back button for discarding changes' do + # click update state ID button + click_link t('idv.buttons.change_state_id_label') + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + fill_in t('in_person_proofing.form.state_id.first_name'), with: 'bad first name' + click_doc_auth_back_link + expect(page).to have_content(t('headings.verify')) + expect(page).to have_current_path(idv_in_person_verify_info_path) + expect(page).to have_text(InPersonHelper::GOOD_FIRST_NAME) + expect(page).not_to have_text('bad first name') + + # click update address link + click_link t('idv.buttons.change_address_label') + expect(page).to have_content(t('in_person_proofing.headings.update_address')) + fill_in t('idv.form.address1'), with: 'bad address' + click_doc_auth_back_link + expect(page).to have_content(t('headings.verify')) + expect(page).to have_current_path(idv_in_person_verify_info_path) + expect(page).to have_text(InPersonHelper::GOOD_IDENTITY_DOC_ADDRESS1) + expect(page).not_to have_text('bad address') + + # click update ssn button + click_on t('idv.buttons.change_ssn_label') + expect(page).to have_content(t('doc_auth.headings.ssn_update')) + fill_out_ssn_form_fail + click_doc_auth_back_link + expect(page).to have_content(t('headings.verify')) + expect(page).to have_current_path(idv_in_person_verify_info_path) + expect(page).to have_text(DocAuthHelper::GOOD_SSN_MASKED) + end + + it 'updates the info on the verify info page' do + # click update state ID button + click_link t('idv.buttons.change_state_id_label') + expect(page).to have_content(t('in_person_proofing.headings.update_state_id')) + fill_in t('in_person_proofing.form.state_id.first_name'), with: 'Natalya' + 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) + expect(page).to have_text('Natalya') + expect(page).not_to have_text('bad first name') + + # click update address link + click_link t('idv.buttons.change_address_label') + expect(page).to have_content(t('in_person_proofing.headings.update_address')) + fill_in t('idv.form.address1'), with: '987 Fake St.' + 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) + expect(page).to have_text('987 Fake St.') + expect(page).not_to have_text('bad address') + + # click update ssn button + click_on t('idv.buttons.change_ssn_label') + expect(page).to have_content(t('doc_auth.headings.ssn_update')) + fill_in t('idv.form.ssn_label'), with: '900-12-2345' + 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) + expect(page).to have_text('9**-**-***5') + end end - it 'does not proceed to the next page if resolution fails', - allow_browser_log: true do - sign_in_and_2fa_user - - begin_in_person_proofing(user) - complete_prepare_step(user) - complete_location_step(user) - complete_state_id_controller(user) - fill_out_ssn_form_with_ssn_that_fails_resolution - click_idv_continue - complete_verify_step(user) - - expect(page).to have_current_path(idv_session_errors_warning_path(flow: 'in_person')) - click_on t('idv.failure.button.warning') - - expect(page).to have_current_path(idv_in_person_verify_info_path) - end - - it 'proceeds to the next page if resolution passes', - allow_browser_log: true do - sign_in_and_2fa_user - begin_in_person_proofing(user) - complete_prepare_step(user) - complete_location_step(user) - complete_state_id_controller(user) - complete_ssn_step(user) - complete_verify_step(user) - - expect(page).to have_content(t('titles.idv.phone')) - expect(fake_analytics).to have_logged_event( - 'IdV: doc auth verify proofing results', - hash_including(analytics_id: 'In Person Proofing'), - ) + context 'when completing the verify info step' do + context 'when SSN resolution fails' do + it 'navigates to the session warning page' do + sign_in_and_2fa_user(user) + begin_in_person_proofing(user) + complete_prepare_step(user) + complete_location_step(user) + complete_state_id_controller(user) + fill_out_ssn_form_with_ssn_that_fails_resolution + click_idv_continue + complete_verify_step(user) + + expect(page).to have_current_path(idv_session_errors_warning_path(flow: 'in_person')) + click_on t('idv.failure.button.warning') + + expect(page).to have_current_path(idv_in_person_verify_info_path) + end + end + + context 'when SSN resolution passes' do + before do + complete_steps_before_info_verify(user) + complete_verify_step(user) + end + + it 'navigates to the verify phone' do + expect(page).to have_content(t('doc_auth.forms.doc_success')) + expect(page).to have_content(t('titles.idv.phone')) + expect(fake_analytics).to have_logged_event( + 'IdV: doc auth verify proofing results', + hash_including(analytics_id: 'In Person Proofing'), + ) + end + end end end diff --git a/spec/support/features/in_person_helper.rb b/spec/support/features/in_person_helper.rb index 36730c23cc3..41fbaef6b9c 100644 --- a/spec/support/features/in_person_helper.rb +++ b/spec/support/features/in_person_helper.rb @@ -174,6 +174,15 @@ def complete_steps_before_state_id_controller expect(page).to have_current_path(idv_in_person_state_id_path, wait: 10) end + def complete_steps_before_info_verify(user = user_with_2fa) + sign_in_and_2fa_user(user) + begin_in_person_proofing(user) + complete_prepare_step(user) + complete_location_step(user) + complete_state_id_controller(user) + complete_ssn_step(user) + end + def complete_all_in_person_proofing_steps(user = user_with_2fa, tmx_status = nil, same_address_as_id: true) complete_prepare_step(user)