Skip to content

Commit

Permalink
Update integration tests to check for alert classes
Browse files Browse the repository at this point in the history
We need to update our integration tests to allow us to explicitly set DAQI values, so that we can check that the correct class for that value has been set on the active tab where there is an alert.
  • Loading branch information
patrickjfl committed Nov 6, 2024
1 parent e060cec commit 6eca99a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions spec/feature_steps/air_quality_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ def given_an_air_pollution_prediction_for_today_w_high_warning_status
end

def and_an_air_pollution_prediction_for_tomorrow_w_moderate_warning_status
forecasts << Fixtures::API.build_forecast(day: :tomorrow, air_pollution_status: :moderate)
forecasts << Fixtures::API.build_forecast(day: :tomorrow, air_pollution_status: :moderate, daqi_value: 4)
end

def and_an_air_pollution_prediction_for_day_after_tomorrow_w_v_high_warning_status
forecasts << Fixtures::API.build_forecast(day: :day_after_tomorrow, air_pollution_status: :very_high)
forecasts << Fixtures::API.build_forecast(day: :day_after_tomorrow, air_pollution_status: :very_high, daqi_value: 10)
end

def given_an_air_pollution_prediction_for_today_w_low_status
Expand Down Expand Up @@ -116,6 +116,9 @@ def then_i_see_an_air_quality_alert_of_moderate_for_tomorrow_v2
within(".alert-guidance") do
expect_to_see_guidance_for(:moderate)
end

expect(page).to have_css(".tab.tomorrow.daqi-alert-after-today-selected-level-4")
expect(page).not_to have_css(".tab.day_after_tomorrow.daqi-alert-after-today-selected-level-10")
end

def then_i_see_an_air_quality_alert_of_v_high_for_day_after_tomorrow_v2
Expand All @@ -125,6 +128,9 @@ def then_i_see_an_air_quality_alert_of_v_high_for_day_after_tomorrow_v2
within(".alert-guidance") do
expect_to_see_guidance_for(:very_high)
end

expect(page).to have_css(".tab.day_after_tomorrow.daqi-alert-after-today-selected-level-10")
expect(page).not_to have_css(".tab.tomorrow.daqi-alert-after-today-selected-level-4")
end

def and_i_see_an_air_quality_alert_of_moderate_for_tomorrow
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/api/forecasts.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Fixtures
module API
class << self
def build_forecast(day:, air_pollution_status:, pollen: :moderate, temperature: :normal, uv: :moderate)
def build_forecast(day:, air_pollution_status:, pollen: :moderate, temperature: :normal, uv: :moderate, daqi_value: nil)
<<~JSON
{
"NO2": 1,
Expand All @@ -16,7 +16,7 @@ def build_forecast(day:, air_pollution_status:, pollen: :moderate, temperature:
"rain_pm": 3.01,
"temp_max": #{max_temp_for(temperature)},
"temp_min": #{min_temp_for(temperature)},
"total": #{daqi_value_for_level(air_pollution_status)},
"total": #{daqi_value || daqi_value_for_level(air_pollution_status)},
"total_status": "#{total_status_for(air_pollution_status)}",
"uv": #{daqi_value_for_level(uv)},
"wind_am": 5.3,
Expand Down

0 comments on commit 6eca99a

Please sign in to comment.