Skip to content

test(joint-core): fix originX/originY fitToContent expected rect [dev]#3368

Merged
kumilingus merged 1 commit into
clientIO:devfrom
kumilingus:fix/fit-to-content-area-origin-test
Jun 15, 2026
Merged

test(joint-core): fix originX/originY fitToContent expected rect [dev]#3368
kumilingus merged 1 commit into
clientIO:devfrom
kumilingus:fix/fit-to-content-area-origin-test

Conversation

@kumilingus

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #3312. The non-zero origin shifts the grid anchor test had wrong expected values — its expected rect (x: -50, y: -75, width: 300, height: 400) did not contain the content (top edge -75 cut off content extending to y = -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, grid 100×100, allowNewOrigin: 'any')

  • Grid lines: x at 50+n*100, y at 25+m*100.
  • Content x ∈ [-100, 200] snaps to [-150, 250] → width 400.
  • Content y ∈ [-100, 300] snaps to [-175, 325] → height 500.
  • Correct rect: { x: -150, y: -175, width: 400, height: 500 }.

Test plan

  • yarn workspace @joint/core test-clientfitToContent() > options > originX / originY passes.

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>

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.

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 for originX=50, originY=25 with allowNewOrigin: '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.

@kumilingus kumilingus merged commit 1e2d9d7 into clientIO:dev Jun 15, 2026
@kumilingus kumilingus requested a review from zbynekstara June 15, 2026 14:12
@zbynekstara zbynekstara changed the title test(joint-core): fix originX/originY fitToContent expected rect test(joint-core): fix originX/originY fitToContent expected rect [dev] Jun 15, 2026
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