Skip to content

Commit

Permalink
Fixing feature tests broken since schedule_manually is true by default
Browse files Browse the repository at this point in the history
  • Loading branch information
cbliard committed Dec 9, 2024
1 parent 7f8da75 commit 2202444
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
project:,
subject: "Parent work package",
assigned_to: other_user,
schedule_manually: false, # because parent of child_wp
start_date: Time.zone.today.beginning_of_week.next_occurring(:wednesday),
due_date: Time.zone.today.beginning_of_week.next_occurring(:thursday),
derived_start_date: Time.zone.today.beginning_of_week.next_occurring(:wednesday),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
require "spec_helper"
require_relative "shared_context"

RSpec.describe "Team planner drag&dop and resizing",
RSpec.describe "Team planner drag&drop and resizing",
:js,
with_ee: %i[team_planner_view],
with_settings: { start_of_week: 1 } do
Expand All @@ -45,6 +45,7 @@
create(:work_package,
project:,
assigned_to: other_user,
schedule_manually: false, # because parent of second_wp
start_date: Time.zone.today.beginning_of_week.next_occurring(:tuesday),
due_date: Time.zone.today.beginning_of_week.next_occurring(:thursday))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@
end

context "if the follower is a task" do
let!(:follower) { create(:work_package, type:, project:) }
let!(:follower) { create(:work_package, type:, project:, schedule_manually: false) }
let!(:relation) { create(:follows_relation, from: follower, to: predecessor) }
let(:date_field) { work_packages_page.edit_field(:combinedDate) }

it_behaves_like "keeps the minimum date from the predecessor when toggling NWD"
end

context "if the follower is a milestone" do
let!(:follower) { create(:work_package, type: milestone_type, project:) }
let!(:follower) { create(:work_package, type: milestone_type, project:, schedule_manually: false) }
let!(:relation) { create(:follows_relation, from: follower, to: predecessor) }
let(:date_field) { work_packages_page.edit_field(:date) }

Expand Down
47 changes: 38 additions & 9 deletions spec/features/work_packages/datepicker/datepicker_parent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
datepicker.expect_visible
end

context "with the child having set dates" do
context "with the child having set dates and the parent being scheduled automatically" do
let(:child_attributes) do
{
start_date: "2021-02-01",
Expand All @@ -71,17 +71,46 @@
}
end

it "disables the non working days options" do
datepicker.expect_ignore_non_working_days_disabled
datepicker.expect_scheduling_mode false
context "when the parent is scheduled automatically" do
let(:parent_attributes) do
{
schedule_manually: false
}
end

first_monday = Time.zone.today.beginning_of_month.next_occurring(:monday)
datepicker.expect_disabled(first_monday)
it "disables the non-working days options" do
datepicker.expect_ignore_non_working_days_disabled
datepicker.expect_automatic_scheduling_mode

datepicker.toggle_scheduling_mode
datepicker.expect_scheduling_mode true
first_monday = Time.zone.today.beginning_of_month.next_occurring(:monday)
datepicker.expect_disabled(first_monday)

datepicker.expect_not_disabled(first_monday)
datepicker.toggle_scheduling_mode
datepicker.expect_manual_scheduling_mode

datepicker.expect_not_disabled(first_monday)
end
end

context "when the parent is scheduled manually" do
let(:parent_attributes) do
{
schedule_manually: true
}
end

it "enables the non-working days options" do
datepicker.expect_ignore_non_working_days_enabled
datepicker.expect_manual_scheduling_mode

first_monday = Time.zone.today.beginning_of_month.next_occurring(:monday)
datepicker.expect_not_disabled(first_monday)

datepicker.toggle_scheduling_mode
datepicker.expect_automatic_scheduling_mode

datepicker.expect_disabled(first_monday)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,22 @@
let!(:wp) do
create(:work_package,
project:,
schedule_manually: false, # because parent of wp_child and follows wp_pre
start_date: Date.parse("2016-01-01"),
due_date: Date.parse("2016-01-05"),
parent: wp_parent)
end
let!(:wp_parent) do
create(:work_package,
project:,
schedule_manually: false, # because parent of wp
start_date: Date.parse("2016-01-01"),
due_date: Date.parse("2016-01-05"))
end
let!(:wp_child) do
create(:work_package,
project:,
schedule_manually: false, # because needed to have rescheduling working
start_date: Date.parse("2016-01-01"),
due_date: Date.parse("2016-01-05"),
parent: wp)
Expand All @@ -80,6 +83,7 @@
let!(:wp_suc) do
create(:work_package,
project:,
schedule_manually: false, # because parent of wp_suc_child and follows wp
start_date: Date.parse("2016-01-06"),
due_date: Date.parse("2016-01-10"),
parent: wp_suc_parent).tap do |suc|
Expand All @@ -89,12 +93,14 @@
let!(:wp_suc_parent) do
create(:work_package,
project:,
schedule_manually: false, # because parent of wp_suc
start_date: Date.parse("2016-01-06"),
due_date: Date.parse("2016-01-10"))
end
let!(:wp_suc_child) do
create(:work_package,
project:,
schedule_manually: false, # because needed to have rescheduling working
start_date: Date.parse("2016-01-06"),
due_date: Date.parse("2016-01-10"),
parent: wp_suc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
create(:work_package,
project:,
type:,
subject: "Parent")
subject: "Parent",
schedule_manually: false)
end

let!(:child) do
Expand Down Expand Up @@ -117,8 +118,4 @@
expect(parent.due_date.iso8601).to eq("2020-07-25")
end
end

context "with a user allowed to view only" do
let(:role) { create(:project_role, permissions: %i[view_work_packages]) }
end
end
12 changes: 10 additions & 2 deletions spec/support/components/datepicker/work_package_datepicker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,20 @@ def expect_duration_highlighted

def expect_scheduling_mode(manually)
if manually
expect(container).to have_checked_field("scheduling", visible: :all)
expect_manual_scheduling_mode
else
expect(container).to have_unchecked_field("scheduling", visible: :all)
expect_automatic_scheduling_mode
end
end

def expect_manual_scheduling_mode
expect(container).to have_checked_field("scheduling", visible: :all)
end

def expect_automatic_scheduling_mode
expect(container).to have_unchecked_field("scheduling", visible: :all)
end

def toggle_scheduling_mode
find("label", text: "Manual scheduling").click
end
Expand Down

0 comments on commit 2202444

Please sign in to comment.