diff --git a/app/components/prediction_component.html.erb b/app/components/prediction_component.html.erb index d77b2da0..9aa984e8 100644 --- a/app/components/prediction_component.html.erb +++ b/app/components/prediction_component.html.erb @@ -1,11 +1,11 @@
- <%= @prediction.name %> + <%= name_for_label %>
-
<%= @prediction.daqi_label %>
+
<%= daqi_level_for_label %>
<%= render partial: "shared/icons/chevron_down" %>
diff --git a/app/components/prediction_component.rb b/app/components/prediction_component.rb index ebde1945..faebd48b 100644 --- a/app/components/prediction_component.rb +++ b/app/components/prediction_component.rb @@ -9,10 +9,18 @@ def name_for_class @prediction.name.parameterize end + def name_for_label + @prediction.name + end + def daqi_level_for_class @prediction.daqi_level.to_s.parameterize end + def daqi_level_for_label + @prediction.daqi_label + end + def daqi_indicator_colour case @prediction.daqi_level when :low diff --git a/app/models/pollen_prediction.rb b/app/models/pollen_prediction.rb index b9d8e508..a711159f 100644 --- a/app/models/pollen_prediction.rb +++ b/app/models/pollen_prediction.rb @@ -7,6 +7,10 @@ def initialize(value) @value = value end + def name + "Pollen" + end + def guidance I18n.t("prediction.guidance.pollen.#{daqi_level}") end diff --git a/app/models/temperature_prediction.rb b/app/models/temperature_prediction.rb index 8cfcbb71..cc6a2ac9 100644 --- a/app/models/temperature_prediction.rb +++ b/app/models/temperature_prediction.rb @@ -6,6 +6,10 @@ def initialize(min:, max:) @max = max end + def name + "Temperature" + end + # :nocov: def inspect "#<#{self.class.name} @min=#{min} @max=#{max}>" diff --git a/app/models/uv_prediction.rb b/app/models/uv_prediction.rb index bade22ef..5b4f7909 100644 --- a/app/models/uv_prediction.rb +++ b/app/models/uv_prediction.rb @@ -7,6 +7,10 @@ def initialize(value) @value = value end + def name + "Ultravoilet rays (UV)" + end + def guidance I18n.t("prediction.guidance.uv.#{daqi_level}") end diff --git a/app/views/styled_forecasts/_predictions.html.erb b/app/views/styled_forecasts/_predictions.html.erb index 202e24e4..6f40a31f 100644 --- a/app/views/styled_forecasts/_predictions.html.erb +++ b/app/views/styled_forecasts/_predictions.html.erb @@ -1,40 +1,5 @@
-
-
-
Ultravoilet rays (UV) -
-
-
Low
-
<%= render partial: "shared/icons/chevron_down" %>
-
-
- -
-
-
-
Pollen -
-
-
Moderate
-
<%= render partial: "shared/icons/chevron_down" %>
-
-
-
- <%= render partial: "details" %> -
-
-
-
-
Temperature -
-
-
Low
-
<%= render partial: "shared/icons/chevron_down" %>
-
-
- -
-
+ <%= render(PredictionComponent.new(prediction: @forecasts.first.uv)) %> + <%= render(PredictionComponent.new(prediction: @forecasts.first.pollen)) %> + <%= render "temperature_prediction", prediction: @forecasts.first.temperature %> diff --git a/app/views/styled_forecasts/_temperature_prediction.html.erb b/app/views/styled_forecasts/_temperature_prediction.html.erb new file mode 100644 index 00000000..05bcb1a5 --- /dev/null +++ b/app/views/styled_forecasts/_temperature_prediction.html.erb @@ -0,0 +1,9 @@ +
+
+
<%= prediction.name %>
+
+
<%= "#{prediction.min.round}°C - #{prediction.max.round}" %>°C
+
+
+
+ diff --git a/spec/feature_steps/forecast_steps.rb b/spec/feature_steps/forecast_steps.rb index f58ddb3a..3ff1c79d 100644 --- a/spec/feature_steps/forecast_steps.rb +++ b/spec/feature_steps/forecast_steps.rb @@ -88,6 +88,18 @@ def and_i_see_predicted_temperature_for_each_day expect_prediction(day: :day_after_tomorrow, category: :temperature, value: "27-31°C") end + def and_i_see_predicted_uv_level_v2 + expect_prediction_v2(category: "ultravoilet-rays-uv", value: "Low") + end + + def and_i_see_predicted_pollen_level_v2 + expect_prediction_v2(category: :pollen, value: "Low") + end + + def and_i_see_predicted_temperature_level_v2 + expect_prediction_v2(category: :temperature, value: "-5°C - 4°C") + end + def expect_prediction(day:, category:, value:) within(prediction_category(category)) do within("td[data-date='#{date(day)}']") do @@ -96,6 +108,12 @@ def expect_prediction(day:, category:, value:) end end + def expect_prediction_v2(category:, value:) + within(".#{category}") do + find("dd", text: value) + end + end + def expect_air_pollution_prediction(day:, value:) within("div[data-date='#{date(day)}']") do expect(page).to have_content(content_for_air_pollution(value)) diff --git a/spec/features/visitors/view_styled_forecasts_spec.rb b/spec/features/visitors/view_styled_forecasts_spec.rb index 7b324266..37a7be2f 100644 --- a/spec/features/visitors/view_styled_forecasts_spec.rb +++ b/spec/features/visitors/view_styled_forecasts_spec.rb @@ -25,5 +25,8 @@ when_i_select_view_forecasts_v2 then_i_see_the_forecasts_page_v2 and_i_see_predicted_air_pollution_status_for_each_day_v2 + and_i_see_predicted_uv_level_v2 + and_i_see_predicted_pollen_level_v2 + and_i_see_predicted_temperature_level_v2 end end