Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions app/controllers/idv/welcome_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
82 changes: 82 additions & 0 deletions app/presenters/idv/welcome_presenter.rb
Original file line number Diff line number Diff line change
@@ -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
44 changes: 15 additions & 29 deletions app/views/idv/welcome/show.html.erb
Original file line number Diff line number Diff line change
@@ -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) %>
<p>
<%= 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',
Expand All @@ -25,31 +23,19 @@
<h2><%= t('doc_auth.instructions.getting_started') %></h2>

<%= 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 %>
<p><%= t('doc_auth.instructions.text1_with_selfie') %></p>
<% @presenter.bullet_points.each do |point| %>
<%= c.with_item(heading: point.bullet) do %>
<p><%= point.text %></p>
<% end %>
<% else %>
<%= c.with_item(heading: t('doc_auth.instructions.bullet1')) do %>
<p><%= t('doc_auth.instructions.text1') %></p>
<% end %>
<% end %>
<%= c.with_item(heading: t('doc_auth.instructions.bullet2')) do %>
<p><%= t('doc_auth.instructions.text2') %></p>
<% end %>
<%= c.with_item(heading: t('doc_auth.instructions.bullet3')) do %>
<p><%= t('doc_auth.instructions.text3') %></p>
<% end %>
<%= c.with_item(heading: t('doc_auth.instructions.bullet4', app_name: APP_NAME)) do %>
<p><%= t('doc_auth.instructions.text4') %></p>
<% 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| %>

<div class="margin-top-4">
<%= render(
Expand Down
2 changes: 2 additions & 0 deletions config/locales/doc_auth/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions config/locales/doc_auth/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions config/locales/doc_auth/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions spec/features/idv/end_to_end_idv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions spec/features/idv/step_up_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
136 changes: 136 additions & 0 deletions spec/presenters/idv/welcome_presenter_spec.rb
Original file line number Diff line number Diff line change
@@ -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) { '<a href="https://www.example.com>Learn more about verifying your identity</a>' }

context 'when a selfie is not required' do
it 'uses the getting started message' do
expect(presenter.explanation_text(help_link)).to eq(
t(
'doc_auth.info.getting_started_html',
sp_name: sp.friendly_name,
link_html: help_link,
),
)
end
end

context 'when a selfie is required' do
let(:sp_session) do
{ biometric_comparison_required: true }
end

before do
allow(IdentityConfig.store).to receive(:doc_auth_selfie_capture_enabled).and_return(true)
end

it 'uses the stepping up message' do
expect(presenter.explanation_text(help_link)).to eq(
t(
'doc_auth.info.stepping_up_html',
sp_name: sp.friendly_name,
link_html: help_link,
),
)
end
end
end

describe 'the bullet points' do
context 'when a selfie is not required' do
it 'uses the no selfie bullet point 1 header' do
expect(presenter.bullet_points[0].bullet).to eq(
t('doc_auth.instructions.bullet1'),
)
end

it 'uses the no selfie bullet point 1 text' do
expect(presenter.bullet_points[0].text).to eq(
t('doc_auth.instructions.text1'),
)
end
end

context 'when a selfie is required' do
let(:sp_session) do
{ biometric_comparison_required: true }
end

before do
allow(IdentityConfig.store).to receive(:doc_auth_selfie_capture_enabled).and_return(true)
end

it 'uses the selfie bullet point 1 header' do
expect(presenter.bullet_points[0].bullet).to eq(
t('doc_auth.instructions.bullet1_with_selfie'),
)
end

it 'uses the selfie bullet point 1 text' do
expect(presenter.bullet_points[0].text).to eq(
t('doc_auth.instructions.text1_with_selfie'),
)
end
end

it 'shows the bullet point 2 header' do
expect(presenter.bullet_points[1].bullet).to eq(
t('doc_auth.instructions.bullet2'),
)
end

it 'shows the bullet point 2 text' do
expect(presenter.bullet_points[1].text).to eq(
t('doc_auth.instructions.text2'),
)
end

it 'shows the bullet point 3 header' do
expect(presenter.bullet_points[2].bullet).to eq(
t('doc_auth.instructions.bullet3'),
)
end

it 'shows the bullet point 3 text' do
expect(presenter.bullet_points[2].text).to eq(
t('doc_auth.instructions.text3'),
)
end

it 'shows the bullet point 4 header' do
expect(presenter.bullet_points[3].bullet).to eq(
t('doc_auth.instructions.bullet4', app_name: sp.friendly_name),
)
end

it 'shows the bullet point 4 text' do
expect(presenter.bullet_points[3].text).to eq(
t('doc_auth.instructions.text4'),
)
end
end
end
Loading