[#68936] Filter changes are not persisted when editing an existing project query

https://community.openproject.org/work_packages/68936
This commit is contained in:
Dombi Attila
2025-12-08 23:40:54 +02:00
parent fbdae2d998
commit 362cb8abca
5 changed files with 90 additions and 7 deletions
@@ -151,11 +151,12 @@ class Projects::IndexPageHeaderComponent < ApplicationComponent
mobile_icon: nil, # Do not show on mobile as it is already part of the menu
mobile_label: nil,
href:,
target: "_self",
data: {
turbo_stream: true,
turbo_method: method
},
target: ""
test_selector: "header-save-button"
) do
render(
Primer::Beta::Octicon.new(
@@ -127,7 +127,7 @@ RSpec.describe "Project list sharing",
wait_for_reload
projects_index_page.expect_can_only_save_as_label
projects_index_page.expect_save_as_label
projects_index_page.save_query_as("Member-of and active list")
wait_for_network_idle
@@ -290,7 +290,7 @@ RSpec.describe "Project list sharing",
projects_index_page.open_filters
projects_index_page.filter_by_active("yes")
projects_index_page.expect_can_only_save_as_label
projects_index_page.expect_save_as_label
projects_index_page.save_query_as("Member-of and active list")
wait_for_network_idle
+66 -1
View File
@@ -254,7 +254,7 @@ RSpec.describe "Persisted lists on projects index page",
projects_page.open_filters
projects_page.filter_by_membership("yes")
wait_for_reload # chnaging filters is still done via page reload
wait_for_reload # changing filters is still done via page reload
# Since the query is static, no save button an no menu item is shown
projects_page.expect_no_notification("Save")
@@ -586,6 +586,71 @@ RSpec.describe "Persisted lists on projects index page",
end
end
it "allows saving queries via the header save button" do
projects_page.visit!
projects_page.set_sidebar_filter("Active projects")
expect_angular_frontend_initialized
# Modify the query
projects_page.open_filters
projects_page.filter_by_membership("yes")
# The "Save as" button and label should be visible
projects_page.expect_header_save_button
projects_page.expect_save_as_label
# Save the query via the header save button and the inline form
projects_page.save_query_via_header
projects_page.fill_in_the_name("My filtered projects")
projects_page.click_on "Save"
wait_for_network_idle
# The "Save as" button should not be visible after saving the query.
projects_page.expect_no_header_save_button
# The new query should be saved and selected
projects_page.expect_sidebar_filter("My filtered projects", selected: true)
# The filters should be stored
projects_page.expect_filter_count(2)
projects_page.expect_filter_set("active")
projects_page.expect_filter_set("member_of")
# Modify the saved query and save it again
projects_page.open_filters
projects_page.set_filter(list_custom_field.column_name,
list_custom_field.name,
"is (OR)",
[list_custom_field.possible_values.first.value])
wait_for_reload
# The "Save" button and label should be visible
projects_page.expect_header_save_button
projects_page.expect_save_label
# Save the query
projects_page.save_query_via_header
wait_for_reload
# The "Save" button should not be visible after saving the query.
projects_page.expect_no_header_save_button
# Reload the query and verify all filters were saved
projects_page.set_sidebar_filter("Active projects")
projects_page.set_sidebar_filter("My filtered projects")
# All filters should be stored
projects_page.expect_filter_count(3)
projects_page.expect_filter_set "member_of"
projects_page.expect_filter_set "active"
projects_page.expect_filter_set(
list_custom_field.column_name,
value: list_custom_field.possible_values.first.value
)
end
it "cannot access another user`s list" do
visit projects_path(query_id: another_users_projects_list.id)
+2 -2
View File
@@ -43,12 +43,12 @@ module Components
if filter_name == "name_and_identifier"
expect(page.find_by_id(filter_name).value).not_to be_empty
elsif value
within("li[data-filter-name='#{filter_name}']:not(.hidden)", visible: :hidden) do
within("li[data-filter-name='#{filter_name}']:not(.hidden)", visible: :all) do
expect(page).to have_css(".advanced-filters--filter-value", text: value, visible: :all)
end
else
expect(page)
.to have_css("li[data-filter-name='#{filter_name}']:not(.hidden)", visible: :hidden)
.to have_css("li[data-filter-name='#{filter_name}']:not(.hidden)", visible: :all)
end
end
+18 -1
View File
@@ -351,6 +351,19 @@ module Pages
wait_for_network_idle
end
def save_query_via_header
page.find('[data-test-selector="header-save-button"]').click
wait_for_network_idle
end
def expect_header_save_button
expect(page).to have_css('[data-test-selector="header-save-button"]')
end
def expect_no_header_save_button
expect(page).to have_no_css('[data-test-selector="header-save-button"]')
end
def save_query_as(name)
click_more_menu_item("Save as")
@@ -359,10 +372,14 @@ module Pages
click_on "Save"
end
def expect_can_only_save_as_label
def expect_save_as_label
expect(page).to have_text(I18n.t("lists.can_be_saved_as"))
end
def expect_save_label
expect(page).to have_text(I18n.t("lists.can_be_saved"))
end
def fill_in_the_name(name)
within '[data-test-selector="project-query-name"]' do
fill_in "Name", with: name