111 Commits

Author SHA1 Message Date
David F 0f1daad3ee Fix advanced filters specs with date range picker. wp/74380 2026-05-26 08:14:56 +02:00
Christophe Bliard 41d34f2563 Simpler fix than 84bbf8d
84bbf8d fixed the flaky spec
`spec/features/projects/life_cycle/overview_page/dialog/update_spec.rb:266`.
It was flaky because it was testing if a date in the date picker is
disabled, but this date could be in the previous month and thus not
visible.

The implemented fix in 84bbf8d was to show the date before testing it
right in the `expect_xxx` methods.

The problem is that it breaks the query/command segregation principle.

Better move the calendar to the correct date before doing assertions on
the dates being visible, so the `expect_xxx` methods actually do also
check that the date is visible, which is desired in some test scenarios.
2026-01-26 18:31:59 +01:00
Christophe Bliard 7c72f0c3a5 Fix slow tests when checking date visible in date picker
941096114c introduced `Components::Datepicker#displays_date?(date)` to
check if a date is visible in the date picker before doing some
assertions on it. Then 84bbf8d549 doubled down on it by calling it
inside each `#expect_non_working(date)`, `#expect_working(date)`,
`#expect_disabled(date)`, `#expect_not_disabled(date)` methods.

The problem is that `#displays_date?(date)` uses `has_css?` so it
returns immediately if the check is positive, but waits for 3 seconds
for the date to become visible if it's not yet. It's missing a `wait:
0`. And the css selector is wrong to: it searches for
`.flatpickr-day.flatpickr-disabled` instead of `.flatpickr-day`, so it
was returning false when the date was visible and enabled.

This commit fixes the problem by:
- Adding `wait: 0` to `has_css?`
- Changing the css selector to `.flatpickr-day`
- Add some `#expect_visible` calls to be sure the date picker is visible
  before doing assertions with `wait: 0`

And same for `#has_previous_month_toggle?`: it missed a `wait: 0` for
the same reasons.

This makes for instance the 2 specs in
`spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb:84`
run in 11 seconds instead of 1 minute 27 seconds.
2026-01-26 18:29:32 +01:00
Christophe Bliard d646353c33 Fix flaky spec
failing spec: ./spec/features/work_packages/details/date_editor_spec.rb:481
failing run: https://github.com/opf/openproject/actions/runs/18496811091/job/52702962599

When the working days only checkbox is toggled, the preview is triggered and updates the datepicker modal.

There was a race condition: if switching to automatic scheduling mode
before the preview finished, the preview would update the datepicker
modal and switching to automatic would be ignored (maybe it should not
be ignored). This was causing the spec to fail because the "working days
only" checkbox was not disabled.

Fix is to wait for the preview to finish before switching to automatic
scheduling mode.
2025-10-15 17:20:39 +02:00
Dombi Attila 84bbf8d549 Fix lifecycle modal datepicker spec not displaying the expected date. 2025-07-21 18:42:49 +03:00
Dombi Attila c47b738dbf Focus the datepicker banner when switching scheduling mode via the keyboard. 2025-07-02 01:21:18 +03:00
Dombi Attila cd93c1e8bf Update manual scheduling spec to expect start date activated on datepicke when start date is clicked. 2025-07-02 01:21:11 +03:00
ulferts 941096114c disable an expectations if the checked for date is not displayed 2025-06-23 11:43:42 +02:00
Jan Sandbrink 0b87e7543f Freeze string literals in specs
Rolling out frozen string literals further by freezing all
string literals in core specs.
2025-05-05 09:29:55 +02:00
Christophe Bliard 0aba09bdd7 Fix flaky spec
Spec was ./spec/features/work_packages/scheduling/scheduling_mode_spec.rb:139
on job run https://github.com/opf/openproject/actions/runs/14519804438/job/40741624438

