Browse Source

test: mock new locations layout feature toggle in tests

pull/987/head
Sam Seed 4 years ago
parent
commit
3f756365e7
  1. 19
      spec/features/schemes_spec.rb
  2. 28
      spec/requests/locations_controller_spec.rb

19
spec/features/schemes_spec.rb

@ -195,7 +195,7 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_link("Locations") expect(page).to have_link("Locations")
end end
context "when I click locations link" do context "when I click locations link and the new locations layout feature toggle is enabled" do
before do before do
click_link("Locations") click_link("Locations")
end end
@ -204,17 +204,28 @@ RSpec.describe "Schemes scheme Features" do
locations.each do |location| locations.each do |location|
expect(page).to have_content(location.id) expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode) expect(page).to have_content(location.postcode)
if FeatureToggle.new_locations_table_layout_enabled?
expect(page).to have_content(location.name) expect(page).to have_content(location.name)
expect(page).to have_content("Active") expect(page).to have_content("Active")
else end
end
end
context "when I click locations link and the new locations layout feature toggle is disabled" do
before do
allow(FeatureToggle).to receive(:new_locations_table_layout_enabled?).and_return(false)
click_link("Locations")
end
it "shows details of those locations" do
locations.each do |location|
expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode)
expect(page).to have_content(location.units) expect(page).to have_content(location.units)
expect(page).to have_content(location.type_of_unit) expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date)) expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end end
end end
end end
end
context "when I search for a specific location" do context "when I search for a specific location" do
before do before do

28
spec/requests/locations_controller_spec.rb

@ -867,21 +867,27 @@ RSpec.describe LocationsController, type: :request do
end end
end end
it "shows locations with correct data" do it "shows locations with correct data wben the new locations layout feature toggle is enabled" do
locations.each do |location| locations.each do |location|
expect(page).to have_content(location.id) expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode) expect(page).to have_content(location.postcode)
if FeatureToggle.new_locations_table_layout_enabled?
expect(page).to have_content(location.name) expect(page).to have_content(location.name)
expect(page).to have_content(location.status) expect(page).to have_content(location.status)
else end
end
it "shows locations with correct data wben the new locations layout feature toggle is disabled" do
allow(FeatureToggle).to receive(:new_locations_table_layout_enabled?).and_return(false)
get "/schemes/#{scheme.id}/locations"
locations.each do |location|
expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode)
expect(page).to have_content(location.type_of_unit) expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type) expect(page).to have_content(location.mobility_type)
expect(page).to have_content(location.location_admin_district) expect(page).to have_content(location.location_admin_district)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date)) expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end end
end end
end
it "has page heading" do it "has page heading" do
expect(page).to have_content(scheme.service_name) expect(page).to have_content(scheme.service_name)
@ -977,21 +983,27 @@ RSpec.describe LocationsController, type: :request do
get "/schemes/#{scheme.id}/locations" get "/schemes/#{scheme.id}/locations"
end end
it "shows locations with correct data" do it "shows locations with correct data wben the new locations layout feature toggle is enabled" do
locations.each do |location| locations.each do |location|
expect(page).to have_content(location.id) expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode) expect(page).to have_content(location.postcode)
if FeatureToggle.new_locations_table_layout_enabled?
expect(page).to have_content(location.name) expect(page).to have_content(location.name)
expect(page).to have_content(location.status) expect(page).to have_content(location.status)
else end
end
it "shows locations with correct data wben the new locations layout feature toggle is disabled" do
allow(FeatureToggle).to receive(:new_locations_table_layout_enabled?).and_return(false)
get "/schemes/#{scheme.id}/locations"
locations.each do |location|
expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode)
expect(page).to have_content(location.type_of_unit) expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type) expect(page).to have_content(location.mobility_type)
expect(page).to have_content(location.location_admin_district) expect(page).to have_content(location.location_admin_district)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date)) expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end end
end end
end
it "has page heading" do it "has page heading" do
expect(page).to have_content(scheme.service_name) expect(page).to have_content(scheme.service_name)

Loading…
Cancel
Save