diff --git a/app/components/find/deadline_banner_component.html.erb b/app/components/find/deadline_banner_component.html.erb index b15f559e7d..f48bf388bc 100644 --- a/app/components/find/deadline_banner_component.html.erb +++ b/app/components/find/deadline_banner_component.html.erb @@ -1,9 +1,7 @@ <% if cycle_timetable.show_apply_deadline_banner? %> <%= govuk_notification_banner(title_text: "Important") do |notification_banner| %> - <% notification_banner.with_heading(text: "Apply now to get on a course starting in the #{cycle_timetable.cycle_year_range} academic year") %> -

Courses can fill up at any time, so you should apply as soon as you can.

-

If you’re applying for the first time since applications opened in <%= cycle_timetable.find_opens.to_fs(:month_and_year) %>, apply no later than <%= apply_deadline %>.

-

If your application did not lead to a place and you’re applying again, apply no later than <%= apply_deadline %>.

+ <% notification_banner.with_heading(text: t("apply_deadline_banner.heading", cycle_year_range:, apply_deadline:)) %> +

<%= t("apply_deadline_banner.text") %>

<% end %> <% elsif cycle_timetable.show_cycle_closed_banner? %> <%= govuk_notification_banner(title_text: "Important") do |notification_banner| %> diff --git a/app/components/find/deadline_banner_component.rb b/app/components/find/deadline_banner_component.rb index 29090a2444..726b91907d 100644 --- a/app/components/find/deadline_banner_component.rb +++ b/app/components/find/deadline_banner_component.rb @@ -22,6 +22,10 @@ def apply_deadline cycle_timetable.apply_deadline.to_fs(:govuk_date_and_time) end + def cycle_year_range + cycle_timetable.cycle_year_range + end + def find_opens cycle_timetable.find_opens.to_fs(:month_and_year) end diff --git a/config/locales/deadline_banner_component.yml b/config/locales/deadline_banner_component.yml new file mode 100644 index 0000000000..bf920c89aa --- /dev/null +++ b/config/locales/deadline_banner_component.yml @@ -0,0 +1,4 @@ +en: + apply_deadline_banner: + heading: The deadline for applying to courses starting in %{cycle_year_range} is %{apply_deadline} + text: Courses may fill up before then. Check course availability with the provider. diff --git a/spec/components/find/deadline_banner_component_preview.rb b/spec/components/find/deadline_banner_component_preview.rb new file mode 100644 index 0000000000..a2e37fcde3 --- /dev/null +++ b/spec/components/find/deadline_banner_component_preview.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Find + class DeadlineBannerComponentPreview < ViewComponent::Preview + def show_apply_deadline_banner + render( + Find::DeadlineBannerComponent.new( + flash_empty: true, + cycle_timetable: ShowApplyDeadlineBannerCycleTimetable + ) + ) + end + + def show_cycle_closed_banner + render( + Find::DeadlineBannerComponent.new( + flash_empty: true, + cycle_timetable: ShowCycleClosedBannerTimetable + ) + ) + end + end + + class ShowApplyDeadlineBannerCycleTimetable < CycleTimetable + def self.show_apply_deadline_banner? + true + end + + def self.show_cycle_closed_banner? + false + end + end + + class ShowCycleClosedBannerTimetable < CycleTimetable + def self.show_apply_deadline_banner? + false + end + + def self.show_cycle_closed_banner? + true + end + end +end diff --git a/spec/components/find/deadline_banner_component_spec.rb b/spec/components/find/deadline_banner_component_spec.rb index 3075352689..4fbfd658a5 100644 --- a/spec/components/find/deadline_banner_component_spec.rb +++ b/spec/components/find/deadline_banner_component_spec.rb @@ -19,9 +19,10 @@ module Find Timecop.travel(CycleTimetable.first_deadline_banner + 1.hour) do result = render_inline(described_class.new(flash_empty: true)) - expect(result.text).to include('Courses can fill up at any time, so you should apply as soon as you can.') - expect(result.text).not_to include("You can continue to view and apply for courses until 6pm on #{CycleTimetable.apply_deadline.strftime('%e %B %Y')}") - expect(result.text).not_to include('as there’s no guarantee that the courses currently shown on this website will be on offer next year.') + cycle_year_range = Find::CycleTimetable.cycle_year_range + apply_deadline = Find::CycleTimetable.apply_deadline.to_fs(:govuk_date_and_time) + expect(result.text).to include("The deadline for applying to courses starting in #{cycle_year_range} is #{apply_deadline}") + expect(result.text).to include('Courses may fill up before then. Check course availability with the provider.') end end end diff --git a/spec/features/find/switcher_cycles_spec.rb b/spec/features/find/switcher_cycles_spec.rb index df592dcc98..ae7613fcab 100644 --- a/spec/features/find/switcher_cycles_spec.rb +++ b/spec/features/find/switcher_cycles_spec.rb @@ -19,7 +19,7 @@ then_i_click_on_update_button and_i_should_see_the_success_banner and_i_visit_find_results_page - and_i_see_deadline_banner('Apply now to get on a course starting in the 2023 to 2024 academic year') + and_i_see_mid_cycle_banner end scenario 'Update to Apply deadline has passed' do @@ -80,6 +80,13 @@ def and_i_visit_the_find_homepage visit '/' end + def and_i_see_mid_cycle_banner + cycle_year_range = Find::CycleTimetable.cycle_year_range + apply_deadline = Find::CycleTimetable.apply_deadline.to_fs(:govuk_date_and_time) + banner_text = "The deadline for applying to courses starting in #{cycle_year_range} is #{apply_deadline}" + and_i_see_deadline_banner(banner_text) + end + def and_i_see_deadline_banner(banner_text) expect(page).to have_css('.govuk-notification-banner__content', text: banner_text) end