Add test for new ancestor algorithm during drag'n'drop in hierarchy mode

pull/7993/head
Henriette Dinger 5 years ago
parent e09ea6b931
commit 64872e5cdb
  1. 12
      frontend/src/app/components/wp-table/drag-and-drop/actions/hierarchy-drag-action.service.ts
  2. 64
      spec/features/work_packages/sorting/manual_sorting_spec.rb
  3. 4
      spec/support/pages/work_packages/work_packages_table.rb

@ -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);
});
}
}

@ -40,13 +40,28 @@ describe 'Manual sorting of WP table', type: :feature, js: true do
FactoryBot.create(:work_package, subject: 'WP1', project: project, type: type_task, created_at: Time.now)
end
let(: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)
end
let(: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)
end
let(: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)
end
let(:sort_by) { ::Components::WorkPackages::SortBy.new }
@ -122,7 +137,7 @@ describe 'Manual sorting of WP table', type: :feature, js: true do
hierarchies.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 hierarchy
wp_table.drag_and_drop_work_package from: 3, to: 0
loading_indicator_saveguard
@ -140,6 +155,47 @@ describe 'Manual sorting of WP table', type: :feature, js: true do
hierarchies.expect_leaf_at(work_package_3, work_package_4)
wp_page.expect_no_parent
end
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
end
end
describe 'group mode' do

@ -194,7 +194,7 @@ module Pages
end
def 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 offended
sleep 1
rows = 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 offended
sleep 1
end

Loading…
Cancel
Save