From 0ff8b029c8c5d8d7e1db4125f497a15c9984e1d0 Mon Sep 17 00:00:00 2001 From: Avin Hurry Date: Mon, 4 Mar 2024 12:02:26 +0000 Subject: [PATCH 1/6] [1340] Rework results page labels - Add new labels - Add logic to generate the value for the new label - Re-order existing labels --- .../results/search_result_component.html.erb | 27 +++++++++++-------- .../find/results/search_result_component.rb | 16 +++++++++++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/app/components/find/results/search_result_component.html.erb b/app/components/find/results/search_result_component.html.erb index 09b3f45603..93f793a9a7 100644 --- a/app/components/find/results/search_result_component.html.erb +++ b/app/components/find/results/search_result_component.html.erb @@ -6,8 +6,19 @@ <% end %>
-
Study type
-
<%= course.study_mode.humanize %>
+ +
Fee or salary
+
<%= course.funding %> +
+

<%= course.funding_option %> +

+ +
Course fee
+
<%= course_fee_value %>
+ +
Visa sponsorship
+
<%= visa_sponsorship_status %>
+
Qualification
<% if accredited_provider %> @@ -18,6 +29,9 @@ <% end %>
+
Study type
+
<%= course.study_mode.humanize %>
+ <% if filtered_by_location? && has_sites? %> <% if course.university_based? %> <%= render partial: "find/results/university", locals: { course: } %> @@ -26,16 +40,7 @@ <% end %> <% end %> -
Fee or salary
-
<%= course.funding %> -
-

<%= course.funding_option %> -

