Skip to content

Fix entry order test expectations - #611

Open
duncanmcclean wants to merge 6 commits into
5.xfrom
fix-entry-order-test-expectations
Open

Fix entry order test expectations#611
duncanmcclean wants to merge 6 commits into
5.xfrom
fix-entry-order-test-expectations

Conversation

@duncanmcclean

@duncanmcclean duncanmcclean commented Aug 31, 2026

Copy link
Copy Markdown
Member

This pull request fixes EntryRepositoryTest's order assertions, which were failing against newer statamic/cms releases.

This was happening because statamic/cms (v6.29.0+, via statamic/cms#15238) fixed a bug where new entries in an orderable collection would collide at order = 1. New entries now correctly get their actual position (1, 2, 3, 4) as soon as they're created, instead of waiting for updateOrders() to be called explicitly. The tests were asserting the old, buggy behaviour with hardcoded values.

Since this package supports a wide statamic/cms version range (^6.10), and older supported versions don't have that fix, hardcoding either behaviour would break on the other. This PR fixes it by capturing each entry's order before the structure tree is saved, then asserting it's unchanged afterwards relative to that snapshot, rather than against hardcoded numbers. This tests the actual invariant (saving the structure doesn't affect order) regardless of which statamic/cms version is installed.

statamic/cms v6.20.3+ fixed new entries in orderable collections
colliding at `order = 1`. new entries now correctly get their
actual position (1, 2, 3, 4) as soon as they're created, instead
of waiting for `updateOrders()` to be called explicitly.
the previous fix hardcoded the expected `order` values, which only
held for statamic/cms v6.29+. older supported versions (still within
our ^6.10 constraint) don't have the fix from statamic/cms#15238, so
new entries in an orderable collection still collide at `order = 1`
until `updateOrders()` is called explicitly.

comparing against a snapshot taken before the structure save is
tested regardless of which behaviour is installed.
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.

1 participant