Commit 3317c4ba authored by Mark Lapierre's avatar Mark Lapierre

Don't check for the groups list before filtering

Filter immediately because the page is going to reload anyway.

And don't check for the loading indicator because it the groups
list tree container appears after it disappears.
parent 8589fa87
.js-groups-list-holder .js-groups-list-holder
#js-groups-tree{ data: { hide_projects: 'true', endpoint: dashboard_groups_path(format: :json), path: dashboard_groups_path, form_sel: 'form#group-filter-form', filter_sel: '.js-groups-list-filter', holder_sel: '.js-groups-list-holder', dropdown_sel: '.js-group-filter-dropdown-wrap' } } #js-groups-tree{ data: { hide_projects: 'true', endpoint: dashboard_groups_path(format: :json), path: dashboard_groups_path, form_sel: 'form#group-filter-form', filter_sel: '.js-groups-list-filter', holder_sel: '.js-groups-list-holder', dropdown_sel: '.js-group-filter-dropdown-wrap' } }
.loading-container.text-center .loading-container.text-center
= icon('spinner spin 2x', class: 'loading-animation prepend-top-20 qa-loading-animation') = icon('spinner spin 2x', class: 'loading-animation prepend-top-20')
.group-empty-state.row.align-items-center.justify-content-center.qa-groups-empty-state .group-empty-state.row.align-items-center.justify-content-center
.icon.text-center.order-md-2 .icon.text-center.order-md-2
= custom_icon("icon_empty_groups") = custom_icon("icon_empty_groups")
......
...@@ -9,52 +9,26 @@ module QA ...@@ -9,52 +9,26 @@ module QA
element :groups_filter element :groups_filter
end end
base.view 'app/views/shared/groups/_empty_state.html.haml' do
element :groups_empty_state
end
base.view 'app/assets/javascripts/groups/components/groups.vue' do base.view 'app/assets/javascripts/groups/components/groups.vue' do
element :groups_list_tree_container element :groups_list_tree_container
end end
base.view 'app/views/dashboard/groups/_groups.html.haml' do
element :loading_animation
end
end end
private private
# Filter the list of groups/projects by name
# If submit is true the return key will be sent to the browser to reload
# the page and fetch only the filtered results
def filter_by_name(name, submit: false)
wait(reload: false) do
# Wait 0 for the empty state element because it is there immediately
# if there are no groups. Otherwise there's a loading indicator and
# then groups_list_tree_container appears, which might take longer
page.has_css?(element_selector_css(:groups_empty_state), wait: 0) ||
page.has_css?(element_selector_css(:groups_list_tree_container))
end
field = find_element :groups_filter
field.set(name)
field.send_keys(:return) if submit
end
def has_filtered_group?(name) def has_filtered_group?(name)
# Filter and submit to reload the page and only retrieve the filtered results # Filter and submit to reload the page and only retrieve the filtered results
filter_by_name(name, submit: true) find_element(:groups_filter).set(name).send_keys(:return)
# Since we submitted after filtering the absence of the loading # Since we submitted after filtering, the presence of
# animation and the presence of groups_list_tree_container means we # groups_list_tree_container means we have the complete filtered list
# have the complete filtered list of groups # of groups
wait(reload: false) do wait(reload: false) do
page.has_no_css?(element_selector_css(:loading_animation)) &&
page.has_css?(element_selector_css(:groups_list_tree_container)) page.has_css?(element_selector_css(:groups_list_tree_container))
end end
# If there are no groups we'll know immediately because we filtered the list # If there are no groups we'll know immediately because we filtered the list
return if page.has_text?(/No groups or projects matched your search/, wait: 0) return false if page.has_text?('No groups or projects matched your search', wait: 0)
# The name will be present as filter input so we check for a link, not text # The name will be present as filter input so we check for a link, not text
page.has_link?(name, wait: 0) page.has_link?(name, wait: 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment