From 19e529c8b760946dcd55ee553a0c5464232389a2 Mon Sep 17 00:00:00 2001 From: firelemons Date: Mon, 13 Nov 2023 03:47:45 -0600 Subject: [PATCH] try create test for miles driven warning --- spec/system/case_contacts/new_spec.rb | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/spec/system/case_contacts/new_spec.rb b/spec/system/case_contacts/new_spec.rb index fcf1dee10b..cb36af0bce 100644 --- a/spec/system/case_contacts/new_spec.rb +++ b/spec/system/case_contacts/new_spec.rb @@ -479,10 +479,33 @@ def index_of(text) click_on "Submit" expect(page).to have_current_path(new_case_contact_path) # Submit Blocked - expect(page).to have_text("Date for occurred on is past maximum allowed date of") # Warning Shown + expect(page).to have_text("Date for occurred on is past maximum allowed date of") # Error Shown end - it "will ask the user for a confirmation when miles driven is greater than zero and will show the user a warning", js: true do + it "will require the user for a confirmation when miles driven is greater than zero and will show the user a warning", js: true do + volunteer = create(:volunteer, :with_casa_cases) + volunteer_casa_case_one = volunteer.casa_cases.first + create_contact_types(volunteer_casa_case_one.casa_org) + + sign_in volunteer + visit new_case_contact_path + + fill_out_minimum_required_fields_for_case_contact_form + + choose "Voice Only" + fill_in "a. Miles Driven", with: "5" + + expect(page).to have_text("You requested driving reimbursement for a contact medium that typically does not involve driving. Are you sure that's right?") # Warning Shown + expect(page).to have_text("I'm sure I drove for this contact medium.") # Confirmation Shown + + click_on "Submit" + + expect(page).to have_current_path(new_case_contact_path) # Submit blocked from confirmation checkbox + + check "I'm sure I drove for this contact medium." + click_on "Submit" + + expect(page).not_to have_current_path(new_case_contact_path) # Submit lets user pass end end