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 test case for missing permissions and add retry_blocks as an attempt to make the test more stable

Henriette Darge088b864d8f1e
diff --git a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
index 4730c23ce2d..41fa6a5ea53 100644
--- a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
+++ b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
@@ -320,11 +320,15 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,
}
const assignee = this.wpAssignee(workPackage);
+ const durationEditable = this.eventDurationEditable(workPackage);
+ const resourceEditable = this.eventResourceEditable(workPackage);
+
return {
id: `${workPackage.href as string}-${assignee}`,
resourceId: assignee,
- durationEditable: this.eventDurationEditable(workPackage),
- resourceEditable: this.eventResourceEditable(workPackage),
+ editable: durationEditable || resourceEditable,
+ durationEditable,
+ resourceEditable,
constraint: this.eventConstaints(workPackage),
title: workPackage.subject,
start: this.wpStartDate(workPackage),
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 2d326da13e2..13139a14f7d 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
@@ -39,8 +39,8 @@ describe 'Team planner', type: :feature, js: true do
firstname: 'Bernd',
member_in_project: project,
member_with_permissions: %w[
- view_work_packages view_team_planner
- ]
+ view_work_packages view_team_planner
+ ]
end
let!(:first_wp) do
@@ -90,7 +90,9 @@ describe 'Team planner', type: :feature, js: true do
it 'allows to drag&drop between the lanes to change the assignee' do
# Move first wp to the user
- team_planner.drag_wp_by_pixel(first_wp, 0, -50)
+ retry_block do
+ team_planner.drag_wp_by_pixel(first_wp, 0, -50)
+ end
team_planner.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_update'))
team_planner.within_lane(user) do
@@ -106,7 +108,9 @@ describe 'Team planner', type: :feature, js: true do
end
# Move second wp to the user, resulting in the other user having no WPs any more
- team_planner.drag_wp_by_pixel(second_wp, 0, -50)
+ retry_block do
+ team_planner.drag_wp_by_pixel(second_wp, 0, -50)
+ end
team_planner.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_update'))
team_planner.within_lane(user) do
@@ -140,10 +144,10 @@ describe 'Team planner', type: :feature, js: true do
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)
-
+ # 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.
@@ -161,7 +165,9 @@ describe 'Team planner', type: :feature, js: true do
sleep 5
# Change the dates by dragging the complete wp
- team_planner.drag_wp_by_pixel(second_wp, -100, 0)
+ retry_block do
+ team_planner.drag_wp_by_pixel(second_wp, -100, 0)
+ end
team_planner.expect_and_dismiss_toaster(message: I18n.t('js.notice_successful_update'))
first_wp.reload
@@ -173,8 +179,13 @@ describe 'Team planner', type: :feature, js: true do
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
+ # The calendar needs some time to redraw. If we continue right away we'd get conflicting modifications
+ sleep 5
+ # Parent elements cannot be resized, as they derive their values from their children
+ team_planner.expect_wp_not_resizable(first_wp)
+ # Elements that have start or due date outside of the current view are also not resizable
+ team_planner.expect_wp_not_resizable(third_wp)
end
end
@@ -185,13 +196,19 @@ describe 'Team planner', type: :feature, js: true do
team_planner.visit!
team_planner.add_assignee user
- etry_block do
+ retry_block do
team_planner.add_assignee other_user
end
end
it 'allows neither dragging nor resizing any wp' do
+ team_planner.expect_wp_not_resizable(first_wp)
+ team_planner.expect_wp_not_resizable(second_wp)
+ team_planner.expect_wp_not_resizable(third_wp)
+ team_planner.expect_wp_not_draggable(first_wp)
+ team_planner.expect_wp_not_draggable(second_wp)
+ team_planner.expect_wp_not_draggable(third_wp)
end
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 c6ae8e27a3d..1ea3b328a73 100644
--- a/modules/team_planner/spec/support/pages/team_planner.rb
+++ b/modules/team_planner/spec/support/pages/team_planner.rb
@@ -144,7 +144,7 @@ module Pages
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?
+ drag_by_pixel(element: resizer, by_x: number_of_days * 170, by_y: 0) unless resizer.nil?
end
def drag_wp_by_pixel(work_package, x, y)
@@ -153,5 +153,13 @@ module Pages
drag_by_pixel(element: source, by_x: x, by_y: y)
end
+
+ def expect_wp_not_resizable(work_package)
+ expect(page).to have_selector('.fc-event:not(.fc-event-resizable)', text: work_package.subject)
+ end
+
+ def expect_wp_not_draggable(work_package)
+ expect(page).to have_selector('.fc-event:not(.fc-event-draggable)', text: work_package.subject)
+ end
end
end