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

fix flickering team_planner integration test

Christophe Bliard9ea06599f598
diff --git a/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb b/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb
index f02497d8052..44ab1d45912 100644
--- a/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb
+++ b/modules/team_planner/spec/features/team_planner_user_interaction_spec.rb
@@ -95,7 +95,7 @@ describe 'Team planner drag&dop and resizing', type: :feature, js: true do
it 'allows to drag&drop between the lanes to change the assignee' do
# Move first wp to the user
retry_block do
- team_planner.drag_wp_by_pixel(first_wp, 0, -100)
+ team_planner.drag_wp_to_lane(first_wp, user)
end
team_planner.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_update'))
@@ -113,7 +113,7 @@ describe 'Team planner drag&dop and resizing', type: :feature, js: true do
# Move second wp to the user, resulting in the other user having no WPs any more
retry_block do
- team_planner.drag_wp_by_pixel(second_wp, 0, -100)
+ team_planner.drag_wp_to_lane(second_wp, user)
end
team_planner.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_update'))
@@ -131,7 +131,7 @@ describe 'Team planner drag&dop and resizing', type: :feature, js: true do
# Move the third WP to the empty row of the other user
retry_block do
- team_planner.drag_wp_by_pixel(third_wp, 0, 200)
+ team_planner.drag_wp_to_lane(third_wp, other_user)
end
team_planner.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_update'))
diff --git a/modules/team_planner/spec/support/pages/team_planner.rb b/modules/team_planner/spec/support/pages/team_planner.rb
index 20a0f997581..103b9dbcae5 100644
--- a/modules/team_planner/spec/support/pages/team_planner.rb
+++ b/modules/team_planner/spec/support/pages/team_planner.rb
@@ -118,10 +118,7 @@ module Pages
def within_lane(user, &block)
raise ArgumentError.new("Expected instance of principal") unless user.is_a?(Principal)
- type = ::API::V3::Principals::PrincipalType.for(user)
- href = ::API::V3::Utilities::PathHelper::ApiV3Path.send(type, user.id)
-
- page.within(%(.fc-timeline-lane[data-resource-id="#{href}"]), &block)
+ page.within(lane(user), &block)
end
def expect_event(work_package, present: true)
@@ -174,6 +171,13 @@ module Pages
drag_by_pixel(element: source, by_x: by_x, by_y: by_y)
end
+ def drag_wp_to_lane(work_package, user)
+ wp_strip = event(work_package)
+ lane = lane(user)
+
+ drag_by_pixel(element: wp_strip, by_x: 0, by_y: y_distance(from: wp_strip, to: lane))
+ end
+
def drag_to_remove_dropzone(work_package, expect_removable: true)
source = event(work_package)
@@ -210,6 +214,13 @@ module Pages
page.find('.fc-event', text: work_package.subject)
end
+ def lane(user)
+ type = ::API::V3::Principals::PrincipalType.for(user)
+ href = ::API::V3::Utilities::PathHelper::ApiV3Path.send(type, user.id)
+
+ page.find(%(.fc-timeline-lane[data-resource-id="#{href}"]))
+ end
+
def expect_wp_not_resizable(work_package)
expect(page).to have_selector('.fc-event:not(.fc-event-resizable)', text: work_package.subject)
end
@@ -221,5 +232,13 @@ module Pages
def expect_no_menu_item(name)
expect(page).not_to have_selector('.op-sidemenu--item-title', text: name)
end
+
+ def y_distance(from:, to:)
+ y_center(to) - y_center(from)
+ end
+
+ def y_center(element)
+ element.native.location.y + (element.native.size.height / 2)
+ end
end
end