Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GYR1-678] Clients who log in to GYR get stuck in a loop answering demographic questions #5593

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions app/controllers/documents/ids_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Documents
class IdsController < DocumentUploadQuestionController
include GyrDocuments

before_action :set_required_person_names, only: [:edit, :update]

def self.displayed_document_types
Expand Down Expand Up @@ -33,9 +35,7 @@ def form_params
end

def after_update_success
current_intake.tax_returns.each do |tax_return|
tax_return.advance_to(:intake_needs_doc_help)
end
advance_to(current_intake, :intake_needs_doc_help)
end

def illustration_path
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/documents/selfies_controller.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module Documents
class SelfiesController < DocumentUploadQuestionController
include GyrDocuments

before_action :set_required_person_names, only: [:edit, :update]

def self.document_type
DocumentTypes::Selfie
end

def after_update_success
current_intake.tax_returns.each do |tax_return|
tax_return.advance_to(:intake_needs_doc_help)
end
advance_to(current_intake, :intake_needs_doc_help)
end

def illustration_path
Expand Down
19 changes: 4 additions & 15 deletions app/controllers/documents/ssn_itins_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Documents
class SsnItinsController < DocumentUploadQuestionController
include GyrDocuments

before_action :set_required_person_names, only: [:edit, :update]

def self.displayed_document_types
Expand All @@ -25,10 +27,8 @@ def selectable_document_types
end

def after_update_success
transition_to = has_all_required_docs? ? :intake_ready : :intake_needs_doc_help
current_intake.tax_returns.each do |tax_return|
tax_return.transition_to(transition_to) if tax_return.current_state.to_sym != transition_to
end
transition_to = has_all_required_docs?(current_intake) ? :intake_ready : :intake_needs_doc_help
advance_to(current_intake, transition_to)
end

def form_params
Expand All @@ -42,16 +42,5 @@ def form_params
def illustration_path
'ssn-itins.svg'
end

private

def has_all_required_docs?
intake_doc_types = current_intake.documents.pluck(:document_type)
required_docs = []
required_docs << DocumentTypes::Selfie.key unless IdVerificationExperimentService.new(current_intake).skip_selfies?
DocumentTypes::IDENTITY_TYPES.map(&:key).intersect?(intake_doc_types) &&
DocumentTypes::SECONDARY_IDENTITY_TYPES.map(&:key).intersect?(intake_doc_types) &&
required_docs.all? {|key| intake_doc_types.include?(key) }
end
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
module Questions
class SuccessfullySubmittedController < PostCompletionQuestionsController
include AuthenticatedClientConcern
include AuthenticatedClientConcern, GyrDocuments

before_action do
next_state = has_all_required_docs?(current_intake) ? :intake_ready : :intake_needs_doc_help
advance_to(current_intake, next_state)
end

def include_analytics?
true
Expand Down
16 changes: 16 additions & 0 deletions app/lib/gyr_documents.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module GyrDocuments
def has_all_required_docs?(intake)
intake_doc_types = intake.documents.pluck(:document_type)
required_docs = []
required_docs << DocumentTypes::Selfie.key unless IdVerificationExperimentService.new(intake).skip_selfies?
DocumentTypes::IDENTITY_TYPES.map(&:key).intersect?(intake_doc_types) &&
DocumentTypes::SECONDARY_IDENTITY_TYPES.map(&:key).intersect?(intake_doc_types) &&
required_docs.all? {|key| intake_doc_types.include?(key) }
end

def advance_to(intake, next_state)
intake.tax_returns.each do |tax_return|
tax_return.transition_to(next_state) if tax_return.current_state.to_sym != next_state
end
end
end
2 changes: 1 addition & 1 deletion app/lib/navigation/document_navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DocumentNavigation
Documents::Form1095asController,
Documents::EmploymentController,
Documents::Form1099rsController,
Documents::AdditionalDocumentsController, # Advances statuses to Ready
Documents::AdditionalDocumentsController,
Documents::OverviewController,
].freeze

