-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use shared examples to test cancelation behavior (#2094)
Use shared examples to test cancelation behavior **Why**: So that we can test that cancelation is consistent across IdV steps. Note that this tests the behavior with the different protocols because the difference between cancellation behavior with and without an SP is surprisingly different. Also, this commit adds some empty contexts for steps that don't have a cancel button with the assumption that we want to add a cancel button to those steps.
- Loading branch information
Showing
7 changed files
with
166 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'rails_helper' | ||
|
||
feature 'cancel at IdV step', :idv_job do | ||
include IdvStepHelper | ||
|
||
context 'verify step' do | ||
it_behaves_like 'cancel at idv step', :verify | ||
it_behaves_like 'cancel at idv step', :verify, :oidc | ||
it_behaves_like 'cancel at idv step', :verify, :saml | ||
end | ||
|
||
context 'profile step' do | ||
it_behaves_like 'cancel at idv step', :profile | ||
it_behaves_like 'cancel at idv step', :profile, :oidc | ||
it_behaves_like 'cancel at idv step', :profile, :saml | ||
end | ||
|
||
context 'address step' do | ||
it_behaves_like 'cancel at idv step', :address | ||
it_behaves_like 'cancel at idv step', :address, :oidc | ||
it_behaves_like 'cancel at idv step', :address, :saml | ||
end | ||
|
||
xcontext 'phone step' do | ||
# Phone step doesn't have a cancel button :( | ||
end | ||
|
||
xcontext 'phone otp delivery method selection step' do | ||
# Phone OTP delivery method step doesn't have a cancel button :( | ||
end | ||
|
||
context 'phone otp verification step' do | ||
it_behaves_like 'cancel at idv step', :phone_otp_verification | ||
it_behaves_like 'cancel at idv step', :phone_otp_verification, :oidc | ||
it_behaves_like 'cancel at idv step', :phone_otp_verification, :saml | ||
end | ||
|
||
xcontext 'usps step' do | ||
# USPS step does not have a cancel button :( | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
include IdvStepHelper | ||
|
||
before do | ||
start_idv_from_sp | ||
complete_idv_steps_before_phone_step | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module JavascriptDriverHelper | ||
def javascript_enabled? | ||
Capybara.current_driver == Capybara.javascript_driver | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
shared_examples 'cancel at idv step' do |step, sp| | ||
include SamlAuthHelper | ||
|
||
before do | ||
start_idv_from_sp(sp) | ||
complete_idv_steps_before_step(step) | ||
end | ||
|
||
context 'without js' do | ||
it 'sends the user to the account page', if: sp.present? do | ||
click_idv_cancel | ||
expect(current_url).to eq(account_url) | ||
end | ||
|
||
it 'shows the user a failure message with the option to go back to idv', if: sp.nil? do | ||
click_link t('links.cancel') | ||
|
||
expect(page).to have_content(t('idv.titles.cancel')) | ||
expect(page).to have_content(t('idv.messages.cancel', app: 'login.gov')) | ||
expect(current_path).to eq(verify_cancel_path) | ||
|
||
click_link t('forms.buttons.back') | ||
|
||
expect(current_url).to eq(verify_url) | ||
end | ||
end | ||
|
||
context 'with js', :js do | ||
it 'displays a modal with options to continue or return to account page', if: sp.present? do | ||
# Clicking cancel displays the modal | ||
click_on t('links.cancel_idv') | ||
expect(page).to have_content(t('idv.cancel.modal_header')) | ||
|
||
# Clicking continue should hide the modal | ||
click_on t('idv.buttons.continue') | ||
expect(page).to_not have_content(t('idv.cancel.modal_header')) | ||
|
||
# Clicking cancel again reveals the modal | ||
click_on t('links.cancel_idv') | ||
expect(page).to have_content(t('idv.cancel.modal_header')) | ||
|
||
# Clicking return to account takes us to the account page | ||
page.find_button(t('idv.buttons.cancel')).trigger('click') | ||
expect(page).to have_content(t('headings.account.login_info')) | ||
expect(current_path).to eq(account_path) | ||
end | ||
|
||
it 'shows the user a failure message with the option to go back to idv', if: sp.nil? do | ||
click_link t('links.cancel') | ||
|
||
expect(page).to have_content(t('idv.titles.cancel')) | ||
expect(page).to have_content(t('idv.messages.cancel', app: 'login.gov')) | ||
expect(current_path).to eq(verify_cancel_path) | ||
|
||
click_link t('forms.buttons.back') | ||
|
||
expect(current_path).to eq(verify_path) | ||
end | ||
end | ||
end |