Skip to content

Add page objects for the datetime range filter - #99

Open
senid231 wants to merge 3 commits into
masterfrom
page-objects
Open

senid231 wants to merge 3 commits into
masterfrom
page-objects

Conversation

@senid231

Copy link
Copy Markdown
Member

Adds optional page objects for the datetime range filter, built on active_admin_page_objects 2.x. Apps load them with require "active_admin_datetimepicker/page_objects", so they no longer override filter_range_from and filter_range_to globally.

filter = page.filters.filter(:created_at)
filter.fill_in_range(from: 2.days.ago, to: Time.current) # Time, Date, String or nil
filter.range # => [Time, Time] in Time.zone

Decisions a reviewer can't see in the diff:

  • DateTimeRangeFilter is registered for this plugin's date_time_range inputs only, so the base gem's selectors stay untouched.
  • The write format follows the input: datetime-local (with seconds when step is under a minute), date, or the xdsoft text format.
  • The page objects gem is a test-group dependency loaded with require: false, only on ActiveAdmin 4, because 2.x supports ActiveAdmin 4 only. The gemspec is unchanged.

Verified: CI=1 bundle exec rspec spec passes on ActiveAdmin 4.0.0.beta23 (26 examples) and 3.5 (12 examples). Without CI, the dummy app doesn't eager-load and the ActiveAdmin 4 filter specs fail, on master too.

@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.

🟡 Changes recommended

The new specs only cover zero seconds, leaving nonzero-second preservation and browser normalization unverified for step="1" and step="any".

1 open issue
What changed in this PR

Adds optional page objects for datetime range filters on ActiveAdmin 4, allowing tests to fill and read ranges without overriding the base page-object gem’s selectors.

Changes:

  • Registers a plugin-specific range filter with timezone-aware readers and input-aware formatting.
  • Adds feature coverage, including browser interaction, and documents setup and usage.
  • Adds the page-object dependency only to the ActiveAdmin 4 test group.
File Description
spec/​page_objects_spec.rb Tests filter discovery, range operations, and browser interaction.
README.md Documents optional installation, usage, and migration from selector overrides.
lib/​active_admin_datetimepicker/​page_objects/​date_time_range_filter.rb Implements range writing, reading, formatting, and matching.
lib/​active_admin_datetimepicker/​page_objects.rb Loads the integration and registers dedicated selectors and the filter class.
Gemfile Adds the optional test dependency for ActiveAdmin 4.

Review effort: Balanced


def format_of(input)
case input[:type]
when 'datetime-local' then seconds?(input) ? "#{LOCAL_FORMAT}:%S" : LOCAL_FORMAT

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added in 6306826: browser specs with step="1" and step="any". They check the written value (10:00:15 kept), from/to, have_range, and have_no_range against the minute-only value. The zero-second end is checked with start_with, because the browser may drop :00.

This branch has not been deployed

No deployments
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