In `DateEditField#set_value`, the input fields of the date picker were
cleared and then the values were set. Problem is that when clearining
fields it does not wait for the preview to be applied: when the preview
comes back, it morphs the fields to set empty values but the
`#set_value` method has already started to fill the values, so the start
date field is overwritten with an empty value. Then the test fails
because the start date field is not the one expected.

The solution is to wait for the changes to be applied after clearing the
fields.

I wonder if that may be hiding a real bug where user could have their
input be reset while typing.
2025-04-18 09:59:43 +02:00
Christophe Bliard 34f60d3971 Fix flickering spec
It was not using our datepicker helper which has all the required
synchronization logic. Using it fixes the flickering.

Failing spec is `./spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb:48`
CI job run is https://github.com/opf/openproject/actions/runs/14405034091/job/40403247708?pr=18612
2025-04-14 10:19:52 +02:00
Christophe Bliard 66b8fd2f8e Fir wrong test conditions
The setup was incorrect: the successor's dates were identical to the predecessor's dates which is not possible, and the milestone had start date different from due date which is not possible either.

Finally the second test was wrong too because when a successor milestone is
automatically scheduled, the date can't be changed and the date picker
is fully disabled.
2025-03-31 18:57:39 +02:00
Christophe Bliard b3642054f8 [62362] Show "working days only" checkbox only if date form is shown too
https://community.openproject.org/wp/62362

When clicking the checkbox, it takes all form data and sends it to the
server for rerendering the form with the value updated.

Problem is: when the date form is not displayed and the "no
predecessors" message is displayed instead, there is no form data, so it
sends incomplete data to the server, and the server renders a minimalist
form.

The fix is to hide the checkbox too if the other form elements are hidden.
No checkbox, no click, no problem.
2025-03-20 11:36:17 +01:00
Christophe Bliard d0715a2ebf [62300] Fix 500 error when clicking manual scheduling mode button
For new work packages, the generated URL was incorrect (`#show` instead
of `#new` action) and it then lead to a `ActiveRecord::RecordNotFound`
for id=`new`.
2025-03-19 16:45:05 +01:00
Christophe Bliard 58f1b52bd5 Fix flaky test
The test always works in headfull mode, but seems to be failing
sometimes in headless mode, like if capybara is not up to date with the
browser.

This is a workaround I'm not happy with.
2025-03-17 11:35:07 +01:00
Christophe Bliard 9896908867 [61965] Switch parent to automatic mode when adding first child
https://community.openproject.org/wp/61965
https://community.openproject.org/wp/61054

If a manually scheduled work package has no direct or indirect
predecessors and no children, it switches to automatic scheduling mode
when a child is added.

This fixes the scenario 29 from #61054 and bug #61965. Other scenarios
have been implemented too. 4 of them still need to be implemented.
2025-03-17 10:47:26 +01:00
Henriette Darge 55ab827f84 Merge branch 'dev' into feature/47519-single-date-mode-for-work-package-date-pickers 2025-03-04 14:06:32 +01:00
Henriette Darge 1b1c2a643f Show the datepicker in single date mode when being opened from the Table 2025-03-03 15:10:50 +01:00
Christophe Bliard f9f603c189 [61894] Fix disappearing fields in date picker when in automatic mode
https://community.openproject.org/wp/61894

In the backend, the date picker component assumes that the work package
is a milestone if the frontend did not send any `work_package[due_date]`
value for "Finish date" field.

Problem is, when in automatic scheduling mode, the "Finish date" field
is disabled, so it's not sent to the backend. The backend then
misleadingly thinks that it's a milestone being edited, and displays
only the "Date" field, as a milestone work package would do. The "Finish
date" and "Duration" fields disappear.

