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 datepicker logic spec

Oliver Güntherb8ea0c12e8a8
diff --git a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
new file mode 100644
index 00000000000..9c729067d0f
--- /dev/null
+++ b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
@@ -0,0 +1,91 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2022 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require 'spec_helper'
+require 'support/edit_fields/edit_field'
+
+describe 'Datepicker modal logic',
+ with_settings: { date_format: '%Y-%m-%d' },
+ with_flag: { work_packages_duration_field_active: true },
+ js: true do
+ shared_let(:user) { create :admin }
+
+ shared_let(:type_bug) { create(:type_bug) }
+ shared_let(:type_milestone) { create(:type_milestone) }
+ shared_let(:project) { create(:project, types: [type_bug, type_milestone]) }
+
+ shared_let(:bug_wp) { create :work_package, project:, type: type_bug }
+ shared_let(:milestone_wp) { create :work_package, project:, type: type_milestone }
+
+
+ # assume sat+sun are non working days
+ shared_let(:weekdays) { create :week_days }
+
+ let(:work_packages_page) { Pages::FullWorkPackage.new(work_package, project) }
+ let(:wp_table) { Pages::WorkPackagesTable.new(project) }
+
+ let(:date_field) { work_packages_page.edit_field(:combinedDate) }
+ let(:datepicker) { date_field.datepicker }
+
+ let(:bug_attributes) { nil }
+ let(:milestone_attributes) { nil }
+
+ let(:work_package) { bug_wp }
+
+ before do
+ bug_wp.update!(bug_attributes) unless bug_attributes.nil?
+ milestone_wp.update!(milestone_attributes) unless milestone_attributes.nil?
+ login_as(user)
+
+ work_packages_page.visit!
+ work_packages_page.ensure_page_loaded
+
+ date_field.activate!
+ date_field.expect_active!
+ end
+
+ describe '#43539 Scenario 1' do
+ let(:bug_attributes) do
+ {
+ start_date: Date.parse('2021-02-08'),
+ due_date: nil,
+ duration: nil
+ }
+ end
+
+ it 'sets finish date to 19th if duration of 10 set' do
+ datepicker.expect_start_date '2021-02-08'
+ datepicker.expect_due_date ''
+ datepicker.set_duration '10'
+
+ datepicker.expect_start_date '2021-02-08'
+ datepicker.expect_due_date '2021-02-19'
+ datepicker.expect_duration '10'
+ end
+ end
+end