Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#61940] Work package exports also shows sub-project despite excluded

as-op966973f8dbf5
diff --git a/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.spec.ts b/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.spec.ts
index 2ddd14d40e3..0b73a71031f 100644
--- a/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.spec.ts
+++ b/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.spec.ts
@@ -40,6 +40,7 @@ describe('UrlParamsHelper', () => {
const params = {
ids: [1, 2, 3],
str: '@#$%',
+ importantOption: false
};
let queryString:string;
@@ -48,12 +49,16 @@ describe('UrlParamsHelper', () => {
});
it("concatenates propertys with '&'", () => {
- expect(queryString.split('&').length).toEqual(4);
+ expect(queryString.split('&').length).toEqual(5);
});
it('escapes special characters', () => {
expect(queryString.indexOf('@') === -1).toBeTruthy();
});
+
+ it('does not omit false', () => {
+ expect(queryString.includes('importantOption=false')).toBeTruthy();
+ });
});
describe('encodeQueryJsonParams', () => {
diff --git a/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.ts b/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.ts
index e20bd87ca98..51faa23c15a 100644
--- a/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.ts
+++ b/frontend/src/app/features/work-packages/components/wp-query/url-params-helper.ts
@@ -113,7 +113,7 @@ export class UrlParamsHelperService {
const parts:string[] = [];
_.each(params, (value, key) => {
- if (!value) {
+ if (value === undefined || value === null) {
return;
}
if (!Array.isArray(value)) {
diff --git a/spec/features/work_packages/export_spec.rb b/spec/features/work_packages/export_spec.rb
index b8a64b775d4..6c4ac1a655b 100644
--- a/spec/features/work_packages/export_spec.rb
+++ b/spec/features/work_packages/export_spec.rb
@@ -104,7 +104,7 @@ RSpec.describe "work package export", :js, :selenium do
end
end
- def open_export_dialog!(query_target = :query)
+ def open_page!(query_target = :query)
case query_target
when :query
wp_table.visit_query query
@@ -113,14 +113,21 @@ RSpec.describe "work package export", :js, :selenium do
else
raise ArgumentError, "query_target must be :query or :default"
end
-
work_packages_page.ensure_loaded
+ end
+
+ def show_export_dialog!
settings_menu.open_and_choose I18n.t("js.toolbar.settings.export")
expect(page).to have_css("#op-work-packages-export-dialog", wait: 5)
click_on export_type
sleep 0.1
end
+ def open_export_dialog!(query_target = :query)
+ open_page! query_target
+ show_export_dialog!
+ end
+
def export!
click_on I18n.t("export.dialog.submit")
expect(page).to have_no_button(I18n.t("export.dialog.submit"), wait: 1)
@@ -321,6 +328,26 @@ RSpec.describe "work package export", :js, :selenium do
end
end
+ context "with default display_subprojects_work_packages and an unsaved query" do
+ let(:expected_params) { { includeSubprojects: "false" } }
+ let(:project_include) { Components::ProjectIncludeComponent.new }
+
+ before do
+ Setting.display_subprojects_work_packages = true
+ open_page!(:default)
+ end
+
+ it "does apply a disabled include_subprojects option" do
+ project_include.toggle!
+ project_include.expect_open
+ project_include.toggle_include_all_subprojects
+ project_include.expect_include_all_subprojects_unchecked
+ project_include.click_button("Apply")
+ show_export_dialog!
+ export!
+ end
+ end
+
context "with XLS export" do
let(:export_type) { I18n.t("export.dialog.format.options.xls.label") }
let(:expected_mime_type) { :xls }
diff --git a/spec/support/components/project_include_component.rb b/spec/support/components/project_include_component.rb
index 44919fd8399..07e61399e96 100644
--- a/spec/support/components/project_include_component.rb
+++ b/spec/support/components/project_include_component.rb
@@ -55,6 +55,10 @@ module Components
page.find("[data-qa-project-include-all-subprojects]").click
end
+ def expect_include_all_subprojects_unchecked
+ expect(page.find("[data-qa-project-include-all-subprojects]")).not_to be_checked
+ end
+
def toggle_checkbox(project_id)
page.find("[data-qa-project-include-id='#{project_id}']").click
clear_tooltips