Skip to content

Commit

Permalink
Merge pull request #4360 from DFE-Digital/2027-update-apply-deadline-…
Browse files Browse the repository at this point in the history
…banner-in-publish

[2027] Update apply deadline banner in publish
  • Loading branch information
elceebee authored Jul 10, 2024
2 parents ffd59fa + de5954d commit 22c8b79
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 8 deletions.
6 changes: 2 additions & 4 deletions app/components/find/deadline_banner_component.html.erb
Original file line number Diff line number Diff line change
@@ -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") %>
<p class="govuk-body">Courses can fill up at any time, so you should apply as soon as you can.</p>
<p class="govuk-body">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 %>.</p>
<p class="govuk-body">If your application did not lead to a place and you’re applying again, apply no later than <%= apply_deadline %>.</p>
<% notification_banner.with_heading(text: t("apply_deadline_banner.heading", cycle_year_range:, apply_deadline:)) %>
<p class="govuk-body"><%= t("apply_deadline_banner.text") %></p>
<% end %>
<% elsif cycle_timetable.show_cycle_closed_banner? %>
<%= govuk_notification_banner(title_text: "Important") do |notification_banner| %>
Expand Down
4 changes: 4 additions & 0 deletions app/components/find/deadline_banner_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions config/locales/deadline_banner_component.yml
Original file line number Diff line number Diff line change
@@ -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.
43 changes: 43 additions & 0 deletions spec/components/find/deadline_banner_component_preview.rb
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions spec/components/find/deadline_banner_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion spec/features/find/switcher_cycles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 22c8b79

Please sign in to comment.