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

Filters presenter: Use visually_hidden_prefix from facet #3519

Merged
merged 1 commit into from
Oct 18, 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
2 changes: 1 addition & 1 deletion app/presenters/filters_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def summary_items
value: filter[:label],
displayed_text: "#{filter[:name]}: #{filter[:label]}",
remove_href: finder_url_builder.url_except(filter[:query_params]),
visually_hidden_prefix: "Remove filter",
visually_hidden_prefix: filter[:visually_hidden_prefix] || "Remove filter",
}
end
end
Expand Down
35 changes: 27 additions & 8 deletions spec/presenters/filters_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
"Facet",
key: "facet_with_applied_filters",
has_filters?: true,
applied_filters: [{ name: "name", label: "label", query_params: { key: %w[value] } }],
applied_filters: [
{ name: "name", label: "label", query_params: { key: %w[value] } },
{
name: "name2",
label: "label2",
visually_hidden_prefix: "Get rid of",
query_params: { key2: %w[value2] },
},
],
)
end
let(:another_facet_with_applied_filters) do
Expand Down Expand Up @@ -111,16 +119,27 @@
before do
allow(finder_url_builder).to receive(:url_except).with({ key: %w[value] })
.and_return("/search/foo")
allow(finder_url_builder).to receive(:url_except).with({ key2: %w[value2] })
.and_return("/search/foo2")
end

it "returns the expected summary items" do
expect(summary_items).to contain_exactly({
label: "name",
value: "label",
displayed_text: "name: label",
remove_href: "/search/foo",
visually_hidden_prefix: "Remove filter",
})
expect(summary_items).to contain_exactly(
{
label: "name",
value: "label",
displayed_text: "name: label",
remove_href: "/search/foo",
visually_hidden_prefix: "Remove filter",
},
{
label: "name2",
value: "label2",
displayed_text: "name2: label2",
remove_href: "/search/foo2",
visually_hidden_prefix: "Get rid of",
},
)
end
end
end
Expand Down
Loading