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

Switch `work_packages/datepicker/datepicker_logic_spec` to cuprite

Aaron Contreras2536705eb9af
diff --git a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
index 1ccf4803287..f5e88e7b815 100644
--- a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
+++ b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
@@ -30,7 +30,8 @@ require 'spec_helper'
require 'support/edit_fields/edit_field'
RSpec.describe 'Datepicker modal logic test cases (WP #43539)',
- js: true, with_settings: { date_format: '%Y-%m-%d' } do
+ js: true,
+ with_cuprite: true, with_settings: { date_format: '%Y-%m-%d' } do
shared_let(:user) { create(:admin) }
shared_let(:type_bug) { create(:type_bug) }
@@ -221,8 +222,6 @@ RSpec.describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_due_date '2021-02-12'
datepicker.expect_duration 3
- # The spec clears faster than the due date is filled, wait a bit
- sleep 1
datepicker.clear_duration
datepicker.expect_start_date '2021-02-09'
@@ -245,8 +244,6 @@ RSpec.describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_due_date '2021-02-12'
datepicker.expect_duration 3
- # The spec clears faster than the due date is filled, wait a bit
- sleep 1
datepicker.clear_duration_with_icon
datepicker.expect_start_date '2021-02-09'
@@ -269,8 +266,6 @@ RSpec.describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_due_date '2021-02-12'
datepicker.expect_duration 3
- # The spec clears faster than the due date is filled, wait a bit
- sleep 1
datepicker.clear_duration_with_icon
datepicker.expect_start_date '2021-02-09'
@@ -284,8 +279,6 @@ RSpec.describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_due_date '2021-02-09'
datepicker.expect_duration 3
- # Clear again
- sleep 1
datepicker.clear_duration_with_icon
datepicker.expect_start_date '2021-02-05'
@@ -338,7 +331,6 @@ RSpec.describe 'Datepicker modal logic test cases (WP #43539)',
# simulate someone deleting some chars to type a new date
datepicker.set_start_date '2021-02-'
- sleep 2
datepicker.set_start_date '2021-02-09'
datepicker.expect_start_date '2021-02-09'
@@ -756,8 +748,6 @@ RSpec.describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.focus_duration
datepicker.expect_duration_highlighted
- sleep 1
-
datepicker.select_day 17
datepicker.expect_start_date '2021-02-17'
datepicker.expect_due_date '2021-02-18'
@@ -790,8 +780,6 @@ RSpec.describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.focus_duration
datepicker.expect_duration_highlighted
- sleep 1
-
datepicker.select_day 19
datepicker.expect_start_date '2021-02-18'
datepicker.expect_due_date '2021-02-19'
@@ -824,8 +812,6 @@ RSpec.describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.focus_duration
datepicker.expect_duration_highlighted
- sleep 1
-
datepicker.select_day 19
datepicker.expect_start_date '2021-02-18'
datepicker.expect_due_date '2021-02-19'
@@ -858,8 +844,6 @@ RSpec.describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.focus_duration
datepicker.expect_duration_highlighted
- sleep 1
-
datepicker.select_day 17
datepicker.expect_start_date '2021-02-17'
datepicker.expect_due_date '2021-02-18'
diff --git a/spec/support/components/datepicker/work_package_datepicker.rb b/spec/support/components/datepicker/work_package_datepicker.rb
index 3ca2d85d004..51cfb431925 100644
--- a/spec/support/components/datepicker/work_package_datepicker.rb
+++ b/spec/support/components/datepicker/work_package_datepicker.rb
@@ -77,26 +77,20 @@ module Components
def set_milestone_date(value)
focus_milestone_date
- fill_in 'date', with: value, fill_options: { clear: :backspace }
-
- # Wait until debounce applied
- sleep 1
+ clear_input_field_contents('date')
+ fill_in 'date', with: value
end
def set_start_date(value)
focus_start_date
- fill_in 'startDate', with: value, fill_options: { clear: :backspace }
-
- # Wait for the value to be applied
- sleep 1
+ clear_input_field_contents('startDate')
+ fill_in 'startDate', with: value
end
def set_due_date(value)
focus_due_date
- fill_in 'endDate', with: value, fill_options: { clear: :backspace }
-
- # Wait for the value to be applied
- sleep 1
+ clear_input_field_contents('endDate')
+ fill_in 'endDate', with: value
end
def expect_start_highlighted
@@ -135,7 +129,8 @@ module Components
def set_duration(value)
focus_duration
- fill_in 'duration', with: value, fill_options: { clear: :backspace }
+ clear_input_field_contents('duration')
+ fill_in 'duration', with: value
# Focus a different field
start_date_field.click
@@ -187,7 +182,8 @@ module Components
def clear_duration
duration_field.click
- fill_in 'duration', with: '', fill_options: { clear: :backspace }
+ clear_input_field_contents('duration')
+ fill_in 'duration', with: ''
# Focus a different field
start_date_field.click
diff --git a/spec/support/shared/cuprite_helpers.rb b/spec/support/shared/cuprite_helpers.rb
index 3b20f6f4881..edbbdb0bfd1 100644
--- a/spec/support/shared/cuprite_helpers.rb
+++ b/spec/support/shared/cuprite_helpers.rb
@@ -47,8 +47,12 @@ end
# Ferrum is yet support `fill_options` as a Hash
def clear_input_field_contents(input_element)
- input_element.value.length.times do
- input_element.send_keys(:backspace)
+ if input_element.is_a? String
+ input_element = find_field(input_element)
+ end
+
+ (input_element.value.length + 1).times do
+ input_element.native.node.type(:backspace)
end
end