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

FYST-1200 Update navigation for editing income forms from final review page #5026

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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def update

if @state_file1099_r.valid?(:retirement_income_intake)
@state_file1099_r.save(context: :retirement_income_intake)
redirect_to questions_income_review_path
redirect_to questions_income_review_path(return_to_review: params[:return_to_review])
else
render :edit
end
Expand Down
31 changes: 25 additions & 6 deletions app/controllers/state_file/questions/unemployment_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module StateFile
module Questions
class UnemploymentController < QuestionsController
include OtherOptionsLinksConcern
include ReturnToReviewConcern
before_action :load_links, only: [:new, :edit]

def self.show?(intake)
Expand All @@ -17,7 +16,7 @@ def self.navigation_actions
def index
@state_file1099_gs = current_intake.state_file1099_gs
unless @state_file1099_gs.present?
redirect_to action: :new
redirect_with_review_param(:new)
end
end

Expand All @@ -35,12 +34,12 @@ def update

if @state_file1099_g.had_box_11_no?
@state_file1099_g.destroy
return redirect_to action: :index, return_to_review: params[:return_to_review]
return redirect_with_review_param(:index)
end

if @state_file1099_g.valid?
@state_file1099_g.save
redirect_to action: :index, return_to_review: params[:return_to_review]
redirect_with_review_param(:index)
else
render :edit
end
Expand All @@ -54,7 +53,7 @@ def create

if @state_file1099_g.valid?
@state_file1099_g.save
redirect_to action: :index, return_to_review: params[:return_to_review]
redirect_with_review_param(:index)
else
render :new
end
Expand All @@ -65,11 +64,31 @@ def destroy
if @state_file1099_g.destroy
flash[:notice] = I18n.t("state_file.questions.unemployment.destroy.removed", name: @state_file1099_g.recipient_name)
end
redirect_to action: :index, return_to_review: params[:return_to_review]
redirect_with_review_param(:index)
end

private

def next_path
if params[:return_to_review].present?
StateFile::Questions::IncomeReviewController.to_path_helper(return_to_review: params[:return_to_review])
else
super
end
end

def prev_path
if params[:return_to_review].present?
StateFile::Questions::IncomeReviewController.to_path_helper(return_to_review: params[:return_to_review])
else
super
end
end

def redirect_with_review_param(action)
redirect_to action: action, return_to_review: params[:return_to_review]
end

def state_file1099_params
state_file_params = params.require(:state_file1099_g).permit(
:had_box_11,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/state_file/questions/w2_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def update

if @w2.valid?
@w2.save
redirect_to StateFile::Questions::IncomeReviewController.to_path_helper
redirect_to StateFile::Questions::IncomeReviewController.to_path_helper(return_to_review: params[:return_to_review])
jenny-heath marked this conversation as resolved.
Show resolved Hide resolved
else
render :edit
end
Expand Down
24 changes: 18 additions & 6 deletions app/views/state_file/questions/income_review/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
<p><%= t(".help_text") %></p>

<% if current_intake.state_file1099_rs.present? %>
<div class="white-group retirement-income">
<div class="white-group retirement-income" id="form1099rs">
<p class="text--bold spacing-below-0"><%= t(".retirement_income_title") %></p>
<% current_intake.state_file1099_rs.each do |state_1099r| %>
<div class="spacing-above-25">
<p class="text--bold spacing-below-5"><%= state_1099r.recipient_name %></p>
<p class="spacing-below-5"><%= state_1099r.payer_name %></p>
<%= link_to t(".review_and_edit_state_info"),
StateFile::Questions::RetirementIncomeController.to_path_helper(action: :edit, id: state_1099r.id),
StateFile::Questions::RetirementIncomeController.to_path_helper(
action: :edit,
id: state_1099r.id,
return_to_review: params[:return_to_review]
),
class: "button--small"
%>
</div>
Expand All @@ -21,14 +25,18 @@
<% end %>

<% if @w2s.present? %>
<div class="white-group">
<div class="white-group" id="w2s">
<p class="text--bold spacing-below-0"><%= t(".w2s_title") %></p>
<% @w2s.each do |w2| %>
<div class="spacing-above-25">
<p class="text--bold spacing-below-5"><%= w2.employee_name %></p>
<p class="spacing-below-5"><%= w2.employer_name %></p>
<%= link_to t(".review_and_edit_state_info"),
StateFile::Questions::W2Controller.to_path_helper(action: :edit, id: w2.id),
StateFile::Questions::W2Controller.to_path_helper(
action: :edit,
id: w2.id,
return_to_review: params[:return_to_review]
),
class: "button--small"
%>
</div>
Expand All @@ -46,7 +54,7 @@
<% end %>

<% if current_intake.direct_file_data.fed_unemployment > 0 %>
<div class="white-group unemployment">
<div class="white-group unemployment" id="form1099gs">
<p class="text--bold spacing-below-0"><%= t(".unemployment_title") %></p>
<% if current_intake.state_file1099_gs.count > 0 %>
<% current_intake.state_file1099_gs.each do |state_1099g| %>
Expand All @@ -55,7 +63,11 @@
<p class="text--bold spacing-below-5"><%= recipient.full_name %></p>
<p class="spacing-below-5"><%= state_1099g.payer_name %></p>
<%= link_to t(".review_and_edit_state_info"),
StateFile::Questions::UnemploymentController.to_path_helper(action: :edit, id: state_1099g.id),
StateFile::Questions::UnemploymentController.to_path_helper(
action: :edit,
id: state_1099g.id,
return_to_review: params[:return_to_review]
),
class: "button--small"
%>
</div>
Expand Down
39 changes: 2 additions & 37 deletions spec/features/state_file/complete_intake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,34 +433,7 @@
expect(page).to have_text I18n.t("state_file.landing_page.edit.id.title")
click_on I18n.t('general.get_started'), id: "firstCta"

expect(page).to have_text I18n.t("state_file.questions.id_eligibility_residence.edit.emergency_rental_assistance", filing_year: filing_year)
expect(page).to have_text I18n.t("state_file.questions.id_eligibility_residence.edit.withdrew_msa_fthb", filing_year: filing_year)

find_by_id('state_file_id_eligibility_residence_form_eligibility_withdrew_msa_fthb_no').click
find_by_id('state_file_id_eligibility_residence_form_eligibility_emergency_rental_assistance_no').click

click_on I18n.t("general.continue")

expect(page).to have_text I18n.t("state_file.questions.eligible.id_supported.child_care_deduction")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_supported.interest_from_obligations")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_supported.social_security_retirement_deduction")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_supported.id_child_tax_credit")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_supported.id_grocery_credit")