Expand Down
72 changes: 72 additions & 0 deletions spec/features/web_intake/new_single_filer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ def intake_after_triage_up_to_documents(intake)
click_on "Submit"
}.to change(OutgoingTextMessage, :count).by(1).and change(OutgoingEmail, :count).by(1)

# ID, secondary ID, and selfie were all uploaded.
expect(intake.tax_returns.all? { |tr| tr.current_state == :intake_ready })

expect(intake.reload.current_step).to end_with("/questions/successfully-submitted")
expect(page).to have_selector("h1", text: "Success! Your tax information has been submitted.")
expect(page).to have_text("Client ID number: #{intake.client_id}")
Expand Down Expand Up @@ -457,6 +460,75 @@ def intake_after_triage_up_to_documents(intake)
expect(intake.reload.current_step).to end_with("/questions/demographic-primary-race")
expect(page).to have_selector("h1", text: I18n.t("portal.client_logins.new.title"))
end

scenario "new client filing single without dependents AND without uploading *required* docs" do
intake = intake_up_to_documents

# IRS guidance
expect(page).to have_selector("h1", text: "First, we need to confirm your basic information.")
click_on "Continue"

# Upload ID
expect(page).to have_selector("h1", text: "Attach a photo of your ID card")
click_on "I don't have this right now."

expect(page).to have_text('We know documents can be hard to collect.')
click_on 'Send a reminder link for this document.'

# Selfie instructions
expect(intake.reload.current_step).to end_with("/documents/selfie-instructions")
expect(page).to have_selector("h1", text: "Confirm your identity with a photo of yourself")
click_on I18n.t('views.documents.selfie_instructions.submit_photo')

# Upload selfie
expect(intake.reload.current_step).to end_with("/documents/selfies")
expect(page).to have_selector("h1", text: I18n.t('views.documents.selfies.title'))
click_on "I don't have this right now."

expect(page).to have_text('We know documents can be hard to collect.')
click_on 'Send a reminder link for this document.'

# Upload secondary ID doc
expect(intake.reload.current_step).to end_with("/documents/ssn-itins")
expect(page).to have_selector("h1", text: I18n.t('views.documents.ssn_itins.title'))
click_on "I don't have this right now."

expect(page).to have_text('We know documents can be hard to collect.')
click_on 'Send a reminder link for this document.'

# Documents: Intro
expect(page).to have_selector("h1", text: I18n.t('views.documents.intro.title'))
click_on "Continue"

# Employment docs -- not 'required', let's go ahead and upload 1 here.
expect(page).to have_selector("h1", text: "Share your employment documents")
upload_file("document_type_upload_form_upload", Rails.root.join("spec", "fixtures", "files", "test-pattern.png"))

expect(page).to have_content("test-pattern.png")
expect(page).to have_link("Remove")
click_on "Continue"

expect(page).to have_selector("h1", text: "Please share any additional documents.")
click_on "Continue"

expect(intake.reload.current_step).to end_with("/documents/overview")
expect(page).to have_selector("h1", text: "Great work! Here's a list of what we've collected.")
click_on "I've shared all my documents"

# Final Information
expect(intake.reload.current_step).to end_with("/questions/final-info")
fill_in "Anything else you'd like your tax preparer to know about your situation?", with: "One of my kids moved away for college, should I include them as a dependent?"
expect {
click_on "Submit"
}.to change(OutgoingTextMessage, :count).by(1).and change(OutgoingEmail, :count).by(1)

# Did not upload ID, secondary ID, and selfie.
expect(intake.tax_returns.all? { |tr| tr.current_state == :intake_needs_doc_help })

expect(intake.reload.current_step).to end_with("/questions/successfully-submitted")
expect(page).to have_selector("h1", text: "Success! Your tax information has been submitted.")
expect(page).to have_text("Client ID number: #{intake.client_id}")
end
end

context "client is included in the returning client experiment" do
Expand Down
Loading