Skip to content

Commit 6d2dfbe

Browse files
committed
Specs: make click_icon resilient to intercepted clicks (scroll + JS click) and update admin docs to use Spree.admin_user_class
1 parent 6e7eaca commit 6d2dfbe

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

admin/docs/index_pages.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ class SolidusAdmin::UsersController < SolidusAdmin::BaseController
1616
include SolidusAdmin::ControllerHelpers::Search
1717

1818
def index
19-
users = apply_search_to(Spree.user_class.order(id: :desc), param: :q)
19+
users = apply_search_to(Spree.admin_user_class.order(id: :desc), param: :q)
2020
# ...
2121
```
2222

2323
For pagination support, the index action should also call the `set_page_and_extract_portion_from` method provided by the `geared_pagination` gem. This method sets the `@page` instance variable to the paginated collection and returns the portion of the collection to be displayed on the current page.
2424

2525
```ruby
2626
def index
27-
users = apply_search_to(Spree.user_class.order(id: :desc), param: :q)
27+
users = apply_search_to(Spree.admin_user_class.order(id: :desc), param: :q)
2828
set_page_and_extract_portion_from(users)
2929
# ...
3030
```
@@ -33,7 +33,7 @@ Finally, the index action should render the `index` component passing the `@page
3333

3434
```ruby
3535
def index
36-
users = apply_search_to(Spree.user_class.order(id: :desc), param: :q)
36+
users = apply_search_to(Spree.admin_user_class.order(id: :desc), param: :q)
3737
set_page_and_extract_portion_from(users)
3838
render component('users/index').new(page: @page)
3939
end
@@ -50,7 +50,7 @@ The index component requires only the `page` argument during initialization, all
5050
```ruby
5151
class SolidusAdmin::Users::Index < Solidus::Admin::UI::Pages::Index
5252
def model_class
53-
Spree.user_class
53+
Spree.admin_user_class
5454
end
5555
end
5656

@@ -92,7 +92,7 @@ end
9292
```ruby
9393
# in the controller
9494
def delete
95-
@users = Spree.user_class.where(id: params[:id])
95+
@users = Spree.admin_user_class.where(id: params[:id])
9696
@users.destroy_all
9797
flash[:notice] = "Admin users deleted"
9898
redirect_to solidus_admin.users_path, status: :see_other
@@ -124,7 +124,7 @@ module SolidusAdmin
124124
search_scope(:all)
125125

126126
def index
127-
users = apply_search_to(Spree.user_class.order(id: :desc), param: :q)
127+
users = apply_search_to(Spree.admin_user_class.order(id: :desc), param: :q)
128128
# ...
129129
```
130130

core/lib/spree/testing_support/capybara_ext.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ module Spree
44
module TestingSupport
55
module CapybaraExt
66
def click_icon(type)
7-
find(".fa-#{type}").click
7+
el = find(".fa-#{type}", visible: :all)
8+
el.click
9+
rescue Selenium::WebDriver::Error::ElementClickInterceptedError
10+
# When a floating element (eg. tooltips/overlays) intercepts the click,
11+
# scroll the target into view and dispatch a click via JS to keep tests stable.
12+
page.execute_script('arguments[0].scrollIntoView({block: "center"});', el.native)
13+
page.execute_script('arguments[0].click();', el.native)
814
end
915

1016
def eventually_fill_in(field, options = {})

0 commit comments

Comments
 (0)