From df3fde65c8c7132060a954e6515cf51a88102cce Mon Sep 17 00:00:00 2001 From: Tobias Dillmann Date: Tue, 15 Oct 2024 16:34:50 +0200 Subject: [PATCH] [#52147] make feature specs green --- .../features/projects/persisted_lists_spec.rb | 6 +++-- spec/features/projects/projects_index_spec.rb | 24 ++++++++++++------- spec/support/pages/projects/index.rb | 12 +++++++--- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/spec/features/projects/persisted_lists_spec.rb b/spec/features/projects/persisted_lists_spec.rb index dcf5574875c7..233304fe7f9c 100644 --- a/spec/features/projects/persisted_lists_spec.rb +++ b/spec/features/projects/persisted_lists_spec.rb @@ -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. @@ -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) diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb index 886d00deb450..b0bbfa035cb7 100644 --- a/spec/features/projects/projects_index_spec.rb +++ b/spec/features/projects/projects_index_spec.rb @@ -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) @@ -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) @@ -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)") @@ -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 @@ -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 @@ -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 @@ -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) diff --git a/spec/support/pages/projects/index.rb b/spec/support/pages/projects/index.rb index d83f6f04ac43..465a71cb2490 100644 --- a/spec/support/pages/projects/index.rb +++ b/spec/support/pages/projects/index.rb @@ -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)