Skip to content

Add page objects and fix the end of datetime ranges - #26

Merged
senid231 merged 2 commits into
masterfrom
page-objects
Dec 1, 2026
Merged

senid231 merged 2 commits into
masterfrom
page-objects

Conversation

@senid231

Copy link
Copy Markdown
Member

Adds optional page objects (require "active_admin_date_range_preset/page_objects") and fixes a preset that dropped the last minute of a datetime range.

filter = page.filters.filter(:created_at)
filter.choose_preset("Last 7 days")
filter.range # => the two input values

The bug: with date_to_human_readable: true, a preset wrote 23:59 as the end. The datetimepicker's _lteq_datetime_picker predicate is a strict <, so the range missed its last minute. Inputs with that predicate now end at the next day's 00:00. Setting step="1" with 23:59:59 would still drop the last second. Other inputs keep 23:59:59 and 23:59, as native_inputs_spec expects.

choose_preset finds the menu from the session, because the menu is appended to <body>. A missing title raises Capybara::ElementNotFound, listing the presets on offer. The page objects gem is a test-group dependency with require: false; the gemspec is unchanged.

Verified: the suite passes on ActiveAdmin 4.0.0.beta23 (50 examples) and 3.5 (47 examples).

A preset with date_to_human_readable wrote 23:59 into a _lteq_datetime_picker input, and that predicate is a strict <, so the last minute of the range was dropped. Such inputs now end at the next day's 00:00.

Co-Authored-By: Clanker
@senid231 senid231 self-assigned this Nov 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues affecting the optional page-object integration or datetime range boundary fix.

No open issues 🎉

What changed in this PR

Adds optional page objects for interacting with date-range presets in tests and fixes datetime ranges that previously omitted the final minute when using active_admin_datetimepicker’s strict end predicate.

Changes:

  • Adds choose_preset and range helpers through an optional Active Admin 4 page-object integration.
  • Preserves next-day midnight for exclusive datetime ends while retaining existing date-input behavior.
  • Adds regression coverage and documents the integration and boundary fix.
File Description
vendor/​assets/​javascripts/​active_admin_date_range_preset.js Keeps exclusive datetime range ends at next-day midnight.
spec/​page_objects_spec.rb Tests preset selection, returned ranges, and missing-title errors.
spec/​datetimepicker_markup_spec.rb Tests human-readable datetime and date range boundaries.
README.md Documents optional page objects and exclusive-end behavior.
lib/​active_admin_date_range_preset/​page_objects/​presets.rb Implements preset selection and range-reading helpers.
lib/​active_admin_date_range_preset/​page_objects.rb Loads the optional integration, checks compatibility, and registers selectors.
Gemfile Adds a pinned test-only page-object dependency for Active Admin 4.
CHANGELOG.md Records the page-object addition and datetime boundary fix.

Review effort: Balanced

@senid231
senid231 merged commit 27c871b into master Dec 1, 2026
19 checks passed
@senid231
senid231 deleted the page-objects branch December 1, 2026 10:59
@senid231 senid231 mentioned this pull request Dec 1, 2026
senid231 added a commit that referenced this pull request Dec 1, 2026
Minor: #26 adds optional page objects and fixes the end of datetime
ranges. The CHANGELOG heading moves from Unreleased to 1.1.0.

Co-Authored-By: Clanker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants