Browse Source

Update and remove repeated tests from schemes feature tests

pull/767/head
Kat 3 years ago
parent
commit
e8e7221ca1
  1. 4
      spec/features/schemes_helpers.rb
  2. 310
      spec/features/schemes_spec.rb

4
spec/features/schemes_helpers.rb

@ -23,13 +23,13 @@ module SchemesHelpers
click_button("Sign in") click_button("Sign in")
end end
def fill_in_and_save_scheme_details def fill_in_and_save_scheme_details(answers = {})
fill_in "Scheme name", with: "FooBar" fill_in "Scheme name", with: "FooBar"
check "This scheme contains confidential information" check "This scheme contains confidential information"
choose "Direct access hostel" choose "Direct access hostel"
choose "Yes – registered care home providing nursing care" choose "Yes – registered care home providing nursing care"
select organisation.name, from: "scheme-owning-organisation-id-field" select organisation.name, from: "scheme-owning-organisation-id-field"
choose "The same organisation that owns the housing stock" choose answers["housing_stock_owners"].presence || "The same organisation that owns the housing stock"
click_button "Save and continue" click_button "Save and continue"
end end

310
spec/features/schemes_spec.rb

@ -470,300 +470,72 @@ RSpec.describe "Schemes scheme Features" do
end end
end end
context "when I fill in scheme details indicating that supported services provided by a different organisation and I press save I see primary client group section" do context "when I fill in scheme details indicating that supported services provided by a different organisation and I press save I see primary client group section" do
let(:scheme) { Scheme.first } let(:scheme) { Scheme.first }
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 fill_in "Scheme name", with: "Example"
before do click_button "Save and continue"
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
before do
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