Skip to content

Commit

Permalink
[#55392] feature spec for project list pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
EinLama committed Sep 20, 2024
1 parent fba16ed commit f5e1ecd
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<% end %>
<%= render(Primer::Alpha::Dialog::Footer.new) do %>
<%= render(Primer::ButtonComponent.new(data: { "close-dialog-id": MODAL_ID })) { I18n.t(:button_cancel) } %>
<%= render(Primer::ButtonComponent.new(scheme: :primary, type: :submit, form: QUERY_FORM_ID)) { I18n.t(:button_apply) } %>
<%= render(Primer::ButtonComponent.new(scheme: :primary,
type: :submit,
data: { "test-selector": "#{MODAL_ID}-submit"},
form: QUERY_FORM_ID)) { I18n.t(:button_apply) } %>
<% end %>
<% end %>
39 changes: 39 additions & 0 deletions spec/features/projects/projects_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,45 @@ def load_and_open_filters(user)
projects_page.expect_number_of_sort_fields(1)
end

it "resets the pagination when sorting (bug #55392)" do
# We need pagination, so reduce the page size to enable it
allow(Setting).to receive(:per_page_options_array).and_return([1, 5])
projects_page.set_page_size(1)
wait_for_reload
projects_page.expect_page_size(1)
projects_page.go_to_page(2) # Go to another page that is not the first one
wait_for_reload
projects_page.expect_current_page_number(2)

# Open config dialog and make changes to the sorting
projects_page.open_configure_view
projects_page.switch_configure_view_tab(I18n.t("label_sort"))
projects_page.within_sort_row(0) do
projects_page.change_sort_order(column_identifier: :name, direction: :desc)
end

# Save and close the dialog
projects_page.submit_config_view_dialog
wait_for_reload

# Changing the sorting resets the pagination to the first page
projects_page.expect_current_page_number(1)

# Go to another page again
projects_page.go_to_page(2)
wait_for_reload
projects_page.expect_current_page_number(2)

# Open dialog, do not change anything and save
projects_page.open_configure_view
projects_page.switch_configure_view_tab(I18n.t("label_sort"))
projects_page.submit_config_view_dialog
wait_for_reload

# An unchanged sorting will keep the current position in the pagination
projects_page.expect_current_page_number(2)
end

it "does not allow to sort via long text custom fields" do
long_text_custom_field = create(:text_project_custom_field)
Setting.enabled_projects_columns += [long_text_custom_field.column_name]
Expand Down
4 changes: 4 additions & 0 deletions spec/support/pages/projects/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ def within_sort_row(index, &)
within(field_component, &)
end

def submit_config_view_dialog
page.find('[data-test-selector="op-project-list-configure-dialog-submit"]').click
end

def within_table(&)
within "#project-table", &
end
Expand Down

0 comments on commit f5e1ecd

Please sign in to comment.