Skip to content

Commit

Permalink
Fix "search with a filter with arguments" spec
Browse files Browse the repository at this point in the history
The flake would happen when the second search of `kind:vip` was not
applied to the URL. Running the test directly in Chrome would show it
happening. As the URL parameter was never set, it was therefore blank.
Whilst a `sleep(0.1)` would fix it, this instead restructures the test
to avoid the problem completely.

Closes thoughtbot#2523
  • Loading branch information
CaleCrawford authored and nickcharlton committed May 14, 2024
1 parent 74369ae commit cff1129
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions spec/features/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,17 @@ def have_a_search_bar
end

scenario "admin searches with a filter with arguments", :js do
kind_match = create(:customer, kind: "vip", email: "vip@kind.com")
standard_match = create(:customer, kind: "standard", email: "me@kind.com")
no_match = create(:customer, kind: "vip", email: "standard@kind.com")
kind_match = create(:customer, kind: "vip", email: "standard@kind.com")
total_mismatch = create(:customer, kind: "standard", email: "me@kind.com")
kind_mismatch = create(:customer, kind: "standard", email: "vip@kind.com")

visit admin_customers_path
fill_in :search, with: "kind:standard"
submit_search

expect(page).to have_content(standard_match.email)
expect(page).not_to have_content(kind_match.email)
expect(page).not_to have_content(no_match.email)

clear_search
fill_in :search, with: "kind:vip"
submit_search

expect(page).not_to have_content(standard_match.email)
expect(page).to have_content(kind_match.email)
expect(page).not_to have_content(total_mismatch.email)
expect(page).not_to have_content(kind_mismatch.email)
end

scenario "admin searches with an a term similiar to a filter", :js do
Expand Down

0 comments on commit cff1129

Please sign in to comment.