Skip to content

Commit

Permalink
Merge pull request #3498 from alphagov/full-res-dec
Browse files Browse the repository at this point in the history
All content finder: Use full size result description
  • Loading branch information
csutter authored Oct 11, 2024
2 parents 13f8331 + 7613b8e commit 1496586
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/presenters/result_set_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def document_list_component_data(documents_to_convert:)
content_item:,
debug_score:,
include_ecommerce:,
full_size_description: content_item.all_content_finder?,
).document_list_component_data
end
end
Expand Down
6 changes: 4 additions & 2 deletions app/presenters/search_result_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SearchResultPresenter
:original_rank,
to: :document

def initialize(document:, rank:, metadata_presenter_class:, doc_count:, facets:, content_item:, debug_score:, result_number:, include_ecommerce: true)
def initialize(document:, rank:, metadata_presenter_class:, doc_count:, facets:, content_item:, debug_score:, result_number:, include_ecommerce: true, full_size_description: false)
@document = document
@rank = rank
@metadata = metadata_presenter_class.new(document.metadata(facets)).present
Expand All @@ -23,6 +23,7 @@ def initialize(document:, rank:, metadata_presenter_class:, doc_count:, facets:,
@result_number = result_number
@content_item = content_item
@include_ecommerce = include_ecommerce
@full_size_description = full_size_description
end

def document_list_component_data
Expand All @@ -31,6 +32,7 @@ def document_list_component_data
text: title,
path: link,
description: sanitize(summary_text),
full_size_description:,
data_attributes: ga4_ecommerce_data(link),
},
metadata: structure_metadata,
Expand Down Expand Up @@ -110,5 +112,5 @@ def ga4_ecommerce_data(path)
}
end

attr_reader :document, :metadata, :content_item, :result_number
attr_reader :document, :metadata, :content_item, :result_number, :full_size_description
end
11 changes: 11 additions & 0 deletions spec/presenters/result_set_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
text: "document_title",
path: "/path/to/doc",
description: "document_description",
full_size_description: false,
data_attributes: {
ga4_ecommerce_path: "/path/to/doc",
ga4_ecommerce_content_id: "content_id",
Expand All @@ -158,6 +159,16 @@
search_result_objects = subject.search_results_content[:document_list_component_data]
expect(search_result_objects.first).to eql(expected_hash)
end

context "on the all content finder" do
before do
allow(content_item).to receive(:all_content_finder?).and_return(true)
end

it "shows the full size description" do
expect(subject.search_results_content[:document_list_component_data].first[:link][:full_size_description]).to be true
end
end
end

context "with &debug_score=1" do
Expand Down
11 changes: 11 additions & 0 deletions spec/presenters/search_result_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
content_item:,
facets:,
debug_score:,
full_size_description:,
)
end

Expand Down Expand Up @@ -50,6 +51,7 @@
let(:description) { "I am a document. I am full of words and that." }
let(:content_id) { "content_id" }
let(:show_summaries) { true }
let(:full_size_description) { false }

let(:facets) { [] }

Expand All @@ -63,6 +65,7 @@
text: title,
path: link,
description: "I am a document. I am full of words and that.",
full_size_description: false,
data_attributes: {
ga4_ecommerce_path: link,
ga4_ecommerce_content_id: "content_id",
Expand Down Expand Up @@ -155,6 +158,14 @@
end
end
end

context "with full size description" do
let(:full_size_description) { true }

it "returns link items with the full_size_description attribute set to true" do
expect(subject.document_list_component_data[:link][:full_size_description]).to be(true)
end
end
end

describe "structure_metadata" do
Expand Down

0 comments on commit 1496586

Please sign in to comment.