diff --git a/modules/team_planner/spec/features/team_planner_spec.rb b/modules/team_planner/spec/features/team_planner_spec.rb index 7475d68cb5..d34fb19bac 100644 --- a/modules/team_planner/spec/features/team_planner_spec.rb +++ b/modules/team_planner/spec/features/team_planner_spec.rb @@ -259,4 +259,41 @@ describe 'Team planner', type: :feature, js: true do expect(page).to have_selector('.ng-option-disabled', text: "No items found") end end + + context 'with a readonly work package' do + let(:readonly_status) { create :status, is_readonly: true } + + let!(:blocked_task) do + create :work_package, + project:, + assigned_to: user, + status: readonly_status, + start_date: Time.zone.today - 1.day, + due_date: Time.zone.today + 1.day, + subject: 'A blocked task' + end + + it 'disables editing on readonly tasks' do + with_enterprise_token(:team_planner_view, :readonly_work_packages) + team_planner.visit! + + team_planner.wait_for_loaded + team_planner.expect_empty_state + team_planner.expect_assignee(user, present: false) + + retry_block do + team_planner.click_add_user + page.find('[data-qa-selector="tp-add-assignee"] input') + team_planner.select_user_to_add user.name + end + + team_planner.expect_empty_state(present: false) + team_planner.expect_assignee user + + team_planner.within_lane(user) do + team_planner.expect_event blocked_task + team_planner.expect_resizable blocked_task, resizable: false + end + 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 f77b525c23..58e94d84c3 100644 --- a/modules/team_planner/spec/support/pages/team_planner.rb +++ b/modules/team_planner/spec/support/pages/team_planner.rb @@ -129,6 +129,14 @@ module Pages end end + def expect_resizable(work_package, resizable: true) + if resizable + expect(page).to have_selector('.fc-event.fc-event-resizable', text: work_package.subject, wait: 10) + else + expect(page).to have_selector('.fc-event:not(.fc-event-resizable)', text: work_package.subject, wait: 10) + end + end + def add_assignee(name) click_add_user page.find('[data-qa-selector="tp-add-assignee"] input')