Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2027] Update apply deadline banner in publish #4360

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
avinhurry marked this conversation as resolved.
Show resolved Hide resolved
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
avinhurry marked this conversation as resolved.
Show resolved Hide resolved
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
Loading