Browse Source

test: mock new locations layout feature toggle in tests

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

29
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,14 +204,25 @@ 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") end
else end
expect(page).to have_content(location.units) end
expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date)) context "when I click locations link and the new locations layout feature toggle is disabled" do
end 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.type_of_unit)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end end
end end
end end

52
spec/requests/locations_controller_spec.rb

@ -867,19 +867,25 @@ 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) end
else end
expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type) it "shows locations with correct data wben the new locations layout feature toggle is disabled" do
expect(page).to have_content(location.location_admin_district) allow(FeatureToggle).to receive(:new_locations_table_layout_enabled?).and_return(false)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date)) get "/schemes/#{scheme.id}/locations"
end 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.mobility_type)
expect(page).to have_content(location.location_admin_district)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end end
end end
@ -977,19 +983,25 @@ 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) end
else end
expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type) it "shows locations with correct data wben the new locations layout feature toggle is disabled" do
expect(page).to have_content(location.location_admin_district) allow(FeatureToggle).to receive(:new_locations_table_layout_enabled?).and_return(false)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date)) get "/schemes/#{scheme.id}/locations"
end 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.mobility_type)
expect(page).to have_content(location.location_admin_district)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end end
end end

Loading…
Cancel
Save