-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
You can add collection filters to a dashboard and then use them in the search bar on the index page. eg. `email:[email protected]` However, these collection filters are not discoverable. You have to know about them already to know how to use them. This change introduces a tooltip which lists the available collection filters, allowing all users to discover what is available. Closes #2750
- Loading branch information
1 parent
2bd3037
commit 07bca42
Showing
5 changed files
with
68 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,49 @@ def have_a_search_bar | |
end | ||
end | ||
|
||
describe "search bar tooltip" do | ||
def have_a_search_tooltip | ||
have_css("button[popovertarget=search-tooltip]") | ||
end | ||
|
||
it "is visible when the current dashboard has collection filters" do | ||
visit admin_customers_path | ||
|
||
expect(page).to have_a_search_tooltip | ||
end | ||
|
||
context "when clicked" do | ||
it "shows a popover with the available filters" do | ||
visit admin_customers_path | ||
click_on "?" | ||
|
||
expect(page).to have_content("Use filters to refine your search:") | ||
expect(page).to have_content("vip:<value>") | ||
expect(page).to have_content("kind:<value>") | ||
end | ||
end | ||
|
||
it "is hidden when the current dashboard has no collection filters" do | ||
CustomerDashboard::COLLECTION_FILTERS = {}.freeze | ||
|
||
visit admin_customers_path | ||
|
||
expect(page).not_to have_a_search_tooltip | ||
end | ||
|
||
it "is hidden when nothing is searchable in the current dashboard" do | ||
CustomerDashboard::ATTRIBUTE_TYPES.each do |_name, field_class| | ||
allow(field_class).to( | ||
receive(:searchable?).and_return(false) | ||
) | ||
end | ||
|
||
visit admin_customers_path | ||
|
||
expect(page).not_to have_a_search_tooltip | ||
end | ||
end | ||
|
||
scenario "admin searches for customer by email", :js do | ||
query = "[email protected]" | ||
perfect_match = create(:customer, email: "[email protected]") | ||
|