-
Degree required
<%= degree_required_status %>
- -
Visa sponsorship
-
<%= visa_sponsorship_status %>
diff --git a/app/components/find/results/search_result_component.rb b/app/components/find/results/search_result_component.rb index b44eabdbef..bea372120b 100644 --- a/app/components/find/results/search_result_component.rb +++ b/app/components/find/results/search_result_component.rb @@ -51,6 +51,22 @@ def visa_sponsorship_status end end + def course_fee_value + safe_join([formatted_uk_eu_fee_label, tag.br, formatted_international_fee_label]) + end + + def formatted_uk_eu_fee_label + return if course.fee_uk_eu.blank? + + "UK students: #{number_to_currency(course.fee_uk_eu)}" + end + + def formatted_international_fee_label + return if course.fee_international.blank? + + "International students: #{number_to_currency(course.fee_international)}" + end + def accredited_provider return nil if course.accrediting_provider.blank? From a6afc1107dd8b1789449100642b74b9923f82dd6 Mon Sep 17 00:00:00 2001 From: Avin Hurry Date: Mon, 4 Mar 2024 18:29:00 +0000 Subject: [PATCH 2/6] [1340] Add course fee to summary component - Add logic for course fee value - Render the new value in the component view --- .../find/courses/summary_component/view.html.erb | 3 +++ .../find/courses/summary_component/view.rb | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/app/components/find/courses/summary_component/view.html.erb b/app/components/find/courses/summary_component/view.html.erb index 83a3d0acd3..c5d4a6c880 100644 --- a/app/components/find/courses/summary_component/view.html.erb +++ b/app/components/find/courses/summary_component/view.html.erb @@ -13,6 +13,9 @@
Visa sponsorship
<%= visa_sponsorship_row %>
+
Course fee
+
<%= course_fee_value %>
+
Qualification
<%= render Find::Courses::QualificationsSummaryComponent::View.new(find_outcome) %> <% if age_range_in_years.present? %> diff --git a/app/components/find/courses/summary_component/view.rb b/app/components/find/courses/summary_component/view.rb index a70095f54c..889dec014b 100644 --- a/app/components/find/courses/summary_component/view.rb +++ b/app/components/find/courses/summary_component/view.rb @@ -50,6 +50,22 @@ def visa_sponsorship_row 'Visas cannot be sponsored' end end + + def course_fee_value + safe_join([formatted_uk_eu_fee_label, tag.br, formatted_international_fee_label]) + end + + def formatted_uk_eu_fee_label + return if course.fee_uk_eu.blank? + + "UK students: #{number_to_currency(course.fee_uk_eu)}" + end + + def formatted_international_fee_label + return if course.fee_international.blank? + + "International students: #{number_to_currency(course.fee_international)}" + end end end end From 609b7548e69b0c285a7af9635bc527f656bd5209 Mon Sep 17 00:00:00 2001 From: Avin Hurry Date: Mon, 4 Mar 2024 19:13:08 +0000 Subject: [PATCH 3/6] [1340] Add component tests --- .../courses/sumary_component/view_spec.rb | 40 +++++++++++++++++++ .../results/search_result_component_spec.rb | 40 +++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/spec/components/find/courses/sumary_component/view_spec.rb b/spec/components/find/courses/sumary_component/view_spec.rb index bd55cbfd3f..18dfcf99ff 100644 --- a/spec/components/find/courses/sumary_component/view_spec.rb +++ b/spec/components/find/courses/sumary_component/view_spec.rb @@ -128,6 +128,46 @@ module SummaryComponent expect(result.text).to include('Visas cannot be sponsored') end end + + context 'when there are UK fees' do + it 'renders the uk fees' do + course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: 9250)]).decorate + + result = render_inline(described_class.new(course)) + expect(result.text).to include('UK students: £9,250') + end + end + + context 'when there are international fees' do + it 'renders the international fees' do + course = create(:course, enrichments: [create(:course_enrichment, fee_international: 14_000)]).decorate + + result = render_inline(described_class.new(course)) + expect(result.text).to include('International students: £14,000') + end + end + + context 'when there are uk fees but no international fees' do + it 'renders the uk fees and not the internation fee label' do + course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: 9250, fee_international: nil)]).decorate + + result = render_inline(described_class.new(course)) + + expect(result.text).to include('UK students: £9,250') + expect(result.text).not_to include('International students') + end + end + + context 'when there are international fees but no uk fees' do + it 'renders the international fees but not the uk fee label' do + course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: nil, fee_international: 14_000)]).decorate + + result = render_inline(described_class.new(course)) + + expect(result.text).not_to include('UK students') + expect(result.text).to include('International students: £14,000') + end + end end end end diff --git a/spec/components/find/results/search_result_component_spec.rb b/spec/components/find/results/search_result_component_spec.rb index 51c234c407..9d8bf4054c 100644 --- a/spec/components/find/results/search_result_component_spec.rb +++ b/spec/components/find/results/search_result_component_spec.rb @@ -97,5 +97,45 @@ module Find expect(result.text).not_to include('QTS ratified by') end end + + context 'when there are UK fees' do + it 'renders the uk fees' do + course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: 9250)]).decorate + + result = render_inline(described_class.new(course:)) + expect(result.text).to include('UK students: £9,250') + end + end + + context 'when there are international fees' do + it 'renders the international fees' do + course = create(:course, enrichments: [create(:course_enrichment, fee_international: 14_000)]).decorate + + result = render_inline(described_class.new(course:)) + expect(result.text).to include('International students: £14,000') + end + end + + context 'when there are uk fees but no international fees' do + it 'renders the uk fees and not the internation fee label' do + course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: 9250, fee_international: nil)]).decorate + + result = render_inline(described_class.new(course:)) + + expect(result.text).to include('UK students: £9,250') + expect(result.text).not_to include('International students') + end + end + + context 'when there are international fees but no uk fees' do + it 'renders the international fees but not the uk fee label' do + course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: nil, fee_international: 14_000)]).decorate + + result = render_inline(described_class.new(course:)) + + expect(result.text).not_to include('UK students') + expect(result.text).to include('International students: £14,000') + end + end end end From 3f39df2a708ba57287ceb47b2b1614625644824a Mon Sep 17 00:00:00 2001 From: Avin Hurry Date: Mon, 4 Mar 2024 19:17:54 +0000 Subject: [PATCH 4/6] [1340] Fix preview specs --- spec/components/find/courses/sumary_component/view_preview.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/components/find/courses/sumary_component/view_preview.rb b/spec/components/find/courses/sumary_component/view_preview.rb index 2293a559bc..20c6add5a5 100644 --- a/spec/components/find/courses/sumary_component/view_preview.rb +++ b/spec/components/find/courses/sumary_component/view_preview.rb @@ -57,7 +57,7 @@ def mock_primary_course class FakeCourse include ActiveModel::Model - attr_accessor(:provider, :accrediting_provider, :has_bursary, :age_range_in_years, :course_length, :applications_open_from, :start_date, :qualification, :funding_type, :subjects, :level, :can_sponsor_student_visa) + attr_accessor(:provider, :accrediting_provider, :has_bursary, :age_range_in_years, :course_length, :applications_open_from, :start_date, :qualification, :funding_type, :subjects, :level, :can_sponsor_student_visa, :fee_uk_eu, :fee_international) def has_bursary? has_bursary From dac19a00e0960b7f49f1c08c8870ebab7bf1502f Mon Sep 17 00:00:00 2001 From: Avin Hurry Date: Tue, 5 Mar 2024 11:21:10 +0000 Subject: [PATCH 5/6] [1340] Fix indentation and data-qa --- app/components/find/courses/summary_component/view.html.erb | 4 ++-- app/components/find/results/search_result_component.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/components/find/courses/summary_component/view.html.erb b/app/components/find/courses/summary_component/view.html.erb index c5d4a6c880..34792b35bd 100644 --- a/app/components/find/courses/summary_component/view.html.erb +++ b/app/components/find/courses/summary_component/view.html.erb @@ -13,8 +13,8 @@
Visa sponsorship
<%= visa_sponsorship_row %>
-
Course fee
-
<%= course_fee_value %>
+
Course fee
+
<%= course_fee_value %>
Qualification
<%= render Find::Courses::QualificationsSummaryComponent::View.new(find_outcome) %> diff --git a/app/components/find/results/search_result_component.html.erb b/app/components/find/results/search_result_component.html.erb index 93f793a9a7..883f2ea8f6 100644 --- a/app/components/find/results/search_result_component.html.erb +++ b/app/components/find/results/search_result_component.html.erb @@ -14,7 +14,7 @@
Course fee
-
<%= course_fee_value %>
+
<%= course_fee_value %>
Visa sponsorship
<%= visa_sponsorship_status %>
From a43852b4930b2927da80efae9224933ed2c6123d Mon Sep 17 00:00:00 2001 From: Avin Hurry Date: Tue, 5 Mar 2024 18:40:29 +0000 Subject: [PATCH 6/6] [1340] Handle no fee cases Salaried or apprenticeship salaried courses don't have a fee --- .../find/courses/summary_component/view.html.erb | 6 ++++-- .../find/courses/summary_component/view.rb | 4 ++++ .../find/results/search_result_component.html.erb | 6 ++++-- .../find/results/search_result_component.rb | 4 ++++ .../find/courses/sumary_component/view_spec.rb | 13 +++++++++++++ .../find/results/search_result_component_spec.rb | 13 +++++++++++++ 6 files changed, 42 insertions(+), 4 deletions(-) diff --git a/app/components/find/courses/summary_component/view.html.erb b/app/components/find/courses/summary_component/view.html.erb index 34792b35bd..a0b2424e19 100644 --- a/app/components/find/courses/summary_component/view.html.erb +++ b/app/components/find/courses/summary_component/view.html.erb @@ -13,8 +13,10 @@
Visa sponsorship
<%= visa_sponsorship_row %>
-
Course fee
-
<%= course_fee_value %>
+ <% unless no_fee? %> +
Course fee
+
<%= course_fee_value %>
+ <% end %>
Qualification
<%= render Find::Courses::QualificationsSummaryComponent::View.new(find_outcome) %> diff --git a/app/components/find/courses/summary_component/view.rb b/app/components/find/courses/summary_component/view.rb index 889dec014b..64b86ea4a8 100644 --- a/app/components/find/courses/summary_component/view.rb +++ b/app/components/find/courses/summary_component/view.rb @@ -66,6 +66,10 @@ def formatted_international_fee_label "International students: #{number_to_currency(course.fee_international)}" end + + def no_fee? + course.fee_international.blank? && course.fee_uk_eu.blank? + end end end end diff --git a/app/components/find/results/search_result_component.html.erb b/app/components/find/results/search_result_component.html.erb index 883f2ea8f6..3b569ce609 100644 --- a/app/components/find/results/search_result_component.html.erb +++ b/app/components/find/results/search_result_component.html.erb @@ -13,8 +13,10 @@

