Skip to content

Commit

Permalink
[#52147] make feature specs green
Browse files Browse the repository at this point in the history
  • Loading branch information
EinLama committed Oct 15, 2024
1 parent 7bd5edd commit df3fde6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
6 changes: 4 additions & 2 deletions spec/features/projects/persisted_lists_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@
projects_page.expect_no_sidebar_filter(another_users_projects_list.name)

# Sorts ASC by name
projects_page.sort_by_via_table_header("Name")
projects_page.click_table_header_to_open_action_menu("Name")
projects_page.sort_via_action_menu("Name", direction: :asc)

# Results should be filtered and ordered ASC by name and the user is still on the first page.
# Column is kept.
Expand All @@ -483,7 +484,8 @@

# Sorts DESC by name
# Soon, a save icon should be displayed then.
projects_page.sort_by_via_table_header("Name")
projects_page.click_table_header_to_open_action_menu("Name")
projects_page.sort_via_action_menu("Name", direction: :desc)

# The title is kept
projects_page.expect_title(my_projects_list.name)
Expand Down
24 changes: 16 additions & 8 deletions spec/features/projects/projects_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ def load_and_open_filters(user)
projects_page.expect_no_columns("Status")

# Sorts ASC by name
projects_page.sort_by_via_table_header("Name")
projects_page.click_table_header_to_open_action_menu("Name")
projects_page.sort_via_action_menu("Name", direction: :asc)
wait_for_reload
projects_page.expect_sort_order_via_table_header("Name", direction: :asc)

Expand Down Expand Up @@ -461,7 +462,8 @@ def load_and_open_filters(user)
projects_page.expect_total_pages(2) # Filters kept active, so there is no third page.

# Sorts DESC by name
projects_page.sort_by_via_table_header("Name")
projects_page.click_table_header_to_open_action_menu("Name")
projects_page.sort_via_action_menu("Name", direction: :desc)
wait_for_reload
projects_page.expect_sort_order_via_table_header("Name", direction: :desc)

Expand Down Expand Up @@ -646,12 +648,14 @@ def load_and_open_filters(user)
login_as(admin)
projects_page.visit!

click_link_or_button('Sort by "Status"')
projects_page.click_table_header_to_open_action_menu("project_status")
projects_page.sort_via_action_menu("project_status", direction: :asc)

projects_page.expect_project_at_place(green_project, 1)
expect(page).to have_text("(1 - 5/5)")

click_link_or_button('Ascending sorted by "Status"')
projects_page.click_table_header_to_open_action_menu("project_status")
projects_page.sort_via_action_menu("project_status", direction: :desc)

projects_page.expect_project_at_place(green_project, 5)
expect(page).to have_text("(1 - 5/5)")
Expand Down Expand Up @@ -1254,7 +1258,8 @@ def load_and_open_filters(user)
child_project_z,
public_project)

click_link_or_button("Name")
projects_page.click_table_header_to_open_action_menu("Name")
projects_page.sort_via_action_menu("Name", direction: :asc)
wait_for_reload

# Projects ordered by name asc
Expand All @@ -1266,7 +1271,8 @@ def load_and_open_filters(user)
public_project,
child_project_z)

click_link_or_button("Name")
projects_page.click_table_header_to_open_action_menu("Name")
projects_page.sort_via_action_menu("Name", direction: :desc)
wait_for_reload

# Projects ordered by name desc
Expand All @@ -1278,7 +1284,8 @@ def load_and_open_filters(user)
development_project,
child_project_a)

click_link_or_button(integer_custom_field.name)
projects_page.click_table_header_to_open_action_menu(integer_custom_field.column_name)
projects_page.sort_via_action_menu(integer_custom_field.column_name, direction: :asc)
wait_for_reload

# Projects ordered by cf asc first then project name desc
Expand All @@ -1304,7 +1311,8 @@ def load_and_open_filters(user)
end

it "sorts projects by latest_activity_at" do
click_link_or_button('Sort by "Latest activity at"')
projects_page.click_table_header_to_open_action_menu("latest_activity_at")
projects_page.sort_via_action_menu("latest_activity_at", direction: :asc)
wait_for_reload

projects_page.expect_project_at_place(project, 1)
Expand Down
12 changes: 9 additions & 3 deletions spec/support/pages/projects/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,20 @@ def delete_query
end
end

def sort_by_via_table_header(column_name)
find(".generic-table--sort-header a", text: column_name.upcase).click
def click_table_header_to_open_action_menu(column_name)
find(".generic-table--sort-header #menu-#{column_name.downcase}-button").click
end

def sort_via_action_menu(column_name, direction:)
raise ArgumentError, "direction should be :asc or :desc" unless %i[asc desc].include?(direction)

find(".generic-table--sort-header a[data-test-selector='#{column_name.downcase}-sort-#{direction}']").click
end

def expect_sort_order_via_table_header(column_name, direction:)
raise ArgumentError, "direction should be :asc or :desc" unless %i[asc desc].include?(direction)

find(".generic-table--sort-header .#{direction} a", text: column_name.upcase)
find(".generic-table--sort-header .#{direction} .Button-label", text: column_name.upcase)
end

def set_page_size(size)
Expand Down

0 comments on commit df3fde6

Please sign in to comment.