click_on I18n.t("state_file.questions.eligible.edit.not_supported")

expect(page).to have_text I18n.t("state_file.questions.eligible.id_unsupported.id_college_savings_program")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_unsupported.id_youth_rehab_contributions")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_unsupported.maintaining_elderly_disabled_credit")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_unsupported.long_term_care_insurance_subtraction")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_unsupported.earned_on_reservation")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_unsupported.education_contribution_credit")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_unsupported.itemized_deductions")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_unsupported.dependents_not_claimed_fed_return")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_unsupported.voluntary_donations")
expect(page).to have_text I18n.t("state_file.questions.eligible.id_unsupported.change_in_filing_status")

click_on I18n.t("general.continue")
step_through_eligibility_screener(us_state: "id")

step_through_initial_authentication(contact_preference: :email)

Expand Down Expand Up @@ -561,15 +534,7 @@
# select optoins that allow us to proceed
click_on "Continue"

# click continue on eligibility & check the messaging is correct here?
# select mfj
choose I18n.t("general.affirmative")
choose I18n.t("general.negative"), id: "state_file_md_eligibility_filing_status_form_eligibility_homebuyer_withdrawal_mfj_no"
choose I18n.t("general.negative"), id: "state_file_md_eligibility_filing_status_form_eligibility_home_different_areas_no"

click_on "Continue"

click_on "Continue"
step_through_eligibility_screener(us_state: "md")

step_through_initial_authentication(contact_preference: :email)

Expand Down
151 changes: 151 additions & 0 deletions spec/features/state_file/review_page_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
require "rails_helper"

RSpec.feature "Completing a state file intake", active_job: true do
include MockTwilio
include StateFileIntakeHelper