<%= course.funding_option %> -

Course fee
-
<%= course_fee_value %>
+ <% unless no_fee? %> +
Course fee
+
<%= course_fee_value %>
+ <% end %>
Visa sponsorship
<%= visa_sponsorship_status %>
diff --git a/app/components/find/results/search_result_component.rb b/app/components/find/results/search_result_component.rb index bea372120b..044cb347ec 100644 --- a/app/components/find/results/search_result_component.rb +++ b/app/components/find/results/search_result_component.rb @@ -67,6 +67,10 @@ def formatted_international_fee_label "International students: #{number_to_currency(course.fee_international)}" end + def no_fee? + course.fee_international.blank? && course.fee_uk_eu.blank? + end + def accredited_provider return nil if course.accrediting_provider.blank? diff --git a/spec/components/find/courses/sumary_component/view_spec.rb b/spec/components/find/courses/sumary_component/view_spec.rb index 18dfcf99ff..5c64b93af6 100644 --- a/spec/components/find/courses/sumary_component/view_spec.rb +++ b/spec/components/find/courses/sumary_component/view_spec.rb @@ -135,6 +135,7 @@ module SummaryComponent result = render_inline(described_class.new(course)) expect(result.text).to include('UK students: £9,250') + expect(result.text).to include('Course fee') end end @@ -168,6 +169,18 @@ module SummaryComponent expect(result.text).to include('International students: £14,000') end end + + context 'when there are no fees' do + it 'does not render the row' do + course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: nil, fee_international: nil)]).decorate + + result = render_inline(described_class.new(course)) + + expect(result.text).not_to include('UK students') + expect(result.text).not_to include('International students: £14,000') + expect(result.text).not_to include('Course fee') + end + end end end end diff --git a/spec/components/find/results/search_result_component_spec.rb b/spec/components/find/results/search_result_component_spec.rb index 9d8bf4054c..6514b3bc29 100644 --- a/spec/components/find/results/search_result_component_spec.rb +++ b/spec/components/find/results/search_result_component_spec.rb @@ -104,6 +104,7 @@ module Find result = render_inline(described_class.new(course:)) expect(result.text).to include('UK students: £9,250') + expect(result.text).to include('Course fee') end end @@ -137,5 +138,17 @@ module Find expect(result.text).to include('International students: £14,000') end end + + context 'when there are no fees' do + it 'does not render the row' do + course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: nil, fee_international: nil)]).decorate + + result = render_inline(described_class.new(course:)) + + expect(result.text).not_to include('UK students') + expect(result.text).not_to include('International students: £14,000') + expect(result.text).not_to include('Course fee') + end + end end end