diff --git a/app/controllers/idv/welcome_controller.rb b/app/controllers/idv/welcome_controller.rb index 77e84bbb04d..ba1754d6b31 100644 --- a/app/controllers/idv/welcome_controller.rb +++ b/app/controllers/idv/welcome_controller.rb @@ -12,8 +12,7 @@ def show Funnel::DocAuth::RegisterStep.new(current_user.id, sp_session[:issuer]). call('welcome', :view, true) - @sp_name = decorated_sp_session.sp_name || APP_NAME - @title = t('doc_auth.headings.welcome', sp_name: @sp_name) + @presenter = Idv::WelcomePresenter.new(decorated_sp_session) end def update diff --git a/app/presenters/idv/welcome_presenter.rb b/app/presenters/idv/welcome_presenter.rb new file mode 100644 index 00000000000..6f938c937a5 --- /dev/null +++ b/app/presenters/idv/welcome_presenter.rb @@ -0,0 +1,82 @@ +module Idv + class WelcomePresenter + include ActionView::Helpers::TranslationHelper + include Rails.application.routes.url_helpers + include LinkHelper + include ActionView::Helpers::UrlHelper + + attr_accessor :url_options + + def initialize(decorated_sp_session) + @decorated_sp_session = decorated_sp_session + @url_options = {} + end + + def sp_name + decorated_sp_session.sp_name || APP_NAME + end + + def title + t('doc_auth.headings.welcome', sp_name: sp_name) + end + + def selfie_required? + decorated_sp_session.selfie_required? + end + + def explanation_text(help_link) + if selfie_required? + t( + 'doc_auth.info.stepping_up_html', + sp_name:, + link_html: help_link, + ) + else + t( + 'doc_auth.info.getting_started_html', + sp_name: sp_name, + link_html: help_link, + ) + end + end + + def bullet_points + [ + if selfie_required? + bullet_point( + t('doc_auth.instructions.bullet1_with_selfie'), + t('doc_auth.instructions.text1_with_selfie'), + ) + else + bullet_point( + t('doc_auth.instructions.bullet1'), + t('doc_auth.instructions.text1'), + ) + end, + + bullet_point( + t('doc_auth.instructions.bullet2'), + t('doc_auth.instructions.text2'), + ), + + bullet_point( + t('doc_auth.instructions.bullet3'), + t('doc_auth.instructions.text3'), + ), + + bullet_point( + t('doc_auth.instructions.bullet4', app_name: sp_name), + t('doc_auth.instructions.text4'), + ), + ] + end + + private + + attr_accessor :decorated_sp_session + + def bullet_point(bullet, text) + OpenStruct.new(bullet: bullet, text: text) + end + end +end diff --git a/app/views/idv/welcome/show.html.erb b/app/views/idv/welcome/show.html.erb index 0ce1009fd3c..950e6f58096 100644 --- a/app/views/idv/welcome/show.html.erb +++ b/app/views/idv/welcome/show.html.erb @@ -1,15 +1,13 @@ -<% self.title = @title %> +<% self.title = @presenter.title %> <%= render JavascriptRequiredComponent.new( header: t('idv.welcome.no_js_header'), - intro: t('idv.welcome.no_js_intro', sp_name: @sp_name), + intro: t('idv.welcome.no_js_intro', sp_name: @presenter.sp_name), location: :idv_welcome, ) do %> -<%= render PageHeadingComponent.new.with_content(@title) %> +<%= render PageHeadingComponent.new.with_content(@presenter.title) %>

