Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI

on:
push:
branches: [main, 1-x-stable]
branches: [main]
pull_request:

jobs:
Expand All @@ -21,6 +21,15 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: spec/dummy/package-lock.json
- run: npm ci --no-audit --no-fund
working-directory: spec/dummy
- run: npm run build
working-directory: spec/dummy
- run: bundle exec rspec

rubocop:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
/gemfiles/*.lock
/tmp/
/.bundle/
/spec/dummy/node_modules/
/spec/dummy/app/assets/builds/
/spec/dummy/tmp/
/spec/dummy/log/
52 changes: 24 additions & 28 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,53 @@
# Changelog

## Unreleased
## 2.0.0.beta1

### Added

- `Table::Row#cell`, `has_cell?` and `Table#row_with` find the cells of the `actions` and `selectable` columns. ActiveAdmin 4 writes no `data-column` on them, so these lookups used to fail.
- `BatchActions#apply` leaves an open menu open; clicking the toggle again closed it.
- A String `text:` together with a String `exact_text:` checks both, also in the case-insensitive cell and row matchers.
- `Flashes#flash_types`, a private method that a theme overrides to add the flash types it renders.
- `Comments` section for resource comments: `count`, `bodies`, `authors`, `has_comment?`, `add` and `delete`. The `form` selector leaves the comment form out.
- has_many support: `Form.has_many`, `Form#has_many` and the `HasMany` section with fieldsets, `add`, `remove` and `marked_for_destroy?`. `have_exact_fields` counts a has_many block as one declared element, so a form with an undeclared has_many block reports it as unexpected.
- Status tags: `Table::Row` and `AttributesTable` get `status_tag(key)`, `status_tags(key)`, `has_status_tag?(key, label = nil, status:)` and `has_no_status_tag?`. `type:` is an alias of `status:`.
- Sorting: `Table#sort_by(key, direction = nil)`, `#sort_direction`, `#has_sort?` (alias `sorted_by?`), `#has_no_sort?`, `#has_sortable_column?` and `#has_no_sortable_column?`.
- A panel nested in another panel is found by its own title; before, the outer panel matched too and Capybara raised `Ambiguous`.

- `Table::Row#has_cell?`, `Table#has_row?`, `AttributesTable#has_row?` and their `has_no_` forms ignore case for a String `text:` or `exact_text:`. Chrome reports text as CSS shows it, so a theme that uppercases a value no longer breaks the match.
- `StringFilter` and `NumericFilter` drive a filter whose key holds its predicate, such as `filter :uuid_eq`: ActiveAdmin renders a bare input without a predicate select.
- `Form::Field#required?`, `#input` (the field's first control) and `#force_fill(text)`, which sets a text control's value with JavaScript past its `maxlength`.
- `Table#row_with(key, text)`, `#has_row_with?` and `#has_no_row_with?` find a row by a cell's text, for tables without record ids.
- `MainMenu#href(*labels)`, and `has_item?` and `has_no_item?` take `href:`: a path, a full URL or a Regexp.
- `have_semantic_errors` and `have_no_semantic_errors` take a Regexp, which matches part of a message.
- `ActiveAdminPageObjects.register_field_class(wrapper_class, field_class)` and `.register_filter_class(wrapper_class, filter_class)`: a theme or plugin maps the formtastic class of its own input to its section class, and `form.field` and `filters.filter` return that class without a declaration. A registered class wins over the gem's class.

## 1.0.0 (2026-11-24)

### Added

- Arguments that would make a matcher pass on any page raise `ArgumentError`: a record id that is not an Integer or a non-empty String in `Table#row`, `#has_row?` and `#has_no_row?`, an `only:` or `except:` scope that leaves no declared name, and a flash type of `nil`.
- `MainMenu#has_item?` and `#has_no_item?` wait, and take `wait:`.
- `DateRangeFilter#set` clears an end for `""` as for `nil`.
- `have_table` from `ActiveAdminPageObjects::RSpec::Matchers` calls the page object only when it defines `has_table?` itself, as `section :table` does; Capybara's own `has_table?` does not count.
- `Form::FileField` for formtastic's `file` input: `fill(path)` attaches the file, and `form.fill(attachment: path)` works. `Form#field` and `HasMany::Fieldset#field` return it by the input class.
- Disabled fields: `Form::Field#disabled?` and `#enabled?` on every field type, and `have_disabled_field(name)` and `have_enabled_field(name)` with their `have_no_` forms on a form and on a has_many fieldset.
- `have_status_tag` and `have_no_status_tag` look at every status tag of the cell, not only the first. `status_tags(key)` on an index row and on the attributes table returns all of them.
- `Form::FileField` for formtastic's `file` input: `fill(path)` attaches the file, and `form.fill(attachment: path)` works. `Form#field` returns it by the input class.
- Disabled fields: `Form::Field#disabled?` and `#enabled?` on every field type, and `have_disabled_field(name)` and `have_enabled_field(name)` with their `have_no_` forms on a form.
- `Table#has_row?(record_id)` and `#has_no_row?(record_id)`: `expect(table).to have_row(customer.id)`.
- Regexp titles: `Tabs#switch`, `have_tab`, `page.panel`, `page.sidebar` and the `:active_admin_panel` and `:active_admin_sidebar` selectors take a Regexp for a title with a changing part, such as "Possible Routes (2)". A String still compares the whole title.
- Regexp titles: `page.panel` and the `:active_admin_panel` selector take a Regexp for a title with a changing part, such as "Possible Routes (2)". A String still compares the whole title.
- `DownloadLinks`, declared with `section :download_links, ActiveAdminPageObjects::DownloadLinks`: `formats`, `have_format(format)`, `href(format)` and `click(format)` for the "Download: CSV XML JSON" links of an index page.
- Declared elements: `AttributesTable.row(key, label)`, `Table.column(key, label)`, `Filters.filter(name, label, type)` and `Form.field(name, label, type)` declare a section's elements with their labels, also inside a `section ... do` block. A filter or a field also needs its section class.
- `have_declared_rows`, `have_declared_columns`, `have_declared_filters` and `have_declared_fields` compare the declared labels with the page exactly. `have_exact_rows`, `have_exact_columns`, `have_exact_filters` and `have_exact_fields` also fail when the page has an element that is not declared. All take `only:` and `except:`. `declared_label_mismatches` and `exact_mismatches` return what differs.
- Lookups and matchers see only visible elements, as Capybara does by default. `visible: :all` on a call takes hidden elements too: `form.field(:notes, visible: :all)`, `have_exact_fields(visible: :all)`, `exact_mismatches(visible: :all)`. `visible: :all` on a declaration makes it the default for that element: `field :notes, "Notes", ActiveAdminPageObjects::Form::StringField, visible: :all`.
- Failure messages: with `ActiveAdminPageObjects::RSpec::Matchers` included, the `have_declared_*` and `have_exact_*` matchers and their `have_no_` forms list the missing elements, the unexpected elements and the labels that differ. `have_exact_field_errors` and `have_exact_semantic_errors` list the missing and the unexpected messages. `last_mismatches`, `last_field_errors` and `last_semantic_errors` return what the last of these matchers found.
- The untitled selection and actions columns of an index table are the columns `selectable` and `actions`, declared with the label `""`. ActiveAdmin 4 gives them no `data-column`.
- `Filters#filter` and `Form#field` return an instance of the declared class, and raise `ActiveAdminPageObjects::DeclaredClassMismatch`, a `Capybara::ExpectationNotMet`, unless it is the detected class or a subclass of it. `have_disabled_field` and `have_enabled_field` raise it too. To use your own field or filter class, declare it. A declaration defines no method on the section: reach it with `form.field(:name)` or `filters.filter(:name)`, and write your own methods in the section block for shortcuts.
- `Form.has_many(name, heading, &block)` declares a has_many block with the fields of its fieldsets, reached with `form.has_many(:name)`.
- A section with declarations raises `ArgumentError` for an undeclared name before it queries the page.
- Typed form fields: `Form#field` and `HasMany::Fieldset#field` return `Form::StringField`, `SelectField`, `BooleanField`, `RadioField`, `CheckBoxesField` or `DatePickerField` by the formtastic input class. Each has a `fill(value)` for its type. `form.fill(name: "Acme", active: false)` fills several fields in the given order, on a form and on a has_many fieldset.
- Form errors: `have_field_error`, `have_field_errors`, `have_exact_field_errors`, `have_semantic_errors` and `have_exact_semantic_errors(*messages, strict_order: false)`, each with its `have_no_` form. Has_many fieldsets have the field error matchers too.
- `have_status_tag(key, label, type: nil)` and `have_no_status_tag` on index rows and on the attributes table.
- `Panel#links` and `Sidebar#links` list the links of the body as `{ text:, href: }`, with the href as a path.
- Typed form fields: `Form#field` returns `Form::StringField`, `SelectField`, `BooleanField`, `RadioField`, `CheckBoxesField` or `DatePickerField` by the formtastic input class. Each has a `fill(value)` for its type. `DatePickerField` is the `date_picker` input, a native `<input type="date">`. `form.fill(name: "Acme", active: false)` fills several fields in the given order.
- Form errors: `have_field_error`, `have_field_errors`, `have_exact_field_errors`, `have_semantic_errors` and `have_exact_semantic_errors(*messages, strict_order: false)`, each with its `have_no_` form.
- `Panel#links` lists the links of the body as `{ text:, href: }`, with the `href` attribute as the page wrote it.
- `ActiveAdminPageObjects::RSpec::Matchers`, loaded with `require "active_admin_page_objects/rspec"`: the matcher names of capybara_active_admin 1.0.0, which call the predicate of a page object and that gem's matcher for anything else.
- `MainMenu#labels(*parents)` lists the item labels at a menu level. `MainMenu#click(*labels)` hovers each parent and clicks the item's link, as a user does; it sees visible items only, so a hidden submenu raises `Capybara::ElementNotFound`. `go` still visits the link's URL.
- Version 1.0.0: page objects for vanilla ActiveAdmin 3 only. The gem depends on `activeadmin` (>= 3.0, < 4.0.0.a). Vanilla ActiveAdmin 4 is the 2.x line on `main`.
- SitePrism page and sections for vanilla ActiveAdmin 3: layout, breadcrumbs, action items, flashes, main menu, index table, attributes table, panel, filters (string, numeric, select, boolean, date range), scopes, pagination, batch actions and formtastic forms.
- `HasMany`, reached with `form.has_many(:orders)`: count, add and remove fieldsets, and fill their fields.
- `StatusTag`, reached with `row.status_tag(:status)` and `attributes_table.status_tag(:status)`.
- `Sidebar`, reached with `page.sidebar("Help")`. `page.panel` skips sidebar sections and the comments panel.
- `ModalDialog`, reached with `page.modal_dialog`. `BatchActions#apply(label, inputs = {})` fills the dialog of an action with `confirm:` or `form:`.
- `Comments`, declared with `section :comments, ActiveAdminPageObjects::Comments`: read, add and delete comments.
- Table sorting: `Table#sort_by`, `#sorted_by` and `#has_sortable_column?`.
- `Tabs`, `UtilityNavigation` and `DropdownMenu` (`action_items.dropdown("More")`).
- `ActiveAdminPageObjects.register_selectors(**map)` takes only the selector map.
- `MainMenu#labels(*parents)` lists the item labels at a menu level. `MainMenu#click(*labels)` opens each collapsed parent with its toggle button and clicks the item's link, as a user does; it sees visible items only, so a hidden submenu raises `Capybara::ElementNotFound`. `go` still visits the link's URL.
- Version 2.x: page objects for vanilla ActiveAdmin 4 only. The gem now depends on `activeadmin` (>= 4.0.0.beta23, < 5.0.0.a): the comments section needs the `active-admin-comments-form` id of beta20, and beta23 is the version the suite runs on. Vanilla ActiveAdmin 3 moves to the 1.x line.
- SitePrism page and sections for vanilla ActiveAdmin 4: layout, breadcrumbs, action items, flashes, main menu, index table, attributes table, panel, filters (string, numeric, select, boolean, date range), scopes, pagination, batch actions and formtastic forms.
- `ActiveAdminPageObjects.register_selectors(**map)` takes only the selector map. It can also replace a key ActiveAdmin 4 removed, such as `tabs`.
- `ActiveAdminPageObjects::Layout.add_section` and `Layout.add_element` add a section or an element to every page that includes `Layout`, including page classes defined earlier.
- `ActiveAdminPageObjects::SelectControl` drives a visible native `<select>` for `SelectFilter`, `BooleanFilter`, `Form::SelectField`, `Form::Field` and the predicate select of `StringFilter` and `NumericFilter`. A `<select>` that is hidden or marked `aria-hidden="true"`, as a JavaScript select widget leaves it, raises `Capybara::ElementNotFound` when it is picked from or read. A section class for a widget overrides the private `native_select_visibility` to return `:all` and read the hidden select, and overrides `select_option` or `fill` to drive the widget. A gem with a widget on every select prepends a module into `SelectControl`.
- `ActiveAdminPageObjects.check_version!` for theme and plugin page objects.
- `dark_mode_toggle` and `user_menu_button` raise `NotInActiveAdmin3`: ActiveAdmin 3 has neither.
- `ActiveAdminPageObjects.check_version!` for theme and plugin page objects. Features ActiveAdmin 4 removed raise `RemovedInActiveAdmin4`.

### Removed

Expand Down
10 changes: 5 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ gem "rake"
gem "rspec", "~> 3.13"
gem "rubocop", "~> 1.80", require: false

# Dummy ActiveAdmin 3 app (spec/dummy): sprockets, jQuery from jquery-rails,
# Sass for active_admin.scss.
gem "activeadmin", "3.5.2"
# Dummy ActiveAdmin 4 app (spec/dummy): importmap + propshaft, Tailwind CSS
# built with the npm CLI.
gem "activeadmin", "4.0.0.beta23"
gem "cuprite"
gem "dartsass-sprockets"
gem "importmap-rails"
gem "propshaft"
gem "puma"
gem "rails", "~> 8.0"
gem "sprockets-rails"
gem "sqlite3"
Loading
Loading