Skip to content

Commit

Permalink
Merge pull request #9615 from alphagov/content-modelling/692-filter-b…
Browse files Browse the repository at this point in the history
…ehaviour

content-modelling/ changing default configuration of search filters
  • Loading branch information
Harriethw authored Nov 14, 2024
2 parents eeca7e1 + 84cb9c9 commit 73c0d16
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
),
},
expanded: @filters&.fetch(:keyword, nil).present?,
expanded: true,
},
{
heading: {
Expand All @@ -39,7 +39,7 @@
}
),
},
expanded: @filters&.fetch(:block_type, nil).present?,
expanded: true,
},
{
heading: {
Expand All @@ -55,7 +55,7 @@
}
),
},
expanded: @filters&.fetch(:lead_organisation, nil).present?,
expanded: true,
},
],
} %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ def session_filters
end

def default_filters
{ lead_organisation: current_user.organisation.try(:id) || "" }
{ lead_organisation: "" }
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ Feature: Search for a content object

Scenario: GDS Editor can filter by organisation
When I visit the Content Block Manager home page
Then my organisation is already selected as a filter
And I should see the details for all documents from my organisation
When I select the lead organisation "All organisations"
Then 'all organisations' is already selected as a filter
And "3" content blocks are returned in total
When I select the lead organisation "Department of Placeholder"
And I click to view results
Then "3" content blocks are returned in total
Then I should see the details for all documents from my organisation

Scenario: GDS Editor searches for a content object by keyword in instructions to publishers
When I visit the Content Block Manager home page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@
end
end

Then("my organisation is already selected as a filter") do
expect(page).to have_field("Lead organisation", with: @user.organisation.id)
Then("'all organisations' is already selected as a filter") do
expect(page).to have_field("Lead organisation", with: "")
end

Then("I should see the details for all documents from my organisation") do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class ContentBlockManager::ContentBlock::Document::Index::FilterOptionsComponent
ContentBlockManager::ContentBlock::Schema.stubs(:valid_schemas).returns(%w[email_address postal_address])
end

it "collapses all sections by default" do
it "expands all sections by default" do
render_inline(
ContentBlockManager::ContentBlock::Document::Index::FilterOptionsComponent.new(
filters: {},
),
)
assert_selector ".govuk-accordion__section--expanded", count: 0
assert_selector ".govuk-accordion__section--expanded", count: 3
end

it "adds value of keyword to text input from filter" do
Expand All @@ -34,7 +34,6 @@ class ContentBlockManager::ContentBlock::Document::Index::FilterOptionsComponent
),
)

assert_selector ".govuk-accordion__section--expanded", count: 1
assert_selector ".govuk-accordion__section--expanded", text: "Keyword"
assert_selector "input[name='keyword'][value='ministry defense']"
end
Expand All @@ -57,7 +56,6 @@ class ContentBlockManager::ContentBlock::Document::Index::FilterOptionsComponent
),
)

assert_selector ".govuk-accordion__section--expanded", count: 1
assert_selector ".govuk-accordion__section--expanded", text: "Content block type"

assert_selector "input[type='checkbox'][name='block_type[]'][value='email_address'][checked]"
Expand All @@ -78,7 +76,6 @@ class ContentBlockManager::ContentBlock::Document::Index::FilterOptionsComponent
),
)

assert_selector ".govuk-accordion__section--expanded", count: 1
assert_selector ".govuk-accordion__section--expanded", text: "Lead organisation"

assert_selector "select[name='lead_organisation']"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class ContentBlockManager::ContentBlock::DocumentsTest < ActionDispatch::Integra

describe "when no filter params are specified" do
describe "when there are no session filters" do
it "adds the users organisation as the lead organisation by default" do
it "sets the filter to 'all organisations' by default" do
visit content_block_manager.content_block_manager_content_block_documents_path

assert_current_path content_block_manager.content_block_manager_root_path({ lead_organisation: @organisation.id.to_s })
assert_current_path content_block_manager.content_block_manager_root_path({ lead_organisation: "" })
end
end

Expand All @@ -76,7 +76,7 @@ class ContentBlockManager::ContentBlock::DocumentsTest < ActionDispatch::Integra
it "resets the filters when reset_fields is set" do
visit content_block_manager.content_block_manager_content_block_documents_path({ reset_fields: true })

assert_current_path content_block_manager.content_block_manager_root_path({ lead_organisation: @organisation.id.to_s })
assert_current_path content_block_manager.content_block_manager_root_path({ lead_organisation: "" })
end
end
end
Expand Down

0 comments on commit 73c0d16

Please sign in to comment.