As the "Duration" field is always enabled, the fix is rely on it
(`work_package[duration]`) instead of the "Finish date" field.
2025-02-28 16:49:15 +01:00
Henriette Darge b400b67b0a Add test cases for single-date mode 2025-02-26 08:36:15 +01:00
Henriette Darge fc9f48c8d5 Set focus when activating a date field and expect that in a test 2025-02-26 08:36:12 +01:00
Henriette Darge 7773a24677 Pass the "date_mode" param correctly 2025-02-26 08:36:12 +01:00
Henriette Darge 8d726ced6c Adapt tests to new single-date mode 2025-02-26 08:36:10 +01:00
Christophe Bliard 1bdcb56d67 Start adding automated tests from scenarios in wp #60670
https://community.openproject.org/wp/60670
2025-02-25 17:41:07 +01:00
Christophe Bliard 9584fe3330 refactor: Make test terminology match UI terminology 2025-02-25 09:18:21 +01:00
Christophe Bliard dfa56ca57a [60670] Update datepicker tests according to the new behavior
Some scenarios have been described in https://community.openproject.org/wp/60670

Some of them are still not implemented. 5 of them are still failing:
  - scenarios 13x
  - scenario 22a
  - scenario 23a

scenario 6a relies on the clear button being available, which is not the
case yet, so it's disabled.
2025-02-25 09:18:21 +01:00
Christophe Bliard 366dc2dc18 Display error in date picker for invalid duration
If duration is negative or garbage, an error is displayed in the date
picker. It will not display any derivation-related errors for start and
due dates. For instance if start date is set, due date is not set, and
duration is invalid, then it won't display "can not be set to null as
start date and duration are known" error for due date.
2025-02-25 09:18:19 +01:00
Christophe Bliard 0df023e49e Better test assertions and documentation
Do not set expectations on the day being waited for. Could be disabled
or not, that's not this test purpose, that only to wait for a refresh.

And use default wait time. 20 seconds is way to much to wait.
2025-02-25 09:18:17 +01:00
Christophe Bliard eaba879060 Improve month selection for date picker tests
After selecting a month, `#select_month` returns the index of the
selected month. It previously worked well only for single-month
datepickers. For a multiple months date picker, it was failing because
the selector is invalid (so it waited 5 seconds for nothing), then it
was retried, the current month was calculated, and that was the value
returned as the 2 conditions were not met. So in the end it was
returning the correct value, but it was also doing one useless retry.

This commit introduces `#current_month_index` to return the index of the
current month. This one works for both single and multi date pickers. It
is used by `#select_month` to calculate the number of months to move
forward or backward.

This should lead to some faster tests.
2025-02-25 09:18:17 +01:00
Henriette Darge a3911d9db2 Fix some more test selectors 2025-02-25 09:18:15 +01:00
Henriette Darge 2e651f74eb Fix some more tests 2025-02-25 09:18:10 +01:00
Henriette Darge df642c8ef2 Adapt some more test selectors 2025-02-25 09:18:08 +01:00
Henriette Darge 19dacbae6b Get tests running by waiting for the controller to be loaded before starting to change things. Further some selectors have been fixed 2025-02-25 09:18:08 +01:00
Henriette Darge 056ef3dac3 Start to re-add some test selectors and adapt tests to new structure 2025-02-25 09:18:06 +01:00
Christophe Bliard 2d7288d317 [59539] Make work packages manually scheduled by default
The `schedule_manually` column is also non-nullable now.

This includes the following changes:

- Automatically scheduled parent dates are and `ignore_non_working_days`
  attributes are now always derived from children's values, even if the
  children are scheduled manually.

  It's more natural. Without that, adding a child to a work package
  would not change the parent's dates.

  As a consequence, the parent can start on a non-working day if one of
  its children is manually scheduled, ignores non-working days, and
  starts on a non-working day. That's why the parent's
  `ignore_non_working_days` attribute is now also derived from all its
  children regardless of the scheduling mode.

  If the parent is manually scheduled, its dates and it's ability to
  ignore non-working days will still be defined independently from its
  children.

- Fix tests broken by scheduling mode being manual by default.

  The tests had to be adapted to explicitly set scheduling mode to
  automatic for followers and parents, and sometimes even follower's
  children. Without it, work packages would not be rescheduled
  automatically.

