Skip to content

Commit 362cb8a

Browse files
committed
[#68936] Filter changes are not persisted when editing an existing project query
https://community.openproject.org/work_packages/68936
1 parent fbdae2d commit 362cb8a

File tree

5 files changed

+90
-7
lines changed

5 files changed

+90
-7
lines changed

app/components/projects/index_page_header_component.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,12 @@ def header_save_action(header:, message:, label:, href:, method: nil)
151151
mobile_icon: nil, # Do not show on mobile as it is already part of the menu
152152
mobile_label: nil,
153153
href:,
154+
target: "_self",
154155
data: {
155156
turbo_stream: true,
156157
turbo_method: method
157158
},
158-
target: ""
159+
test_selector: "header-save-button"
159160
) do
160161
render(
161162
Primer::Beta::Octicon.new(

spec/features/projects/persisted_lists_sharing_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127

128128
wait_for_reload
129129

130-
projects_index_page.expect_can_only_save_as_label
130+
projects_index_page.expect_save_as_label
131131
projects_index_page.save_query_as("Member-of and active list")
132132

133133
wait_for_network_idle
@@ -290,7 +290,7 @@
290290

291291
projects_index_page.open_filters
292292
projects_index_page.filter_by_active("yes")
293-
projects_index_page.expect_can_only_save_as_label
293+
projects_index_page.expect_save_as_label
294294
projects_index_page.save_query_as("Member-of and active list")
295295

296296
wait_for_network_idle

spec/features/projects/persisted_lists_spec.rb

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
projects_page.open_filters
255255
projects_page.filter_by_membership("yes")
256256

257-
wait_for_reload # chnaging filters is still done via page reload
257+
wait_for_reload # changing filters is still done via page reload
258258

259259
# Since the query is static, no save button an no menu item is shown
260260
projects_page.expect_no_notification("Save")
@@ -586,6 +586,71 @@
586586
end
587587
end
588588

589+
it "allows saving queries via the header save button" do
590+
projects_page.visit!
591+
projects_page.set_sidebar_filter("Active projects")
592+
593+
expect_angular_frontend_initialized
594+
595+
# Modify the query
596+
projects_page.open_filters
597+
projects_page.filter_by_membership("yes")
598+
599+
# The "Save as" button and label should be visible
600+
projects_page.expect_header_save_button
601+
projects_page.expect_save_as_label
602+
603+
# Save the query via the header save button and the inline form
604+
projects_page.save_query_via_header
605+
projects_page.fill_in_the_name("My filtered projects")
606+
projects_page.click_on "Save"
607+
608+
wait_for_network_idle
609+
610+
# The "Save as" button should not be visible after saving the query.
611+
projects_page.expect_no_header_save_button
612+
613+
# The new query should be saved and selected
614+
projects_page.expect_sidebar_filter("My filtered projects", selected: true)
615+
616+
# The filters should be stored
617+
projects_page.expect_filter_count(2)
618+
projects_page.expect_filter_set("active")
619+
projects_page.expect_filter_set("member_of")
620+
621+
# Modify the saved query and save it again
622+
projects_page.open_filters
623+
projects_page.set_filter(list_custom_field.column_name,
624+
list_custom_field.name,
625+
"is (OR)",
626+
[list_custom_field.possible_values.first.value])
627+
wait_for_reload
628+
629+
# The "Save" button and label should be visible
630+
projects_page.expect_header_save_button
631+
projects_page.expect_save_label
632+
633+
# Save the query
634+
projects_page.save_query_via_header
635+
wait_for_reload
636+
637+
# The "Save" button should not be visible after saving the query.
638+
projects_page.expect_no_header_save_button
639+
640+
# Reload the query and verify all filters were saved
641+
projects_page.set_sidebar_filter("Active projects")
642+
projects_page.set_sidebar_filter("My filtered projects")
643+
644+
# All filters should be stored
645+
projects_page.expect_filter_count(3)
646+
projects_page.expect_filter_set "member_of"
647+
projects_page.expect_filter_set "active"
648+
projects_page.expect_filter_set(
649+
list_custom_field.column_name,
650+
value: list_custom_field.possible_values.first.value
651+
)
652+
end
653+
589654
it "cannot access another user`s list" do
590655
visit projects_path(query_id: another_users_projects_list.id)
591656

spec/support/components/common/filters.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ def expect_filter_set(filter_name, value: nil)
4343
if filter_name == "name_and_identifier"
4444
expect(page.find_by_id(filter_name).value).not_to be_empty
4545
elsif value
46-
within("li[data-filter-name='#{filter_name}']:not(.hidden)", visible: :hidden) do
46+
within("li[data-filter-name='#{filter_name}']:not(.hidden)", visible: :all) do
4747
expect(page).to have_css(".advanced-filters--filter-value", text: value, visible: :all)
4848
end
4949
else
5050
expect(page)
51-
.to have_css("li[data-filter-name='#{filter_name}']:not(.hidden)", visible: :hidden)
51+
.to have_css("li[data-filter-name='#{filter_name}']:not(.hidden)", visible: :all)
5252
end
5353
end
5454

spec/support/pages/projects/index.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,19 @@ def save_query
351351
wait_for_network_idle
352352
end
353353

354+
def save_query_via_header
355+
page.find('[data-test-selector="header-save-button"]').click
356+
wait_for_network_idle
357+
end
358+
359+
def expect_header_save_button
360+
expect(page).to have_css('[data-test-selector="header-save-button"]')
361+
end
362+
363+
def expect_no_header_save_button
364+
expect(page).to have_no_css('[data-test-selector="header-save-button"]')
365+
end
366+
354367
def save_query_as(name)
355368
click_more_menu_item("Save as")
356369

@@ -359,10 +372,14 @@ def save_query_as(name)
359372
click_on "Save"
360373
end
361374

362-
def expect_can_only_save_as_label
375+
def expect_save_as_label
363376
expect(page).to have_text(I18n.t("lists.can_be_saved_as"))
364377
end
365378

379+
def expect_save_label
380+
expect(page).to have_text(I18n.t("lists.can_be_saved"))
381+
end
382+
366383
def fill_in_the_name(name)
367384
within '[data-test-selector="project-query-name"]' do
368385
fill_in "Name", with: name

0 commit comments

Comments
 (0)