Skip to content

Commit d70f37e

Browse files
authored
Fix "search with a filter with arguments" spec (#2581)
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 #2523
1 parent 2b554b3 commit d70f37e

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

spec/features/search_spec.rb

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,17 @@ def have_a_search_bar
8686
end
8787

8888
scenario "admin searches with a filter with arguments", :js do
89-
kind_match = create(:customer, kind: "vip", email: "vip@kind.com")
90-
standard_match = create(:customer, kind: "standard", email: "[email protected]")
91-
no_match = create(:customer, kind: "vip", email: "standard@kind.com")
89+
kind_match = create(:customer, kind: "vip", email: "standard@kind.com")
90+
total_mismatch = create(:customer, kind: "standard", email: "[email protected]")
91+
kind_mismatch = create(:customer, kind: "standard", email: "vip@kind.com")
9292

9393
visit admin_customers_path
94-
fill_in :search, with: "kind:standard"
95-
submit_search
96-
97-
expect(page).to have_content(standard_match.email)
98-
expect(page).not_to have_content(kind_match.email)
99-
expect(page).not_to have_content(no_match.email)
100-
101-
clear_search
10294
fill_in :search, with: "kind:vip"
10395
submit_search
10496

105-
expect(page).not_to have_content(standard_match.email)
10697
expect(page).to have_content(kind_match.email)
98+
expect(page).not_to have_content(total_mismatch.email)
99+
expect(page).not_to have_content(kind_mismatch.email)
107100
end
108101

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

0 commit comments

Comments
 (0)