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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add test for new ancestor algorithm during drag'n'drop in hierarchy mode
Henriette Dinger64872e5cdb1f
diff --git a/frontend/src/app/components/wp-table/drag-and-drop/actions/hierarchy-drag-action.service.ts b/frontend/src/app/components/wp-table/drag-and-drop/actions/hierarchy-drag-action.service.tsindex c5527914cd9..86ba7271140 100644--- a/frontend/src/app/components/wp-table/drag-and-drop/actions/hierarchy-drag-action.service.ts+++ b/frontend/src/app/components/wp-table/drag-and-drop/actions/hierarchy-drag-action.service.ts@@ -69,10 +69,7 @@ export class HierarchyDragActionService extends TableDragActionService {// If the sibling is no hierarchy root, return it's parent.// Thus, the dropped element will get the same hierarchy level as the sibling- return this.wpCacheService.require(previousWpId)- .then((wp:WorkPackageResource) => {- return Promise.resolve(wp.parent.id);- });+ return this.loadParentOfWP(previousWpId);}private findRelationRowRoot(el:Element):Element|null {@@ -86,4 +83,11 @@ export class HierarchyDragActionService extends TableDragActionService {return null;}++ private loadParentOfWP(wpId:string):Promise<string|null> {+ return this.wpCacheService.require(wpId)+ .then((wp:WorkPackageResource) => {+ return Promise.resolve(wp.parent.id);+ });+ }}diff --git a/spec/features/work_packages/sorting/manual_sorting_spec.rb b/spec/features/work_packages/sorting/manual_sorting_spec.rbindex eee4e1b3af0..51107792b7f 100644--- a/spec/features/work_packages/sorting/manual_sorting_spec.rb+++ b/spec/features/work_packages/sorting/manual_sorting_spec.rb@@ -40,13 +40,28 @@ describe 'Manual sorting of WP table', type: :feature, js: true doFactoryBot.create(:work_package, subject: 'WP1', project: project, type: type_task, created_at: Time.now)endlet(:work_package_2) do- FactoryBot.create(:work_package, subject: 'WP2', project: project, parent: work_package_1, type: type_task, created_at: Time.now - 1.minutes)+ FactoryBot.create(:work_package,+ subject: 'WP2',+ project: project,+ parent: work_package_1,+ type: type_task,+ created_at: Time.now - 1.minutes)endlet(:work_package_3) do- FactoryBot.create(:work_package, subject: 'WP3', project: project, parent: work_package_2, type: type_bug, created_at: Time.now - 2.minutes)+ FactoryBot.create(:work_package,+ subject: 'WP3',+ project: project,+ parent: work_package_2,+ type: type_bug,+ created_at: Time.now - 2.minutes)endlet(:work_package_4) do- FactoryBot.create(:work_package, subject: 'WP4', project: project, parent: work_package_3, type: type_bug, created_at: Time.now - 3.minutes)+ FactoryBot.create(:work_package,+ subject: 'WP4',+ project: project,+ parent: work_package_3,+ type: type_bug,+ created_at: Time.now - 3.minutes)endlet(:sort_by) { ::Components::WorkPackages::SortBy.new }@@ -122,7 +137,7 @@ describe 'Manual sorting of WP table', type: :feature, js: true dohierarchies.expect_leaf_at(work_package_3, work_package_4)end- it 'can drag an element out of the hierarchy' do+ it 'can drag an element completely out of the hierarchy' do# Move up the hierarchywp_table.drag_and_drop_work_package from: 3, to: 0loading_indicator_saveguard@@ -140,6 +155,47 @@ describe 'Manual sorting of WP table', type: :feature, js: true dohierarchies.expect_leaf_at(work_package_3, work_package_4)wp_page.expect_no_parentend++ context 'drag an element partly out of the hierarchy' do+ let(:work_package_5) do+ FactoryBot.create(:work_package, subject: 'WP5', project: project, parent: work_package_1)+ end+ let(:work_package_6) do+ FactoryBot.create(:work_package, subject: 'WP6', project: project, parent: work_package_1)+ end++ before do+ work_package_5+ work_package_6+ work_package_4.parent = work_package_2+ work_package_4.save!+ wp_table.visit!++ # Hierarchy enabled+ wp_table.expect_work_package_order(work_package_1,+ work_package_2,+ work_package_3,+ work_package_4,+ work_package_5,+ work_package_6)+ hierarchies.expect_hierarchy_at(work_package_1, work_package_2)+ hierarchies.expect_leaf_at(work_package_3, work_package_4, work_package_5, work_package_6)+ end++ it 'move below a sibling of my parent' do+ wp_table.drag_and_drop_work_package from: 3, to: 5++ loading_indicator_saveguard+ wp_table.expect_work_package_order(work_package_1,+ work_package_2,+ work_package_3,+ work_package_5,+ work_package_4,+ work_package_6)+ hierarchies.expect_hierarchy_at(work_package_1, work_package_2)+ hierarchies.expect_leaf_at(work_package_3, work_package_4, work_package_5, work_package_6)+ end+ endenddescribe 'group mode' dodiff --git a/spec/support/pages/work_packages/work_packages_table.rb b/spec/support/pages/work_packages/work_packages_table.rbindex 1d1f2d67b66..acc0201b212 100644--- a/spec/support/pages/work_packages/work_packages_table.rb+++ b/spec/support/pages/work_packages/work_packages_table.rb@@ -194,7 +194,7 @@ module Pagesenddef drag_and_drop_work_package(from:, to:)- # Wait a bit because drag & drop in selenium is easily offendedA+ # Wait a bit because drag & drop in selenium is easily offendedsleep 1rows = page.all('.wp-table--row')@@ -238,7 +238,7 @@ module Pages.release.perform- # Wait a bit because drag & drop in selenium is easily offendedA+ # Wait a bit because drag & drop in selenium is easily offendedsleep 1end