Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion app/controllers/idv/confirm_start_over_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,30 @@ class ConfirmStartOverController < ApplicationController
before_action :confirm_idv_needed

def index
analytics.idv_gpo_confirm_start_over_visited
@step_indicator_step = requested_letter_before? ? :get_a_letter : :verify_phone_or_address

# Temporarily check referer until request letter view is updated to link to
# the before_letter route
if request.referer == idv_request_letter_url
analytics.idv_gpo_confirm_start_over_before_letter_visited
render 'idv/confirm_start_over/before_letter'
else
Comment on lines +15 to +18
Copy link
Contributor

@matthinz matthinz Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a double take at this initially but then saw the note in the description about how this is temporary. This is fine for now, but I don't want any referer-checking code sitting around long term.

Maybe just call it out a little bit (and clarify that we're calling out to before_letter here):

Suggested change
if request.referer == idv_request_letter_url
analytics.idv_gpo_confirm_start_over_before_letter_visited
render 'idv/confirm_start_over/before_letter'
else
# Temporarily check referer until link in request letter view is updated
if request.referer == idv_request_letter_url
before_letter
else

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followup PR: #9423

analytics.idv_gpo_confirm_start_over_visited
render :index
end
end

def before_letter
@step_indicator_step = requested_letter_before? ? :get_a_letter : :verify_phone_or_address
analytics.idv_gpo_confirm_start_over_before_letter_visited

render 'idv/confirm_start_over/before_letter'
end

private

def requested_letter_before?
current_user&.gpo_verification_pending_profile?
end
end
end
9 changes: 7 additions & 2 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1105,9 +1105,14 @@ def idv_gpo_address_letter_requested(
)
end

# The user visited the gpo confirm cancellation screen from RequestLetter
def idv_gpo_confirm_start_over_before_letter_visited(**extra)
track_event(:idv_gpo_confirm_start_over_before_letter_visited, **extra)
end

# The user visited the gpo confirm cancellation screen
def idv_gpo_confirm_start_over_visited
track_event('IdV: gpo confirm start over visited') # rubocop:disable IdentityIdp/AnalyticsEventNameLinter
def idv_gpo_confirm_start_over_visited(**extra)
track_event('IdV: gpo confirm start over visited', **extra) # rubocop:disable IdentityIdp/AnalyticsEventNameLinter
end

# A GPO reminder email was sent to the user
Expand Down
25 changes: 25 additions & 0 deletions app/views/idv/confirm_start_over/before_letter.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<%= render(
'idv/shared/error',
type: :warning,
heading: t('idv.cancel.headings.prompt.start_over'),
current_step: @step_indicator_step,
) do %>
<p>
<%= t('idv.cancel.description.gpo.start_over_new_address') %>
</p>
<p>
<%= t('idv.cancel.description.gpo.continue') %>
</p>

<div class="margin-y-5">
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
button_to(idv_session_path(step: :gpo_verify), **tag_options, &block)
end,
method: :delete,
big: true,
wide: true,
).with_content(t('idv.buttons.continue_plain')) %>
</div>
<% end %>
<%= render('idv/shared/back', step: 'gpo_verify', fallback_path: idv_verify_by_mail_enter_code_path) %>
3 changes: 2 additions & 1 deletion app/views/idv/confirm_start_over/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'idv/shared/error',
type: :warning,
heading: t('idv.cancel.headings.prompt.standard'),
current_step: :get_a_letter,
current_step: @step_indicator_step,
) do %>
<p>
<%= t('idv.cancel.description.gpo.start_over') %>
Expand All @@ -14,6 +14,7 @@
</li>
<% end %>
</ul>

