diff --git a/test/controllers/searches_controller_test.rb b/test/controllers/searches_controller_test.rb
index 0cc0bceee..12c191567 100644
--- a/test/controllers/searches_controller_test.rb
+++ b/test/controllers/searches_controller_test.rb
@@ -5,9 +5,11 @@ class SearchesControllerTest < ActionDispatch::IntegrationTest
setup do
@board.update!(all_access: true)
- @card = @board.cards.create!(title: "Layout is broken", creator: @user)
+ @card = @board.cards.create!(title: "Layout is broken", description: "Look at this mess.", creator: @user)
@comment_card = @board.cards.create!(title: "Some card", creator: @user)
@comment_card.comments.create!(body: "overflowing text issue", creator: @user)
+ @comment2_card = @board.cards.create!(title: "Just haggis", description: "More haggis", creator: @user)
+ @comment2_card.comments.create!(body: "I love haggis", creator: @user)
untenanted { sign_in_as @user }
end
@@ -15,11 +17,19 @@ class SearchesControllerTest < ActionDispatch::IntegrationTest
test "search" do
# Searching by card title
get search_path(q: "broken", script_name: "/#{@account.external_account_id}")
- assert_select "li", text: /Layout is broken/
+ assert_select "li .search__title", text: /Layout is broken/
+ assert_select "li .search__excerpt", text: /Look at this mess/
# Searching by comment
get search_path(q: "overflowing", script_name: "/#{@account.external_account_id}")
- assert_select "li", text: /Some card/
+ assert_select "li .search__title", text: /Some card/
+ assert_select "li .search__excerpt--comment", text: /overflowing text issue/
+
+ # Searching for a term that appears in a card and in a comment
+ get search_path(q: "haggis", script_name: "/#{@account.external_account_id}")
+ assert_select "li .search__title", text: /Just haggis/, count: 2 # card title shows up in two entries
+ assert_select "li .search__excerpt", text: /More haggis/ # one entry for the card description
+ assert_select "li .search__excerpt--comment", text: /I love haggis/ # one entry for the comment
# Searching by card id
get search_path(q: @card.id, script_name: "/#{@account.external_account_id}")