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

Add a feature test for the bugfix of #44895

Christophe Bliard0db4773e4700
diff --git a/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.ts b/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.ts
index 91201648ab3..3d4e92c4ef0 100644
--- a/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.ts
+++ b/frontend/src/app/features/work-packages/components/wp-edit-form/work-package-filter-values.ts
@@ -33,11 +33,14 @@ export class WorkPackageFilterValues {
if (this.excluded.indexOf(filter.id) !== -1) {
return;
}
+ const operator = filter.operator.id as FilterOperator;
// Special case due to the introduction of the project include dropdown
// If we are in a project, we want the create wp to be part of that project.
// Only for embedded tables, there might be different filter values necessary.
if (filter.id === 'project') {
+ if (operator !== '=') return;
+
const projectFilter = _.find(filter.values, (resource:HalResource|string) => {
return ((resource instanceof HalResource) ? resource.href : resource) === this.currentProject.apiv3Path;
});
@@ -52,7 +55,6 @@ export class WorkPackageFilterValues {
}
// Look for a handler with the filter's operator
- const operator = filter.operator.id as FilterOperator;
const handler = this.handlers[operator];
// Apply the filter if there is any
diff --git a/modules/boards/spec/features/action_boards/status_board_spec.rb b/modules/boards/spec/features/action_boards/status_board_spec.rb
index 1547cc9beca..928ac7e12e2 100644
--- a/modules/boards/spec/features/action_boards/status_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/status_board_spec.rb
@@ -44,14 +44,14 @@ describe 'Status action board', js: true do
let(:permissions) do
%i[show_board_views manage_board_views add_work_packages
- edit_work_packages view_work_packages manage_public_queries]
+ edit_work_packages move_work_packages view_work_packages manage_public_queries]
end
let!(:priority) { create(:default_priority) }
let!(:open_status) { create(:default_status, name: 'Open') }
- let!(:other_status) { create(:status, name: 'Whatever') }
+ let!(:whatever_status) { create(:status, name: 'Whatever') }
let!(:closed_status) { create(:status, is_closed: true, name: 'Closed') }
- let!(:work_package) { create(:work_package, project:, subject: 'Foo', status: other_status) }
+ let!(:work_package) { create(:work_package, project:, subject: 'Foo', status: whatever_status) }
let(:filters) { Components::WorkPackages::Filters.new }
@@ -66,7 +66,7 @@ describe 'Status action board', js: true do
create(:workflow,
type:,
role:,
- old_status_id: other_status.id,
+ old_status_id: whatever_status.id,
new_status_id: open_status.id)
end
let!(:workflow_type_back_open) do
@@ -76,6 +76,13 @@ describe 'Status action board', js: true do
old_status_id: closed_status.id,
new_status_id: open_status.id)
end
+ let!(:workflow_type_open_to_whatever) do
+ create(:workflow,
+ type:,
+ role:,
+ old_status_id: open_status.id,
+ new_status_id: whatever_status.id)
+ end
before do
with_enterprise_token :board_view
@@ -97,6 +104,51 @@ describe 'Status action board', js: true do
board_page.expect_list 'Closed'
end
+ it 'does not change moving card project when filtering on projects (Bug #44895)' do
+ other_project = create(:project,
+ types: [type],
+ enabled_module_names: %i[work_package_tracking board_view],
+ members: { user => role })
+ board_index.visit!
+
+ # Create new board
+ board_page = board_index.create_board action: :Status
+
+ board_page.add_list option: 'Whatever'
+ board_page.expect_list 'Whatever'
+
+ # Add item
+ board_page.add_card 'Open', 'New Task'
+
+ # Add projects filter
+ board_page.filters.open
+ # binding.pry
+ # board_page.filters.add_filter('Project')
+ # board_page.filters.add_filter_by('Project', 'is (OR)', [other_project.name, project.name])
+
+ board_page.filters.add_filter_by('Project', 'is not', other_project.name)
+ board_page.filters.expect_filter_count 1
+
+ # wait for the chain of debounces:
+ # - 250ms in frontend/src/app/features/work-packages/components/filters/filter-project/filter-project.component.ts
+ # - 500ms in frontend/src/app/features/work-packages/components/filters/query-filters/query-filters.component.ts
+ # - 250ms in frontend/src/app/features/boards/board/board-filter/board-filter.component.ts
+ sleep(1)
+ # wait for the loading indicators to disappear
+ loading_indicator_saveguard
+
+ # move card
+ board_page.move_card(0, from: 'Open', to: 'Whatever')
+ board_page.wait_for_lists_reload
+
+ board_page.expect_card('Whatever', 'New Task', present: true)
+
+ wp_task = WorkPackage.find_by(subject: 'New Task')
+
+ expect(wp_task.status).to eq(whatever_status), 'Moving the card should have updated the status'
+ expect(wp_task.project).to eq(project), 'Moving the card should not change the project'
+ end
+
it 'allows management of boards' do
board_index.visit!
diff --git a/modules/boards/spec/features/support/board_page.rb b/modules/boards/spec/features/support/board_page.rb
index 04940c25ae5..d289fe22645 100644
--- a/modules/boards/spec/features/support/board_page.rb
+++ b/modules/boards/spec/features/support/board_page.rb
@@ -47,6 +47,10 @@ module Pages
@board
end
+ def filters
+ Components::WorkPackages::Filters.new
+ end
+
def free?
@board.options['type'] == 'free'
end
@@ -169,6 +173,14 @@ module Pages
drag_n_drop_element(from: source, to: target)
end
+ def wait_for_lists_reload
+ # wait for reload of lists to start and finish
+ # Not sure if that's the most reliable way to do it, but there is nothing visible
+ # about the PATCH request being sent and executed successfully after moving a card.
+ expect(page).to have_selector('.loading-indicator', wait: 5)
+ expect(page).not_to have_selector('.loading-indicator')
+ end
+
def add_list(option: nil, query: option)
if option.nil? && action?
raise "Must pass value option for action boards"
diff --git a/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb b/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb
index 2ddccdaf095..42df28850f6 100644
--- a/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb
+++ b/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb
@@ -8,6 +8,9 @@ module Components::Autocompleter
# Wait for dropdown to open
ng_find_dropdown(element, results_selector:) if wait_dropdown_open
+ # Wait for autocompleter options to be loaded (data fetching is debounced by 250ms after creation or typing)
+ expect(element).not_to have_selector('.ng-spinner-loader')
+
# Insert the text to find
within(element) do
ng_enter_query(element, query)