- <%= t( - 'doc_auth.info.getting_started_html', - sp_name: @sp_name, - link_html: new_tab_link_to( + <%= @presenter.explanation_text( + new_tab_link_to( t('doc_auth.info.getting_started_learn_more'), help_center_redirect_path( category: 'verify-your-identity', @@ -25,31 +23,19 @@

<%= t('doc_auth.instructions.getting_started') %>

<%= render ProcessListComponent.new(heading_level: :h3, class: 'margin-y-3') do |c| %> - <% if decorated_sp_session.selfie_required? %> - <%= c.with_item(heading: t('doc_auth.instructions.bullet1_with_selfie')) do %> -

<%= t('doc_auth.instructions.text1_with_selfie') %>

+ <% @presenter.bullet_points.each do |point| %> + <%= c.with_item(heading: point.bullet) do %> +

<%= point.text %>

<% end %> - <% else %> - <%= c.with_item(heading: t('doc_auth.instructions.bullet1')) do %> -

<%= t('doc_auth.instructions.text1') %>

- <% end %> - <% end %> - <%= c.with_item(heading: t('doc_auth.instructions.bullet2')) do %> -

<%= t('doc_auth.instructions.text2') %>

- <% end %> - <%= c.with_item(heading: t('doc_auth.instructions.bullet3')) do %> -

<%= t('doc_auth.instructions.text3') %>

- <% end %> - <%= c.with_item(heading: t('doc_auth.instructions.bullet4', app_name: APP_NAME)) do %> -

<%= t('doc_auth.instructions.text4') %>

<% end %> <% end %> -<%= simple_form_for( - :doc_auth, - url: url_for, - method: 'put', - html: { autocomplete: 'off', class: 'margin-top-2 margin-bottom-5 js-consent-continue-form' }, - ) do |f| %> + + <%= simple_form_for( + :doc_auth, + url: url_for, + method: 'put', + html: { autocomplete: 'off', class: 'margin-top-2 margin-bottom-5 js-consent-continue-form' }, + ) do |f| %>
<%= render( diff --git a/config/locales/doc_auth/en.yml b/config/locales/doc_auth/en.yml index 831d908172f..a5d5dd2d1f0 100644 --- a/config/locales/doc_auth/en.yml +++ b/config/locales/doc_auth/en.yml @@ -231,6 +231,8 @@ en: too_many_faces: TOO MANY FACES ssn: We need your Social Security number to verify your name, date of birth and address. + stepping_up_html: 'Verify your identity again and take a photo of yourself to + access this service. %{link_html}' tag: Recommended upload_from_computer: Don’t have a phone? Upload photos of your ID from this computer. upload_from_phone: You won’t have to sign in again, and you’ll switch back to diff --git a/config/locales/doc_auth/es.yml b/config/locales/doc_auth/es.yml index 1902a1f4b41..13d64ea0478 100644 --- a/config/locales/doc_auth/es.yml +++ b/config/locales/doc_auth/es.yml @@ -269,6 +269,8 @@ es: too_many_faces: HAY DEMASIADAS CARAS ssn: Necesitamos su número de Seguro Social para validar su nombre, fecha de nacimiento y dirección. + stepping_up_html: 'Verifica tu identidad de nuevo y tómate una foto para acceder + a este servicio. %{link_html}' tag: Recomendado upload_from_computer: ¿No tiene teléfono? Suba fotos de su documento de identidad desde esta computadora. diff --git a/config/locales/doc_auth/fr.yml b/config/locales/doc_auth/fr.yml index 5928afcc3a0..68ac732127a 100644 --- a/config/locales/doc_auth/fr.yml +++ b/config/locales/doc_auth/fr.yml @@ -279,6 +279,8 @@ fr: too_many_faces: TROP DE VISAGES ssn: Nous avons besoin de votre numéro de sécurité sociale pour vérifier votre nom, date de naissance et adresse. + stepping_up_html: 'Vérifiez à nouveau votre identité et prenez une photo de vous + pour accéder à ce service. %{link_html}' tag: Recommandation upload_from_computer: Vous n’avez pas de téléphone ? Téléchargez les photos de votre carte d’identité depuis cet ordinateur. diff --git a/spec/features/idv/end_to_end_idv_spec.rb b/spec/features/idv/end_to_end_idv_spec.rb index 397021e9937..43a610fab01 100644 --- a/spec/features/idv/end_to_end_idv_spec.rb +++ b/spec/features/idv/end_to_end_idv_spec.rb @@ -150,6 +150,13 @@ def validate_welcome_page expect(page).to have_current_path(idv_welcome_path) expect(page).to have_content t('doc_auth.headings.welcome', sp_name: sp_name) + + stepping_up_info_message = t( + 'doc_auth.info.stepping_up_html', + sp_name: sp.name, + link_html: '', + ) + expect(page).not_to have_content(stepping_up_info_message) end def validate_agreement_page diff --git a/spec/features/idv/step_up_spec.rb b/spec/features/idv/step_up_spec.rb index 3085068aa52..62c79364c72 100644 --- a/spec/features/idv/step_up_spec.rb +++ b/spec/features/idv/step_up_spec.rb @@ -21,6 +21,14 @@ expect(page).to have_current_path(idv_welcome_path) + stepping_up_info_message = t( + 'doc_auth.info.stepping_up_html', + sp_name: sp.name, + link_html: '', + ) + + expect(page).to have_content(stepping_up_info_message) + complete_proofing_steps(with_selfie: true) end diff --git a/spec/presenters/idv/welcome_presenter_spec.rb b/spec/presenters/idv/welcome_presenter_spec.rb new file mode 100644 index 00000000000..2cb0fe29c76 --- /dev/null +++ b/spec/presenters/idv/welcome_presenter_spec.rb @@ -0,0 +1,136 @@ +require 'rails_helper' + +RSpec.describe Idv::WelcomePresenter do + subject(:presenter) { Idv::WelcomePresenter.new(decorated_sp_session) } + + let(:sp) { build(:service_provider) } + + let(:sp_session) { {} } + + let(:decorated_sp_session) do + ServiceProviderSession.new( + sp: sp, + view_context: nil, + sp_session: sp_session, + service_provider_request: nil, + ) + end + + it 'gives us the correct sp_name' do + expect(presenter.sp_name).to eq(sp.friendly_name) + end + + it 'gives us the correct title' do + expect(presenter.title).to eq(t('doc_auth.headings.welcome', sp_name: sp.friendly_name)) + end + + describe 'the explanation' do + let(:help_link) { '