Browse Source

Move schemes helper methods to a separate file

pull/767/head
Kat 3 years ago
parent
commit
94f2d8c877
  1. 59
      spec/features/form/helpers.rb
  2. 84
      spec/features/schemes_helpers.rb
  3. 4
      spec/features/schemes_spec.rb

59
spec/features/form/helpers.rb

@ -22,63 +22,4 @@ module Helpers
fill_in("user[password]", with: user.password) fill_in("user[password]", with: user.password)
click_button("Sign in") click_button("Sign in")
end end
def fill_in_and_save_scheme_details
fill_in "Scheme name", with: "FooBar"
check "This scheme contains confidential information"
choose "Direct access hostel"
choose "Yes – registered care home providing nursing care"
select organisation.name, from: "scheme-owning-organisation-id-field"
choose "The same organisation that owns the housing stock"
click_button "Save and continue"
end
def fill_in_and_save_primary_client_group
choose "Homeless families with support needs"
click_button "Save and continue"
end
def fill_in_and_save_secondary_client_group_confirmation
choose "Yes"
click_button "Save and continue"
end
def fill_in_and_save_secondary_client_group
choose "Homeless families with support needs"
click_button "Save and continue"
end
def fill_in_and_save_support
choose "Low level"
choose "Very short stay"
click_button "Save and continue"
end
def fill_in_and_save_location
fill_in "Postcode", with: "SW1P 4DF"
fill_in "Location name (optional)", with: "Some name"
fill_in "Total number of units at this location", with: 1
choose "Self-contained house"
choose "location-add-another-location-no-field"
choose "location-mobility-type-none-field"
click_button "Save and continue"
end
def fill_in_and_save_second_location
fill_in "Postcode", with: "XX1 1XX"
fill_in "Location name (optional)", with: "Other name"
fill_in "Total number of units at this location", with: 2
choose "Self-contained house"
choose "location-add-another-location-no-field"
choose "location-mobility-type-none-field"
click_button "Save and continue"
end
def create_and_save_a_scheme
fill_in_and_save_scheme_details
fill_in_and_save_primary_client_group
fill_in_and_save_secondary_client_group_confirmation
fill_in_and_save_secondary_client_group
fill_in_and_save_support
end
end end

84
spec/features/schemes_helpers.rb

@ -0,0 +1,84 @@
module SchemesHelpers
def fill_in_number_question(case_log_id, question, value, path)
visit("/logs/#{case_log_id}/#{path}")
fill_in("case-log-#{question.to_s.dasherize}-field", with: value)
click_button("Save and continue")
end
def answer_all_questions_in_income_subsection(case_log)
visit("/logs/#{case_log.id}/net-income")
fill_in("case-log-earnings-field", with: 18_000)
choose("case-log-incfreq-2-field")
click_button("Save and continue")
choose("case-log-benefits-0-field")
click_button("Save and continue")
choose("case-log-hb-1-field")
click_button("Save and continue")
end
def sign_in(user)
visit("/logs")
fill_in("user[email]", with: user.email)
fill_in("user[password]", with: user.password)
click_button("Sign in")
end
def fill_in_and_save_scheme_details
fill_in "Scheme name", with: "FooBar"
check "This scheme contains confidential information"
choose "Direct access hostel"
choose "Yes – registered care home providing nursing care"
select organisation.name, from: "scheme-owning-organisation-id-field"
choose "The same organisation that owns the housing stock"
click_button "Save and continue"
end
def fill_in_and_save_primary_client_group
choose "Homeless families with support needs"
click_button "Save and continue"
end
def fill_in_and_save_secondary_client_group_confirmation
choose "Yes"
click_button "Save and continue"
end
def fill_in_and_save_secondary_client_group
choose "Homeless families with support needs"
click_button "Save and continue"
end
def fill_in_and_save_support
choose "Low level"
choose "Very short stay"
click_button "Save and continue"
end
def fill_in_and_save_location
fill_in "Postcode", with: "SW1P 4DF"
fill_in "Location name (optional)", with: "Some name"
fill_in "Total number of units at this location", with: 1
choose "Self-contained house"
choose "location-add-another-location-no-field"
choose "location-mobility-type-none-field"
click_button "Save and continue"
end
def fill_in_and_save_second_location
fill_in "Postcode", with: "XX1 1XX"
fill_in "Location name (optional)", with: "Other name"
fill_in "Total number of units at this location", with: 2
choose "Self-contained house"
choose "location-add-another-location-no-field"
choose "location-mobility-type-none-field"
click_button "Save and continue"
end
def create_and_save_a_scheme
fill_in_and_save_scheme_details
fill_in_and_save_primary_client_group
fill_in_and_save_secondary_client_group_confirmation
fill_in_and_save_secondary_client_group
fill_in_and_save_support
end
end

4
spec/features/schemes_spec.rb

@ -1,8 +1,8 @@
require "rails_helper" require "rails_helper"
require_relative "form/helpers" require_relative "schemes_helpers"
RSpec.describe "Schemes scheme Features" do RSpec.describe "Schemes scheme Features" do
include Helpers include SchemesHelpers
context "when viewing list of schemes" do context "when viewing list of schemes" do
context "when I am signed as a coordinator user and there are schemes in the database" do context "when I am signed as a coordinator user and there are schemes in the database" do
let!(:user) { FactoryBot.create(:user, :data_coordinator, last_sign_in_at: Time.zone.now) } let!(:user) { FactoryBot.create(:user, :data_coordinator, last_sign_in_at: Time.zone.now) }

Loading…
Cancel
Save