test(joint-core): fix originX/originY fitToContent expected rect [dev]#3368
Merged
kumilingus merged 1 commit intoJun 15, 2026
Merged
Conversation
Shifting grid anchor changes which grid lines bracket the content, so content's bounding edges may no longer align with the new grid — the returned rect grows/shifts accordingly. Prior expectation assumed the result was just the default-origin rect translated by (originX, originY), which would have left the top edge of the content outside the rect. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR corrects the expected rectangle in the fitToContent() test for non-zero originX/originY, aligning the test with the actual behavior where shifting the grid anchor changes which grid lines bracket the content (and can increase the resulting fitted dimensions).
Changes:
- Fixes the expected
fitToContent()rect fororiginX=50, originY=25withallowNewOrigin: 'any'. - Replaces the prior (incorrect) “translated-only” explanation with a grid-line–based snapping rationale consistent with the implementation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jul 3, 2026
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.
Summary
Follow-up to #3312. The
non-zero origin shifts the grid anchortest had wrong expected values — its expected rect (x: -50, y: -75, width: 300, height: 400) did not contain the content (top edge-75cut off content extending toy = -100).The expectation assumed the result was just the default-origin rect translated by
(originX, originY). But shifting the grid anchor changes which grid lines bracket the content, so dimensions can grow when content edges no longer align with the new grid.Trace (content
(-100,-100, 300×400),originX=50, originY=25, grid100×100,allowNewOrigin: 'any')50+n*100, y at25+m*100.[-100, 200]snaps to[-150, 250]→ width 400.[-100, 300]snaps to[-175, 325]→ height 500.{ x: -150, y: -175, width: 400, height: 500 }.Test plan
yarn workspace @joint/core test-client—fitToContent() > options > originX / originYpasses.