Browse Source

shuffle schemes feature tests (#767)

* shuffle schemes feature tests

* Move schemes helper methods to a separate file

* Update and remove repeated tests from schemes feature tests

* lint
pull/772/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
2ed736bd1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 84
      spec/features/schemes_helpers.rb
  2. 861
      spec/features/schemes_spec.rb

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(answers = {})
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 answers["housing_stock_owners"].presence || "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

861
spec/features/schemes_spec.rb

@ -1,6 +1,8 @@
require "rails_helper" require "rails_helper"
require_relative "schemes_helpers"
RSpec.describe "Schemes scheme Features" do RSpec.describe "Schemes scheme Features" do
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) }
@ -88,70 +90,54 @@ RSpec.describe "Schemes scheme Features" do
click_button("Submit") click_button("Submit")
end end
it "allows navigating to the schemes from the home page" do
expect(page).to have_link("Schemes", href: "/schemes")
end
context "when viewing list of schemes" do context "when viewing list of schemes" do
it "displays the link to the schemes" do before do
expect(page).to have_link("Schemes", href: "/schemes") click_link "Schemes", href: "/schemes"
end end
context "when I click schemes" do it "shows a list of schemes" do
before do schemes.each do |scheme|
click_link "Schemes", href: "/schemes" expect(page).to have_content(scheme.id)
end expect(page).to have_link(scheme.service_name)
expect(page).to have_content(scheme.primary_client_group)
it "shows list of schemes" do
schemes.each do |scheme|
expect(page).to have_content(scheme.id)
end
end end
end
context "when I search for a specific scheme" do it "displays a search bar" do
it "there is a search bar with a message and search button for schemes" do expect(page).to have_field("search")
expect(page).to have_field("search") expect(page).to have_content("Search by scheme name, code or postcode")
expect(page).to have_content("Search by scheme name, code or postcode") expect(page).to have_button("Search")
expect(page).to have_button("Search") end
end
context "when I fill in search information and press the search button" do
before do
fill_in("search", with: scheme_to_search.id_to_display)
click_button("Search")
end
it "displays scheme matching the scheme code" do
expect(page).to have_content(scheme_to_search.id_to_display)
end
context "when I want to clear results" do it "allows searching the schemes by scheme code" do
it "there is link to clear the search results" do fill_in("search", with: scheme_to_search.id_to_display)
expect(page).to have_link("Clear search") click_button("Search")
end expect(page).to have_content(scheme_to_search.id_to_display)
end
it "displays all schemes after I clear the search results" do it "allows clearing the search results" do
click_link("Clear search") fill_in("search", with: scheme_to_search.id_to_display)
expect(page).to have_content(scheme_to_search.id_to_display) click_button("Search")
schemes.each do |scheme| click_link("Clear search")
expect(page).to have_content(scheme.id_to_display) expect(page).to have_content(scheme_to_search.id_to_display)
end schemes.each do |scheme|
end expect(page).to have_content(scheme.id_to_display)
end
end
end end
end end
end end
context "when viewing individual scheme" do context "when viewing individual scheme" do
let!(:schemes) { FactoryBot.create_list(:scheme, 5) }
context "when I visit schemes page" do context "when I visit schemes page" do
before do before do
visit("schemes") visit("schemes")
end end
it "shows list of links to schemes" do
schemes.each do |scheme|
expect(page).to have_link(scheme.service_name)
expect(page).to have_content(scheme.primary_client_group)
end
end
context "when I click to see individual scheme" do context "when I click to see individual scheme" do
let(:scheme) { schemes.first } let(:scheme) { schemes.first }
@ -222,7 +208,11 @@ RSpec.describe "Schemes scheme Features" do
end end
context "when creating a new scheme" do context "when creating a new scheme" do
let(:organisation_name) { "FooBar" }
let(:scheme) { Scheme.first }
before do before do
FactoryBot.create(:organisation, name: organisation_name)
Scheme.destroy_all Scheme.destroy_all
click_link "Schemes", href: "/schemes" click_link "Schemes", href: "/schemes"
end end
@ -233,8 +223,6 @@ RSpec.describe "Schemes scheme Features" do
end end
context "when I press create a new scheme" do context "when I press create a new scheme" do
let!(:organisation) { FactoryBot.create(:organisation, name: "FooBar") }
before do before do
click_link "Create a new supported housing scheme" click_link "Create a new supported housing scheme"
end end
@ -249,291 +237,235 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_content "Who provides the support services used by this scheme?" expect(page).to have_content "Who provides the support services used by this scheme?"
end end
context "when I fill in scheme details and I press save I see primary client group section" do it "lets me fill in the primary client group" do
let(:scheme) { Scheme.first } fill_in_and_save_scheme_details
expect(page).to have_content "What client group is this scheme intended for?"
end
it "allows to navigate back and fill in the scheme details" do
fill_in_and_save_scheme_details
click_link "Back"
expect(page).to have_current_path("/schemes/#{scheme.id}/details")
expect(page).to have_content "Scheme name"
expect(page).to have_content "This scheme contains confidential information"
expect(page).to have_content "What is this type of scheme?"
expect(page).to have_content "Who provides the support services used by this scheme?"
expect(page).to have_content "Is this scheme registered under the Care Standards Act 2000?"
end
it "returns to the primary client group question after amending scheme details" do
fill_in_and_save_scheme_details
click_link "Back"
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/primary-client-group")
end
it "allows confirming if the scheme provides for secondary group details" do
fill_in_and_save_scheme_details
fill_in_and_save_primary_client_group
expect(page).to have_content "Does this scheme provide for another client group?"
end
it "allows amending primary client group after navigating back from secondary client group confirmation question" do
fill_in_and_save_scheme_details
fill_in_and_save_primary_client_group
click_link "Back"
expect(page).to have_current_path("/schemes/#{scheme.id}/primary-client-group")
expect(page).to have_content "What client group is this scheme intended for?"
end
it "returns to the secondary group details confirmation question after amending primary client group" do
fill_in_and_save_scheme_details
fill_in_and_save_primary_client_group
click_link "Back"
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group")
end
it "allows selecting secondary client group if the scheme provides for it" do
fill_in_and_save_scheme_details
fill_in_and_save_primary_client_group
fill_in_and_save_secondary_client_group_confirmation
expect(page).to have_content "What is the other client group?"
end
it "allows amending secondary client group confirmation question after navigating from secondary client group question" do
fill_in_and_save_scheme_details
fill_in_and_save_primary_client_group
fill_in_and_save_secondary_client_group_confirmation
click_link "Back"
expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group")
expect(page).to have_content "Does this scheme provide for another client group?"
end
it "returns to the secondary group details question after amending secondary group details confirmation" do
fill_in_and_save_scheme_details
fill_in_and_save_primary_client_group
fill_in_and_save_secondary_client_group_confirmation
click_link "Back"
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group")
end
it "allows selecting the level of support" do
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
expect(page).to have_content "What support does this scheme provide?"
end
it "allows amending secondary client group question after navigating from level of support" do
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
click_link "Back"
expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group")
expect(page).to have_content "What is the other client group?"
end
it "returns to the level of support question after amending secondary group details" do
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
click_link "Back"
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/support")
end
context "when adding a location" do
before do before do
fill_in "Scheme name", with: "FooBar" create_and_save_a_scheme
check "This scheme contains confidential information" end
choose "Direct access hostel"
choose "Yes – registered care home providing nursing care" it "lets me add location" do
select organisation.name, from: "scheme-owning-organisation-id-field" expect(page).to have_content "Add a location to this scheme"
choose "The same organisation that owns the housing stock" end
it "lets me navigate back to support questions" do
click_link "Back"
expect(page).to have_current_path("/schemes/#{scheme.id}/support")
expect(page).to have_content "What support does this scheme provide?"
end
it "returns to the add location page after amending the support question" do
click_link "Back"
click_button "Save and continue" click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/locations/new")
end end
it "lets me fill in the scheme details" do it "lets me check my answers after adding a location" do
expect(page).to have_content "What client group is this scheme intended for?" fill_in_and_save_location
expect(page).to have_content "Check your changes before creating this scheme"
end end
context "when I press the back button" do it "lets me check my answers after adding a second location" do
before do fill_in_and_save_location
click_link "Back" click_link "Add a location"
end fill_in_and_save_second_location
expect(page).to have_content "Check your changes before creating this scheme"
end
end
it "lets me fill in the scheme details" do context "when viewing locations" do
expect(page).to have_current_path("/schemes/#{scheme.id}/details") before do
expect(page).to have_content "Scheme name" create_and_save_a_scheme
expect(page).to have_content "This scheme contains confidential information"
expect(page).to have_content "What is this type of scheme?"
expect(page).to have_content "Who provides the support services used by this scheme?"
expect(page).to have_content "Is this scheme registered under the Care Standards Act 2000?"
end
context "when we amend scheme details" do fill_in_and_save_location
it "returns to the primary client group question" do click_link "Locations"
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/primary-client-group")
end
end
end end
context "when I select primary client group details" do it "displays information about a single location" do
before do expect(page).to have_content "Locations"
choose "Homeless families with support needs" expect(page).to have_content "#{scheme.locations.count} location"
click_button "Save and continue" end
end
it "lets me confirm if I want to select secondary group details" do it "displays information about the first created location" do
expect(page).to have_content "Does this scheme provide for another client group?" expect(page).to have_content "SW1P4DF"
end expect(page).to have_content "Some name"
expect(page).to have_content "Self-contained house"
expect(page).to have_content "None"
end
context "when I press the back button" do it "displays information about another location" do
before do click_link "Add a location"
click_link "Back" fill_in_and_save_second_location
end expect(page).to have_content "Locations"
expect(page).to have_content "#{scheme.locations.count} location"
end
it "lets me select the primary client group" do it "displays information about newly created location" do
expect(page).to have_current_path("/schemes/#{scheme.id}/primary-client-group") click_link "Add a location"
expect(page).to have_content "What client group is this scheme intended for?" fill_in_and_save_second_location
end expect(page).to have_content "XX11XX"
expect(page).to have_content "Other name"
expect(page).to have_content "Self-contained house"
end
end
context "when we amend primary client group" do context "when changing location details" do
it "returns to the confirm secondary client group question" do before do
click_button "Save and continue" create_and_save_a_scheme
expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group") fill_in_and_save_second_location
end click_link "Locations"
end end
end
context "when I confirm the secondary group" do it "displays changed location" do
before do click_link "XX11XX"
choose "Yes" fill_in "Postcode", with: "ZZ1 1ZZ"
click_button "Save and continue" choose "location-mobility-type-wheelchair-user-standard-field"
end click_button "Save and continue"
expect(page).to have_content "Locations"
expect(page).to have_content "#{scheme.locations.count} location"
expect(page).to have_content "ZZ11ZZ"
expect(page).to have_content("Wheelchair-user standard")
end
end
it "lets me select secondary client group" do context "when changing scheme answers" do
expect(page).to have_content "What is the other client group?" before do
end create_and_save_a_scheme
fill_in_and_save_location
end
context "when I press the back button" do it "displays change links" do
before do assert_selector "a", text: "Change", count: 13
click_link "Back" end
end
it "lets me confirm the secondary group" do it "allows changing details questions" do
expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group") click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first)
expect(page).to have_content "Does this scheme provide for another client group?" expect(page).to have_current_path("/schemes/#{scheme.id}/details?check_answers=true")
end
context "when we amend confirm secondary client" do fill_in "Scheme name", with: "Example"
it "returns to the secondary client group question" do click_button "Save and continue"
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group")
end
end
end
context "when I select the secondary group" do expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
before do expect(page).to have_content "Example"
choose "Homeless families with support needs" end
click_button "Save and continue"
end
it "lets me select level of support" do it "lets me select the support answers after navigating back" do
expect(page).to have_content "What support does this scheme provide?" click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first)
end click_link "Back"
expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
expect(page).to have_content "Check your changes before creating this scheme"
end
end
context "when I press the back button" do context "when selecting 'create a scheme'" do
before do before do
click_link "Back" create_and_save_a_scheme
end fill_in_and_save_location
click_link "Create scheme"
it "lets me select the secondary group" do end
expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group")
expect(page).to have_content "What is the other client group?"
end
context "when we amend secondary client" do
it "returns to the support question" do
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/support")
end
end
end
context "when I select the support answers" do it "adds scheme to the list of schemes" do
before do expect(page).to have_content "Supported housing schemes"
choose "Low level" expect(page).to have_content scheme.id_to_display
choose "Very short stay" expect(page).to have_content scheme.service_name
click_button "Save and continue" expect(page).to have_content scheme.owning_organisation.name
end expect(page).to have_content "#{scheme.owning_organisation.name} has been created."
it "lets me add location" do
expect(page).to have_content "Add a location to this scheme"
end
context "when I press the back button" do
before do
click_link "Back"
end
it "lets me select the secondary group" do
expect(page).to have_current_path("/schemes/#{scheme.id}/support")
expect(page).to have_content "What support does this scheme provide?"
end
context "when I amend support" do
it "returns to the add location page" do
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/locations/new")
end
end
end
context "when I add location to the scheme" do
before do
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
it "lets me check my answers" do
expect(page).to have_content "Check your changes before creating this scheme"
end
context "when I select to view locations" do
before do
click_link "Locations"
end
it "displays information about locations" do
expect(page).to have_content "Locations"
expect(page).to have_content "#{scheme.locations.count} location"
end
it "displays information about newly created location" do
expect(page).to have_content "SW1P4DF"
expect(page).to have_content "Some name"
expect(page).to have_content "Self-contained house"
expect(page).to have_content "None"
end
end
context "and I select to add another location a scheme" do
before do
click_link "Add a 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
it "lets me check my answers" do
expect(page).to have_content "Check your changes before creating this scheme"
end
context "when I select to view locations" do
before do
click_link "Locations"
end
it "displays information about another location" do
expect(page).to have_content "Locations"
expect(page).to have_content "#{scheme.locations.count} location"
end
it "displays information about newly created location" do
expect(page).to have_content "XX11XX"
expect(page).to have_content "Other name"
expect(page).to have_content "Self-contained house"
end
context "when changing location details" do
before do
click_link "XX11XX"
fill_in "Postcode", with: "ZZ1 1ZZ"
choose "location-mobility-type-wheelchair-user-standard-field"
click_button "Save and continue"
end
it "displays changed location" do
expect(page).to have_content "Locations"
expect(page).to have_content "#{scheme.locations.count} location"
expect(page).to have_content "ZZ11ZZ"
expect(page).to have_content("Wheelchair-user standard")
end
end
end
end
context "when changing answers" do
it "displays change links" do
assert_selector "a", text: "Change", count: 13
end
context "when changing details" do
before do
click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first)
end
it "allows changing details questions" do
expect(page).to have_current_path("/schemes/#{scheme.id}/details?check_answers=true")
fill_in "Scheme name", with: "Example"
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
expect(page).to have_content "Example"
end
context "when I press the back button" do
before do
click_link "Back"
end
it "lets me select the support answers" do
expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
expect(page).to have_content "Check your changes before creating this scheme"
end
end
end
end
context "and I select to create a scheme" do
before do
click_link "Create scheme"
end
it "adds scheme to the list of schemes" do
expect(page).to have_content "Supported housing schemes"
expect(page).to have_content scheme.id_to_display
expect(page).to have_content scheme.service_name
expect(page).to have_content scheme.owning_organisation.name
expect(page).to have_content "#{scheme.owning_organisation.name} has been created."
end
end
end
end
end
end
end end
end end
@ -542,295 +474,66 @@ RSpec.describe "Schemes scheme Features" do
let!(:another_organisation) { FactoryBot.create(:organisation, name: "Another Org") } let!(:another_organisation) { FactoryBot.create(:organisation, name: "Another Org") }
before do before do
fill_in "Scheme name", with: "FooBar" fill_in_and_save_scheme_details({ "housing_stock_owners" => "Another registered housing provider" })
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 "Another registered housing provider"
click_button "Save and continue"
end end
it "lets me fill in the managing organisation details" do it "lets me fill in the managing organisation details" do
expect(page).to have_content "Which organisation provides the support services used by this scheme?" expect(page).to have_content "Which organisation provides the support services used by this scheme?"
end end
context "when I press the back button" do it "lets me fill in the scheme details after navigating back" do
before do click_link "Back"
click_link "Back" expect(page).to have_current_path("/schemes/#{scheme.id}/details")
end expect(page).to have_content "Scheme name"
expect(page).to have_content "This scheme contains confidential information"
expect(page).to have_content "What is this type of scheme?"
expect(page).to have_content "Who provides the support services used by this scheme?"
expect(page).to have_content "Is this scheme registered under the Care Standards Act 2000?"
end
it "lets me fill in the scheme details" do it "returns to the support service provider after amending the question" do
expect(page).to have_current_path("/schemes/#{scheme.id}/details") click_link "Back"
expect(page).to have_content "Scheme name" click_button "Save and continue"
expect(page).to have_content "This scheme contains confidential information" expect(page).to have_current_path("/schemes/#{scheme.id}/support-services-provider")
expect(page).to have_content "What is this type of scheme?" end
expect(page).to have_content "Who provides the support services used by this scheme?"
expect(page).to have_content "Is this scheme registered under the Care Standards Act 2000?"
end
context "when we amend scheme details" do it "lets the primary client group to be selected" do
it "returns to the primary client group question" do select another_organisation.name, from: "scheme-managing-organisation-id-field"
click_button "Save and continue" click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/support-services-provider") expect(page).to have_content "What client group is this scheme intended for?"
end
end
end end
context "when I select organisation providing support for scheme" do context "when changing scheme answers" do
before do before do
select another_organisation.name, from: "scheme-managing-organisation-id-field" select another_organisation.name, from: "scheme-managing-organisation-id-field"
click_button "Save and continue" click_button "Save and continue"
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
fill_in_and_save_location
end end
it "lets me select the primary client group" do it "displays change links" do
expect(page).to have_content "What client group is this scheme intended for?" assert_selector "a", text: "Change", count: 13
end end
context "when I select primary client group details" do it "allows changing details questions" do
before do click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first)
choose "Homeless families with support needs" expect(page).to have_current_path("/schemes/#{scheme.id}/details?check_answers=true")
click_button "Save and continue"
end
it "lets me confirm if I want to select secondary group details" do
expect(page).to have_content "Does this scheme provide for another client group?"
end
context "when I press the back button" do
before do
click_link "Back"
end
it "lets me select the primary client group" do
expect(page).to have_current_path("/schemes/#{scheme.id}/primary-client-group")
expect(page).to have_content "What client group is this scheme intended for?"
end
context "when we amend primary client group" do
it "returns to the confirm secondary client group question" do
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group")
end
end
end
context "when I confirm the secondary group" do fill_in "Scheme name", with: "Example"
before do click_button "Save and continue"
choose "Yes"
click_button "Save and continue"
end
it "lets me select secondary client group" do
expect(page).to have_content "What is the other client group?"
end
context "when I press the back button" do expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
before do expect(page).to have_content "Example"
click_link "Back" end
end
it "lets me confirm the secondary group" do
expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group")
expect(page).to have_content "Does this scheme provide for another client group?"
end
context "when we amend confirm secondary client" do
it "returns to the secondary client group question" do
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group")
end
end
end
context "when I select the secondary group" do it "lets me select the support answers after navigating back" do
before do click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first)
choose "Homeless families with support needs" click_link "Back"
click_button "Save and continue" expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
end expect(page).to have_content "Check your changes before creating this scheme"
it "lets me select level of support" do
expect(page).to have_content "What support does this scheme provide?"
end
context "when I press the back button" do
before do
click_link "Back"
end
it "lets me select the secondary group" do
expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group")
expect(page).to have_content "What is the other client group?"
end
context "when we amend secondary client" do
it "returns to the support question" do
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/support")
end
end
end
context "when I select the support answers" do
before do
choose "Low level"
choose "Very short stay"
click_button "Save and continue"
end
it "lets me add location" do
expect(page).to have_content "Add a location to this scheme"
end
context "when I press the back button" do
before do
click_link "Back"
end
it "lets me select the secondary group" do
expect(page).to have_current_path("/schemes/#{scheme.id}/support")
expect(page).to have_content "What support does this scheme provide?"
end
context "when I amend support" do
it "returns to the add location page" do
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/locations/new")
end
end
end
context "when I add location to the scheme" do
before do
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
it "lets me check my answers" do
expect(page).to have_content "Check your changes before creating this scheme"
end
context "when I select to view locations" do
before do
click_link "Locations"
end
it "displays information about locations" do
expect(page).to have_content "Locations"
expect(page).to have_content "#{scheme.locations.count} location"
end
it "displays information about newly created location" do
expect(page).to have_content "SW1P4DF"
expect(page).to have_content "Some name"
expect(page).to have_content "Self-contained house"
end
end
context "and I select to add another location a scheme" do
before do
click_link "Add a 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
it "lets me check my answers" do
expect(page).to have_content "Check your changes before creating this scheme"
end
context "when I select to view locations" do
before do
click_link "Locations"
end
it "displays information about another location" do
expect(page).to have_content "Locations"
expect(page).to have_content "#{scheme.locations.count} location"
end
it "displays information about newly created location" do
expect(page).to have_content "XX11XX"
expect(page).to have_content "Other name"
expect(page).to have_content "Self-contained house"
end
context "when changing location details" do
before do
click_link "XX11XX"
fill_in "Postcode", with: "ZZ1 1ZZ"
click_button "Save and continue"
end
it "displays changed location" do
expect(page).to have_content "Locations"
expect(page).to have_content "#{scheme.locations.count} location"
expect(page).to have_content "ZZ11ZZ"
end
end
end
end
context "when changing answers" do
it "displays change links" do
assert_selector "a", text: "Change", count: 13
end
context "when changing details" do
before do
click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first)
end
it "allows changing details questions" do
expect(page).to have_current_path("/schemes/#{scheme.id}/details?check_answers=true")
fill_in "Scheme name", with: "Example"
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
expect(page).to have_content "Example"
end
context "when I press the back button" do
before do
click_link "Back"
end
it "lets me select the support answers" do
expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
expect(page).to have_content "Check your changes before creating this scheme"
end
end
end
end
context "and I select to create a scheme" do
before do
click_link "Create scheme"
end
it "adds scheme to the list of schemes" do
expect(page).to have_content "Supported housing schemes"
expect(page).to have_content scheme.id_to_display
expect(page).to have_content scheme.service_name
expect(page).to have_content scheme.owning_organisation.name
expect(page).to have_content scheme.managing_organisation.name
expect(page).to have_content "#{scheme.owning_organisation.name} has been created."
end
end
end
end
end
end
end end
end end
end end

Loading…
Cancel
Save