- Replace schedule helpers with table helpers.

  Schedule helpers helped well, but table helpers are more flexible and
  support more column types.

- Add "days counting" and "scheduling mode" columns to table helpers.

  "days counting" to set `ignore_non_working_days` attribute.
    - "all days" value maps to `ignore_non_working_days: true`.
    - "working days" value maps to `ignore_non_working_days: false`.
  "scheduling mode" to set `schedule_manually` attribute.
    - "manual" value maps to `schedule_manually: true`.
    - "automatic" value maps to `schedule_manually: false`.
2025-02-25 09:12:22 +01:00
Christophe Bliard adb75a5c86 Better fix for a flickering test (date-related)
Related to d94ea36eca. Use :enter instead of :right to trigger a
keyboard event to get the internal state of flatpickr updated. It seems
to work better.
2025-01-03 14:45:05 +01:00
Christophe Bliard d94ea36eca Fix flickering test (date-related)
The test wants to change a date using the datepicker from year 2025 to
year 2024. Using `fill_in` or `set` on the year input of the date picker
does not trigger any event which would update the internal state of the
flatpickr (it can be seen because the calendar dates is not redrawn). So
when the month is changed, the year switches back to 2025 (the internal
state), the wrong date is picked and the test fails.

This is fixed by sending a right arrow key to the year input to trigger
a keyboard event which then updates the internal state of the flatpickr.

This is a flickering test as the issue only occurs when the year needs
to be changed.
2024-12-24 09:39:14 +01:00
Dombi Attila 6ce663b0ac Addd more Stage and Gates dialog specs wip. 2024-12-17 15:56:23 +02:00
Christophe Bliard 50dbd4e881 Fix tests broken in previous commit
It was stupid to make an assertion on the selected day for the
datepicker in `#select_day` as the date picker is dismissed half of the
time, so the selected element is not there anymore to make assertions on
it.

Replaced with a direct assertion where it matters and reverted the
"safeguard".
2024-09-06 16:34:56 +02:00
Christophe Bliard 07e707033e refacotr: Reduce duplication and dead-code
The modal behavior being more reliable now, the `retry_block` is not
needed anymore. Also the `#select_day` method was similar in the parent
class. Better keep only the one from the parent class.
2024-09-06 15:36:26 +02:00
Oliver Günther 472b74ff3f Reload opening 2024-08-30 10:05:25 +02:00
Oliver Günther 47da171ac1 Provide option to hide highlight on col 2024-08-19 07:34:10 +02:00
Oliver Günther f8f614b340 Fix non working days behavior 2024-08-16 19:16:15 +02:00
Ivan Kuchin 878f4d021f no need to check for cuprite when using wait_for_network_idle 2024-07-29 13:06:36 +02:00
ulferts 3b2121f733 Revert "Merge remote-tracking branch 'origin/release/13.4' into dev"
This reverts commit 40b2bbeb09, reversing
changes made to b4c6cb17cc.
2024-03-21 11:31:17 +01:00
Ivan Kuchin 7787e457a3 Revert "Merge branch 'dev' into release/13.4"
This reverts commit a901541269, reversing
changes made to e573ca00b7.
2024-03-20 20:19:08 +01:00
Ivan Kuchin 9e4934cd0a change quotes using rubocop --only Style/StringLiterals,Style/QuotedSymbols -a 2024-03-20 18:05:22 +01:00
Christophe Bliard 8fa8584538 Run rubocop --autocorrect on all files
Only the safe cops have run. rubocop version is 1.59.0.
2024-01-05 15:27:09 +01:00
Oliver Günther 92259181ce Adapt specs to use introduced helpers 2023-09-13 09:02:42 +02:00
Aaron Contreras 4e27f82ade Increase debounce wait on Datepicker#set_field 2023-06-29 11:30:36 -05:00