diff --git a/spec/features/idv/doc_auth/verify_step_spec.rb b/spec/features/idv/doc_auth/verify_step_spec.rb index 06f90a92b7a..7e9cd01fdb9 100644 --- a/spec/features/idv/doc_auth/verify_step_spec.rb +++ b/spec/features/idv/doc_auth/verify_step_spec.rb @@ -7,36 +7,32 @@ let(:skip_step_completion) { false } let(:max_attempts) { Throttle.max_attempts(:idv_resolution) } let(:fake_analytics) { FakeAnalytics.new } - let(:user) { create(:user, :signed_up) } before do - unless skip_step_completion - sign_in_and_2fa_user(user) - complete_doc_auth_steps_before_verify_step - end + allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics) end - it 'is on the correct page' do + it 'displays the expected content' do + sign_in_and_2fa_user + complete_doc_auth_steps_before_verify_step + expect(page).to have_current_path(idv_doc_auth_verify_step) expect(page).to have_content(t('headings.verify')) expect(page).to have_css( '.step-indicator__step--current', text: t('step_indicator.flows.idv.verify_info'), ) - end - it 'masks the ssn until toggled visible' do + # SSN is masked until revealed expect(page).to have_text('9**-**-***4') expect(page).not_to have_text(DocAuthHelper::GOOD_SSN) - check t('forms.ssn.show') - expect(page).not_to have_text('9**-**-***4') expect(page).to have_text(DocAuthHelper::GOOD_SSN) end it 'proceeds to the next page upon confirmation' do - allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics) - + sign_in_and_2fa_user + complete_doc_auth_steps_before_verify_step click_idv_continue expect(page).to have_current_path(idv_phone_path) @@ -52,6 +48,8 @@ end it 'proceeds to address page prepopulated with defaults if the user clicks change address' do + sign_in_and_2fa_user + complete_doc_auth_steps_before_verify_step click_button t('idv.buttons.change_address_label') expect(page).to have_current_path(idv_address_path) @@ -61,7 +59,8 @@ end it 'tracks when the user edits their address' do - allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics) + sign_in_and_2fa_user + complete_doc_auth_steps_before_verify_step click_button t('idv.buttons.change_address_label') fill_out_address_form_ok @@ -76,6 +75,9 @@ end it 'proceeds to the ssn page if the user clicks change ssn and allows user to go back' do + sign_in_and_2fa_user + complete_doc_auth_steps_before_verify_step + click_button t('idv.buttons.change_ssn_label') expect(page).to have_current_path(idv_doc_auth_ssn_step) @@ -86,8 +88,6 @@ end it 'does not proceed to the next page if resolution fails' do - allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics) - sign_in_and_2fa_user complete_doc_auth_steps_before_ssn_step fill_out_ssn_form_with_ssn_that_fails_resolution @@ -107,8 +107,6 @@ end it 'does not proceed to the next page if resolution raises an exception' do - allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics) - sign_in_and_2fa_user complete_doc_auth_steps_before_ssn_step fill_out_ssn_form_with_ssn_that_raises_exception @@ -128,7 +126,6 @@ end it 'throttles resolution and continues when it expires' do - allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics) sign_in_and_2fa_user complete_doc_auth_steps_before_ssn_step fill_out_ssn_form_with_ssn_that_fails_resolution @@ -160,19 +157,21 @@ allow(IdentityConfig.store).to receive(:aamva_supported_jurisdictions).and_return( [Idp::Constants::MOCK_IDV_APPLICANT[:state_id_jurisdiction]], ) - - sign_in_and_2fa_user + expect_any_instance_of(Idv::Agent). + to receive(:proof_resolution). + with( + anything, + should_proof_state_id: true, + trace_id: anything, + ). + and_call_original + + user = create(:user, :signed_up) + sign_in_and_2fa_user(user) complete_doc_auth_steps_before_verify_step - agent = instance_double(Idv::Agent) - allow(Idv::Agent).to receive(:new).and_return(agent) - allow(agent).to receive(:proof_resolution).and_return( - success: true, errors: {}, context: { stages: [] }, - ) click_idv_continue - expect(agent).to have_received(:proof_resolution).with( - anything, should_proof_state_id: true, trace_id: anything - ) + expect(DocAuthLog.find_by(user_id: user.id).aamva).not_to be_nil end end @@ -182,19 +181,20 @@ IdentityConfig.store.aamva_supported_jurisdictions - [Idp::Constants::MOCK_IDV_APPLICANT[:state_id_jurisdiction]], ) - - sign_in_and_2fa_user + expect_any_instance_of(Idv::Agent). + to receive(:proof_resolution). + with( + anything, + should_proof_state_id: false, + trace_id: anything, + ). + and_call_original + + user = create(:user, :signed_up) + sign_in_and_2fa_user(user) complete_doc_auth_steps_before_verify_step - agent = instance_double(Idv::Agent) - allow(Idv::Agent).to receive(:new).and_return(agent) - allow(agent).to receive(:proof_resolution).and_return( - success: true, errors: {}, context: { stages: [] }, - ) click_idv_continue - expect(agent).to have_received(:proof_resolution).with( - anything, should_proof_state_id: false, trace_id: anything - ) expect(DocAuthLog.find_by(user_id: user.id).aamva).to be_nil end end @@ -203,20 +203,22 @@ it 'does not perform the state ID check' do allow(IdentityConfig.store).to receive(:aamva_sp_banlist_issuers). and_return('["urn:gov:gsa:openidconnect:sp:server"]') + expect_any_instance_of(Idv::Agent). + to receive(:proof_resolution). + with( + anything, + should_proof_state_id: false, + trace_id: anything, + ). + and_call_original visit_idp_from_sp_with_ial1(:oidc) - sign_in_and_2fa_user + user = create(:user, :signed_up) + sign_in_and_2fa_user(user) complete_doc_auth_steps_before_verify_step - agent = instance_double(Idv::Agent) - allow(Idv::Agent).to receive(:new).and_return(agent) - allow(agent).to receive(:proof_resolution).and_return( - success: true, errors: {}, context: { stages: [] }, - ) click_idv_continue - expect(agent).to have_received(:proof_resolution).with( - anything, should_proof_state_id: false, trace_id: anything - ) + expect(DocAuthLog.find_by(user_id: user.id).aamva).to be_nil end end @@ -225,9 +227,6 @@ sign_in_and_2fa_user complete_doc_auth_steps_before_verify_step - allow_any_instance_of(ApplicationController). - to receive(:analytics).and_return(fake_analytics) - allow(DocumentCaptureSession).to receive(:find_by). and_return(nil) @@ -241,43 +240,13 @@ end end - it 'can toggle viewing the ssn' do - expect(page).to have_text('9**-**-***4') - expect(page).not_to have_text(DocAuthHelper::GOOD_SSN) - - check t('forms.ssn.show') - expect(page).to have_text(DocAuthHelper::GOOD_SSN) - expect(page).not_to have_text('9**-**-***4') - - uncheck t('forms.ssn.show') - expect(page).to have_text('9**-**-***4') - expect(page).not_to have_text(DocAuthHelper::GOOD_SSN) - end - - context 'resolution failure' do - let(:skip_step_completion) { true } - - it 'does not proceed to the next page' do - sign_in_and_2fa_user - complete_doc_auth_steps_before_ssn_step - fill_out_ssn_form_with_ssn_that_fails_resolution - click_idv_continue - click_idv_continue - - expect(page).to have_current_path(idv_session_errors_warning_path) - - click_on t('idv.failure.button.warning') - - expect(page).to have_current_path(idv_doc_auth_verify_step) - end - end - context 'async timed out' do it 'allows resubmitting form' do + sign_in_and_2fa_user + complete_doc_auth_steps_before_verify_step + allow(DocumentCaptureSession).to receive(:find_by). and_return(nil) - allow_any_instance_of(ApplicationController). - to receive(:analytics).and_return(fake_analytics) click_idv_continue expect(page).to have_content(t('idv.failure.timeout'))