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

Test for resizing a wp strip in the team planner (wip)

Henriette Darge4b8604163c52
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 0f24a30100b..2d326da13e2 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
@@ -47,16 +47,16 @@ describe 'Team planner', type: :feature, js: true do
FactoryBot.create :work_package,
project: project,
assigned_to: other_user,
- start_date: Time.zone.today - 1.day,
- due_date: Time.zone.today + 1.day
+ start_date: Time.zone.today.beginning_of_week.next_occurring(:tuesday),
+ due_date: Time.zone.today.beginning_of_week.next_occurring(:thursday)
end
let!(:second_wp) do
FactoryBot.create :work_package,
project: project,
parent: first_wp,
assigned_to: other_user,
- start_date: Time.zone.today - 1.day,
- due_date: Time.zone.today + 1.day
+ start_date: Time.zone.today.beginning_of_week.next_occurring(:tuesday),
+ due_date: Time.zone.today.beginning_of_week.next_occurring(:thursday)
end
let!(:third_wp) do
FactoryBot.create :work_package,
@@ -139,6 +139,41 @@ describe 'Team planner', type: :feature, js: true do
end
it 'allows to resize to change the dates of a wp' do
+ retry_block do
+ # Change date of second_wp by resizing it
+ team_planner.change_wp_date_by_resizing(second_wp, number_of_days: 1, is_start_date: true)
+
+ end
+ team_planner.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_update'))
+
+ # The date has changed, but the assignee remains unchanged.
+ # Because of the hierarchy, the first wp is updated, too.
+ first_wp.reload
+ second_wp.reload
+ expect(second_wp.start_date).to eq(Time.zone.today.beginning_of_week.next_occurring(:wednesday))
+ expect(second_wp.due_date).to eq(Time.zone.today.beginning_of_week.next_occurring(:thursday))
+ expect(second_wp.assigned_to_id).to eq(other_user.id)
+
+ expect(first_wp.start_date).to eq(Time.zone.today.beginning_of_week.next_occurring(:wednesday))
+ expect(first_wp.due_date).to eq(Time.zone.today.beginning_of_week.next_occurring(:thursday))
+
+ # The calendar needs some time to redraw. If we continue right away we'd get conflicting modifications
+ sleep 5
+
+ # Change the dates by dragging the complete wp
+ team_planner.drag_wp_by_pixel(second_wp, -100, 0)
+ team_planner.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_update'))
+
+ first_wp.reload
+ second_wp.reload
+ expect(second_wp.start_date).to eq(Time.zone.today.beginning_of_week.next_occurring(:tuesday))
+ expect(second_wp.due_date).to eq(Time.zone.today.beginning_of_week.next_occurring(:wednesday))
+ expect(second_wp.assigned_to_id).to eq(other_user.id)
+
+ expect(second_wp.start_date).to eq(Time.zone.today.beginning_of_week.next_occurring(:tuesday))
+ expect(second_wp.due_date).to eq(Time.zone.today.beginning_of_week.next_occurring(:wednesday))
+
+ # Parent elements cannot be resized, as they derive their values from their children
end
end
diff --git a/modules/team_planner/spec/support/pages/team_planner.rb b/modules/team_planner/spec/support/pages/team_planner.rb
index 3e0e70f47a5..c6ae8e27a3d 100644
--- a/modules/team_planner/spec/support/pages/team_planner.rb
+++ b/modules/team_planner/spec/support/pages/team_planner.rb
@@ -127,6 +127,26 @@ module Pages
query: name,
results_selector: 'body'
end
+
+ def change_wp_date_by_resizing(work_package, number_of_days:, is_start_date:)
+ wp_strip = page.find('.fc-event', text: work_package.subject)
+
+ page
+ .driver
+ .browser
+ .action
+ .move_to(wp_strip.native)
+ .perform
+
+ if is_start_date
+ resizer = wp_strip.find('.fc-event-resizer-start')
+ else
+ resizer = wp_strip.find('.fc-event-resizer-end')
+ end
+
+ drag_by_pixel(element: resizer, by_x: number_of_days * 150, by_y: 0) unless resizer.nil?
+ end
+
def drag_wp_by_pixel(work_package, x, y)
source = page
.find('.fc-event', text: work_package.subject)