before do
allow_any_instance_of(Routes::StateFileDomain).to receive(:matches?).and_return(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

i see this in our feature specs but am unsure what this is supposed to accomplish, although the tests do break when this is removed - would love to understand what this is doing.

Copy link
Contributor

Choose a reason for hiding this comment

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

this tells the spec when we want to go to / location it's supposed to go to the statefile domain (not gyr which is default?)

end

StateFile::StateInformationService.active_state_codes.each do |state_code|
context "#{state_code.upcase}" do
it "allows user to navigate to income review page, edit an income form, and then navigate back to final review page", required_schema: state_code do
set_up_intake_and_associated_records(state_code)

intake = StateFile::StateInformationService.intake_class(state_code).last

visit "/questions/#{state_code}-review"

# Final review page
expect(page).to have_text I18n.t("state_file.questions.shared.review_header.title")
within "#income-info" do
click_on I18n.t("general.edit")
end

# Income review page
expect(page).to have_text I18n.t("state_file.questions.income_review.edit.title")
within "#w2s" do
click_on I18n.t("state_file.questions.income_review.edit.review_and_edit_state_info")
end

# W2 edit page
expect(page).to have_text strip_html_tags(I18n.t("state_file.questions.w2.edit.instructions_1_html", employer: intake.state_file_w2s.first.employer_name))
fill_in strip_html_tags(I18n.t("state_file.questions.w2.edit.box15_html")), with: "987654321"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we confirm this value was successfully updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we could but i don't think of this test as being the place to cover that. if they w2 page doesn't work that should be caught in the form spec. i could actually just delete this line because the point of this test is to see that clicking continue takes you to the right place?

click_on I18n.t("general.continue")

# Back on income review page
expect(page).to have_text I18n.t("state_file.questions.income_review.edit.title")
click_on I18n.t("general.continue")

# Final review page
expect(page).to have_text I18n.t("state_file.questions.shared.review_header.title")
within "#income-info" do
click_on I18n.t("general.edit")
end

# Income review page
expect(page).to have_text I18n.t("state_file.questions.income_review.edit.title")
within "#form1099rs" do
click_on I18n.t("state_file.questions.income_review.edit.review_and_edit_state_info")
end

# 1099R edit page
expect(page).to have_text strip_html_tags(I18n.t("state_file.questions.retirement_income.edit.title", payer_name: intake.state_file1099_rs.first.payer_name))
fill_in strip_html_tags(I18n.t("state_file.questions.retirement_income.edit.box15_html")), with: "123456789"
click_on I18n.t("general.continue")

# Back on income review page
expect(page).to have_text I18n.t("state_file.questions.income_review.edit.title")
click_on I18n.t("general.continue")

# Final review page
expect(page).to have_text I18n.t("state_file.questions.shared.review_header.title")
within "#income-info" do
click_on I18n.t("general.edit")
end

# Income review page
expect(page).to have_text I18n.t("state_file.questions.income_review.edit.title")
within "#form1099rs" do
click_on I18n.t("state_file.questions.income_review.edit.review_and_edit_state_info")
end

# 1099R edit page
expect(page).to have_text strip_html_tags(I18n.t("state_file.questions.retirement_income.edit.title", payer_name: intake.state_file1099_rs.first.payer_name))
fill_in strip_html_tags(I18n.t("state_file.questions.retirement_income.edit.box15_html")), with: "123456789"
click_on I18n.t("general.continue")

# Back on income review page
expect(page).to have_text I18n.t("state_file.questions.income_review.edit.title")
click_on I18n.t("general.continue")

# Final review page
expect(page).to have_text I18n.t("state_file.questions.shared.review_header.title")
within "#income-info" do
click_on I18n.t("general.edit")
end

# Income review page
expect(page).to have_text I18n.t("state_file.questions.income_review.edit.title")
within "#form1099gs" do
click_on I18n.t("state_file.questions.income_review.edit.review_and_edit_state_info")
end

# 1099G edit page
expect(page).to have_text strip_html_tags(I18n.t("state_file.questions.unemployment.edit.title", count: intake.filer_count, year: MultiTenantService.statefile.current_tax_year))
fill_in strip_html_tags(I18n.t("state_file.questions.unemployment.edit.payer_name")), with: "beepboop"
click_on I18n.t("general.continue")

# takes them to the 1099G index page first
expect(page).to have_text strip_html_tags(I18n.t("state_file.questions.unemployment.index.lets_review"))

# edit a 1099G (there's only one)
click_on I18n.t("general.edit")
click_on I18n.t("general.continue")

# back on index page
expect(page).to have_text strip_html_tags(I18n.t("state_file.questions.unemployment.index.lets_review"))

# delete a 1099G (there's only one)
recipient_name = intake.state_file1099_gs.last.recipient_name
click_on I18n.t("general.delete")
# redirects to new because there are no 1099Gs left, need to select "no" in order to continue
expect(page).to have_text I18n.t("state_file.questions.unemployment.destroy.removed", name: recipient_name)
choose I18n.t("general.negative")
click_on I18n.t("general.continue")

# Back on income review page
expect(page).to have_text I18n.t("state_file.questions.income_review.edit.title")
click_on I18n.t("general.continue")

# Final review page
expect(page).to have_text I18n.t("state_file.questions.shared.review_header.title")
end
end
end

def set_up_intake_and_associated_records(state_code)
visit "/"
click_on "Start Test #{state_code.upcase}"

expect(page).to have_text I18n.t("state_file.landing_page.edit.#{state_code}.title")
click_on I18n.t('general.get_started'), id: "firstCta"
step_through_eligibility_screener(us_state: state_code)
step_through_initial_authentication(contact_preference: :email)
expect(page).to have_text I18n.t('state_file.questions.terms_and_conditions.edit.title')

intake = StateFile::StateInformationService.intake_class(state_code).last
intake.update(
raw_direct_file_data: StateFile::DirectFileApiResponseSampleService.new.read_xml("az_df_complete_sample"),
primary_first_name: "Deedee",
primary_last_name: "Doodoo",
primary_birth_date: Date.new((MultiTenantService.statefile.current_tax_year - 65), 12, 1),
)
intake.direct_file_data.fed_unemployment = 1000
intake.update(raw_direct_file_data: intake.direct_file_data)
create(:state_file_w2, state_file_intake: intake)
create(:state_file1099_r, intake: intake)
create(:state_file1099_g, intake: intake)
end
end
Loading