Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #38001 - Basic test for table sortings #10373

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/roles/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<tr>
<th class="col-md-2"><%= sort :name, :as => s_("Role|Name") %></th>
<th class="col-md-8"><%= sort :description, :as => s_("Role|Description") %></th>
<th class="col-md-1"><%= sort :locked, :as => s_("Role|Locked"), :default => "DESC" %></th>
<th class="col-md-1"><%= s_("Role|Locked") %></th>
<th><%= _('Actions') %></th>
</tr>
</thead>
Expand Down
26 changes: 26 additions & 0 deletions test/integration_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,32 @@ def assert_index_page(index_path, title_text, new_link_text = nil, has_search =
assert_breadcrumb_text(title_text)
(assert first(:link, new_link_text).visible?, "#{new_link_text} is not visible") if new_link_text
(assert find('.autocomplete-search button').visible?, "Search button is not visible") if has_search
assert_sortable_table index_path
end

def assert_sortable_table(index_path)
visit index_path
if page.has_selector?('table')
if page.has_selector?(:css, ".pf-c-table")
th_with_sort = "//th/button"
else
th_with_sort = "//th/a"
end
len = page.all(:xpath, th_with_sort).length
(0..len - 1).each do |i|
th = page.all(:xpath, th_with_sort)[i]
th_text = th.text
th.click
sort_by = page.all(:xpath, th_with_sort)[i]
assert(
sort_by[:class].include?('ascending') ||
sort_by[:class].include?('descending') ||
sort_by["aria-sort"] == 'ascending' ||
sort_by["aria-sort"] == 'descending',
"sort by #{th_text} does not have 'ascending' or 'descending' class"
)
end
end
end

def assert_breadcrumb_text(text)
Expand Down
Loading