<div class="margin-y-5">
<%= render ButtonComponent.new(
action: ->(**tag_options, &block) do
Expand Down
4 changes: 4 additions & 0 deletions config/locales/idv/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ en:
- You will still have a %{app_name} account. You can manage or
delete your account on your %{account_page_text}.
gpo:
continue: Continue to start over and verify your identity from the beginning.
start_over: 'If you clear your information and start over:'
start_over_new_address: To mail your letter to another address, you’ll need to
start over and verify your identity with the new address.
warnings:
- The verification code in your letter will no longer work
- You will start over verifying your identity from the beginning
Expand All @@ -48,6 +51,7 @@ en:
hybrid: Are you sure you want to cancel uploading photos of your ID on this
phone?
standard: Cancel verifying your identity?
start_over: Start over verifying your identity?
start_over: Start over verifying your identity
errors:
incorrect_password: The password you entered is not correct.
Expand Down
5 changes: 5 additions & 0 deletions config/locales/idv/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ es:
- No obstante, continuará teniendo una cuenta en %{app_name}. Puede
administrar o eliminar su cuenta desde %{account_page_text}.
gpo:
continue: Continúe empezando de nuevo y verifique su identidad desde el
principio.
start_over: Si borras tu información y empiezas de nuevo
start_over_new_address: Para enviar su carta a otra dirección, tendrá que
empezar de nuevo y verificar su identidad con la nueva dirección.
warnings:
- El código de verificación de tu carta ya no funcionará
- Tendrás que volver a verificar tu identidad otra vez
Expand All @@ -49,6 +53,7 @@ es:
hybrid: '¿Seguro que desea cancelar la carga de fotos de su identificación en
este teléfono?'
standard: '¿Cancelar la verificación de su identidad?'
start_over: ¿Empezar de nuevo a verificar su identidad?
start_over: Empezar de nuevo a verificar su identidad
errors:
incorrect_password: La contraseña que ingresó no es correcta.
Expand Down
4 changes: 4 additions & 0 deletions config/locales/idv/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ fr:
- Vous aurez toujours un compte %{app_name}. Vous pouvez gérer ou
supprimer votre compte sur %{account_page_text}.
gpo:
continue: Recommencez et vérifiez votre identité depuis le début.
start_over: Si vous supprimez vos informations et recommencez
start_over_new_address: Pour envoyer votre lettre à une autre adresse, vous
devrez recommencer et vérifier votre identité à la nouvelle adresse.
warnings:
- Le code de vérification dans votre lettre ne fonctionnera plus
- Vous recommencerez la vérification de votre identité depuis le
Expand All @@ -52,6 +55,7 @@ fr:
hybrid: Êtes-vous sûr de vouloir annuler le téléchargement de vos photos
d’identité sur ce téléphone?
standard: Annuler la vérification de votre identité?
start_over: Recommencez la vérification de votre identité?
start_over: Recommencez la vérification de votre identité
errors:
incorrect_password: Le mot de passe que vous avez inscrit est incorrect.
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@
post '/by_mail/enter_code' => 'by_mail/enter_code#create'
get '/by_mail/confirm_start_over' => 'confirm_start_over#index',
as: :confirm_start_over
get '/by_mail/confirm_start_over/before_letter' => 'confirm_start_over#before_letter',
as: :confirm_start_over_before_letter

if FeatureManagement.gpo_verification_enabled?
get '/by_mail/request_letter' => 'by_mail/request_letter#index', as: :request_letter
Expand Down
66 changes: 53 additions & 13 deletions spec/features/idv/confirm_start_over_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,67 @@

before do
allow_any_instance_of(ApplicationController).to receive(:analytics).and_return(fake_analytics)
sign_in_live_with_2fa(user)
end

it 'can cancel from confirmation screen' do
expect(current_path).to eq idv_verify_by_mail_enter_code_path
context 'user decides to start over from request letter page' do
it 'allows user to start over' do
start_idv_from_sp
complete_idv_steps_before_gpo_step
click_on t('idv.messages.gpo.start_over_link_text')

click_on t('idv.messages.clear_and_start_over')
expect(current_path).to eq idv_confirm_start_over_path
expect(page).to have_content(t('idv.cancel.description.gpo.start_over_new_address'))
expect_step_indicator_current_step(t('step_indicator.flows.idv.verify_phone_or_address'))
expect(fake_analytics).to have_logged_event(:idv_gpo_confirm_start_over_before_letter_visited)
click_idv_continue

expect(current_path).to eq idv_confirm_start_over_path
expect(fake_analytics).to have_logged_event('IdV: gpo confirm start over visited')
expect(current_path).to eq idv_welcome_path
end
end

context 'user decides to start over from request letter page with new route' do
it 'allows user to start over' do
start_idv_from_sp
complete_idv_steps_before_gpo_step
click_on t('idv.messages.gpo.start_over_link_text')
visit idv_confirm_start_over_before_letter_path

click_idv_continue
expect(current_path).to eq idv_confirm_start_over_before_letter_path
expect(page).to have_content(t('idv.cancel.description.gpo.start_over_new_address'))
expect_step_indicator_current_step(t('step_indicator.flows.idv.verify_phone_or_address'))
expect(fake_analytics).to have_logged_event(:idv_gpo_confirm_start_over_before_letter_visited)
click_idv_continue

expect(current_path).to eq idv_welcome_path
expect(current_path).to eq idv_welcome_path
end
end

it 'can return back to verify screen from confirm screen' do
click_on t('idv.messages.clear_and_start_over')
click_on t('forms.buttons.back')
context 'user decides to start over after requesting a letter' do
before do
sign_in_live_with_2fa(user)
end

it 'can cancel from confirmation screen' do
expect(current_path).to eq idv_verify_by_mail_enter_code_path

click_on t('idv.messages.clear_and_start_over')

expect(current_path).to eq idv_confirm_start_over_path
expect(page).to have_content(t('idv.cancel.description.gpo.start_over'))
expect_step_indicator_current_step(t('step_indicator.flows.idv.get_a_letter'))
expect(fake_analytics).to have_logged_event('IdV: gpo confirm start over visited')

click_idv_continue

expect(current_path).to eq idv_welcome_path
end

it 'can return back to verify screen from confirm screen' do
click_on t('idv.messages.clear_and_start_over')
click_on t('forms.buttons.back')

expect(fake_analytics).to have_logged_event('IdV: gpo confirm start over visited')
expect(current_path).to eq idv_verify_by_mail_enter_code_path
expect(fake_analytics).to have_logged_event('IdV: gpo confirm start over visited')
expect(current_path).to eq idv_verify_by_mail_enter_code_path
end
end
end