Skip to content

Commit

Permalink
Change show only brexit results to show only transition period results
Browse files Browse the repository at this point in the history
A checkbox that appears in the news and communciations finder
  • Loading branch information
huwd committed Feb 3, 2020
1 parent a25e1f3 commit 324d96e
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
10 changes: 5 additions & 5 deletions features/finders.feature
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,13 @@ Feature: Filtering documents
Then the page has a landmark to the search results
And the page has a landmark to the search filters

Scenario: "Show only Brexit results" checkbox is removed if the topic parameter is set to the Brexit Topic.
When I view the news and communications finder filtered on the brexit topic
Then I cannot see the "show only brexit results" checkbox
Scenario: "Show only transition period results" checkbox is removed if the topic parameter is set to the transition period topic.
When I view the news and communications finder filtered on the transition topic
Then I cannot see the "show only transition period results" checkbox

Scenario: "Show only Brexit results" checkbox is shown if no topic parameter is set
Scenario: "Show only transition period results" checkbox is shown if no topic parameter is set
When I view the news and communications finder
Then I can see the "show only brexit results" checkbox
Then I can see the "show only transition period results" checkbox

Scenario: Email links
When I view the news and communications finder
Expand Down
6 changes: 3 additions & 3 deletions features/fixtures/news_and_communications.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@
"preposition": "about"
},
{
"key": "related_to_brexit",
"key": "related_to_transition_period",
"filter_key": "all_part_of_taxonomy_tree",
"filter_value": "d6c2de5d-ef90-45d1-82d4-5f2438369eea",
"name": "Show only Brexit results",
"short_name": "Brexit",
"name": "Show only transition period results",
"short_name": "transition period",
"type": "checkbox",
"display_as_result_metadata": false,
"filterable": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"facet_name": "topics"
},
{
"facet_id": "related_to_brexit",
"facet_id": "related_to_transition_period",
"filter_key": "all_part_of_taxonomy_tree",
"filter_value": "d6c2de5d-ef90-45d1-82d4-5f2438369eea",
"facet_name": "topics"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@
"preposition": "about"
},
{
"key": "related_to_brexit",
"key": "related_to_transition_period",
"filter_key": "all_part_of_taxonomy_tree",
"filter_value": "d6c2de5d-ef90-45d1-82d4-5f2438369eea",
"name": "Show only Brexit results",
"short_name": "Brexit",
"name": "Show only transition period results",
"short_name": "transition period",
"type": "checkbox",
"display_as_result_metadata": false,
"filterable": true,
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/filtering_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
end

Then(/^I (can|cannot) see the "show only brexit results" checkbox$/) do |can_or_cannot|
have_clause = have_css(".govuk-checkboxes__label", text: "Show only Brexit results")
have_clause = have_css(".govuk-checkboxes__label", text: "Show only transition period results")
if can_or_cannot == "can"
expect(page).to have_clause
else
Expand Down
6 changes: 3 additions & 3 deletions lib/facets_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ def filters_on_brexit_topic?
@value_hash["topic"] == ContentItem::BREXIT_CONTENT_ID
end

def is_related_to_brexit_checkbox?(facet_hash)
facet_hash["key"] == "related_to_brexit" && facet_hash["filter_value"] == ContentItem::BREXIT_CONTENT_ID
def is_related_to_transition_period_checkbox?(facet_hash)
facet_hash["key"] == "related_to_transition_period" && facet_hash["filter_value"] == ContentItem::BREXIT_CONTENT_ID
end

def facet_hashes
all_facet_hashes = FacetExtractor.new(content_item).extract
if filters_on_brexit_topic?
all_facet_hashes.reject { |facet_hash| is_related_to_brexit_checkbox?(facet_hash) }
all_facet_hashes.reject { |facet_hash| is_related_to_transition_period_checkbox?(facet_hash) }
else
all_facet_hashes
end
Expand Down
8 changes: 4 additions & 4 deletions spec/javascripts/modules/remove-filter-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('remove-filter', function () {
var removeFilter
var $checkbox = $(
'<div data-module="remove-filter">' +
'<button href="/search/news-and-communications" class="remove-filter" role="button" aria-label="Remove filter Brexit" data-module="remove-filter-link" data-facet="related_to_brexit" data-value="true" data-track-label="Brexit" data-name="">✕</button>' +
'<button href="/search/news-and-communications" class="remove-filter" role="button" aria-label="Remove filter transition period" data-module="remove-filter-link" data-facet="related_to_transition_period" data-value="true" data-track-label="transition period" data-name="">✕</button>' +
'</div>')

var $oneTextQuery = $(
Expand Down Expand Up @@ -66,8 +66,8 @@ describe('remove-filter', function () {
'<div>' +
'<input name="public_timestamp[from]" value="" id="public_timestamp[from]" type="text">' +
'</div>' +
'<div id="related_to_brexit">' +
'<input type="checkbox" name="related_to_brexit" value="true" data-module="track-click">' +
'<div id="related_to_transition_period">' +
'<input type="checkbox" name="related_to_transition_period" value="true" data-module="track-click">' +
'</div>'

beforeEach(function () {
Expand All @@ -81,7 +81,7 @@ describe('remove-filter', function () {
})

it('deselects a selected checkbox', function (done) {
var checkbox = $('input[name=related_to_brexit]')[0]
var checkbox = $('input[name=related_to_transition_period]')[0]
checkbox.checked = true
removeFilter.start($checkbox)

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/email_alert_title_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
{ "facet_id" => "world_locations", "facet_name" => "world locations" },
{ "facet_id" => "level_one_taxon", "filter_key" => "part_of_taxonomy_tree", "facet_name" => "topics" },
{ "facet_id" => "level_two_taxon", "filter_key" => "part_of_taxonomy_tree", "facet_name" => "topics" },
{ "facet_id" => "related_to_brexit", "filter_key" => "part_of_taxonomy_tree", "filter_value" => "d6c2de5d-ef90-45d1-82d4-5f2438369eea", "facet_name" => "topics" },
{ "facet_id" => "related_to_transition_period", "filter_key" => "part_of_taxonomy_tree", "filter_value" => "d6c2de5d-ef90-45d1-82d4-5f2438369eea", "facet_name" => "topics" },
{ "facet_id" => "document_type", "facet_name" => "document types" },
]
end
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/facets_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@
"allowed_values": [{ "value" => "my_manual" }],
}
}
let(:related_to_brexit_facet_hash) {
let(:related_to_transition_period_facet_hash) {
{
"key": "related_to_brexit",
"key": "related_to_transition_period",
"filter_key": "all_part_of_taxonomy_tree",
"filter_value": "d6c2de5d-ef90-45d1-82d4-5f2438369eea",
"name": "Show only Brexit results",
"name": "Show only transition period results",
"type": "checkbox",
"filterable": true,
}
Expand Down Expand Up @@ -117,7 +117,7 @@
taxon_facet_hash,
checkbox_facet_hash,
radio_facet_hash,
related_to_brexit_facet_hash,
related_to_transition_period_facet_hash,
],
},
}
Expand All @@ -129,17 +129,17 @@
}
}
it "contains no related to brexit taxon" do
expect(facets).to_not include(an_object_satisfying { |facet| facet.key == "related_to_brexit" })
expect(facets).to_not include(an_object_satisfying { |facet| facet.key == "related_to_transition_period" })
end
end
context "The page is not filtered on the brexit topic" do
let(:value_hash) {
{
related_to_brexit: ContentItem::BREXIT_CONTENT_ID,
related_to_transition_period: ContentItem::BREXIT_CONTENT_ID,
}
}
it "contains a related to brexit taxon" do
expect(facets).to include(an_object_satisfying { |facet| facet.key == "related_to_brexit" })
expect(facets).to include(an_object_satisfying { |facet| facet.key == "related_to_transition_period" })
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/presenters/subscriber_list_params_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"organisations" => %w[academy-for-social-justice-commissioning accelerated-access-review],
"people" => %w[sir-philip-jones mark-stanhope],
"level_one_taxon" => %w[c58fdadd-7743-46d6-9629-90bb3ccc4ef0],
"related_to_brexit" => "true",
"related_to_transition_period" => "true",
}

presenter = described_class.new(signup_finder, params)
Expand Down

0 comments on commit 324d96e

Please sign in to comment.