Fix entry order test expectations - #611
Open
duncanmcclean wants to merge 6 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request fixes
EntryRepositoryTest's order assertions, which were failing against newerstatamic/cmsreleases.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 atorder = 1. New entries now correctly get their actual position (1,2,3,4) as soon as they're created, instead of waiting forupdateOrders()to be called explicitly. The tests were asserting the old, buggy behaviour with hardcoded values.Since this package supports a wide
statamic/cmsversion 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'sorderbefore 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 whichstatamic/cmsversion is installed.