GeezerVison is showing github.com — fix: consider `ManhattanConnector` as orthogonal by tbouffard · Pull Request #707 · maxGraph/maxGraph
Conversation
tbouffard
commented
Mar 4, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Currently, the implementation of a connector must be explicitly referenced in the code to decide whether it is considered orthogonal.
This is not configurable.
So, when a new connector is added, its reference must be added. This was not done when ManhattanConnector was introduced.
ManhattanConnector is now referenced in Graph.isOrthogonal and Graph.createEdgeHandler.
Tests have been added to validate the correction and a refactoring of the implementation to simplify it.
Summary by CodeRabbit
- Refactor
- Improved the logic that determines how connections are handled, ensuring more consistent visuals and behavior.
- Tests
- Added comprehensive tests for the
isOrthogonal and createEdgeHandler methods, covering various edge cases to ensure robust performance and reliability.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Currently, the implementation of a connector must be explicitly referenced in the code to decide whether it is considered orthogonal.
This is not configurable.
So, when a new connector is added, its reference must be added. This was not done when `ManhattanConnector` was introduced.
ManhattanConnector is now referenced in `Graph.isOrthogonal` and `Graph.createEdgeHandler`.
tests have been added to validate the correction and a refactoring of the implementation to simplify it.
coderabbitai
Bot
commented
Mar 4, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Walkthrough
A new test file has been added to validate the graph object's isOrthogonal and createEdgeHandler methods using various edge styles and CellState configurations. The logic within the Graph class has been refactored to update condition ordering, include the EdgeStyle.Loop in a positive check, and replace direct null checks with the isNullish utility. No changes were made to the exported or public entity declarations.
Changes
| File(s) |
Change Summary |
| packages/core/tests/view/Graph.test.ts |
Introduced unit tests for isOrthogonal and createEdgeHandler covering multiple edge style scenarios and CellState configurations. |
| packages/core/src/view/Graph.ts |
Revised createEdgeHandler and isOrthogonal methods: adjusted condition ordering, repositioned the EdgeStyle.Loop check, and improved null checks using isNullish. |
Sequence Diagram(s)
sequenceDiagram
participant Client as Graph Client
participant Graph as Graph Class
participant Handler as Edge Handler Instance
Client->>Graph: call createEdgeHandler(state, edgeStyle)
alt edgeStyle is ElbowConnector/Loop
Graph-->>Handler: return ElbowEdgeHandler
else alt edgeStyle is ManhattanConnector/OrthogonalConnector/SegmentConnector
Graph-->>Handler: return EdgeSegmentHandler
else
Graph-->>Handler: return EdgeHandler
end
Loading
sequenceDiagram
participant Client as Graph Client
participant Graph as Graph Class
participant Utils as isNullish Utility
Client->>Graph: call isOrthogonal(edge)
Graph->>Utils: check edge's nullish values
Graph-->>Client: return boolean based on orthogonal property and edge style
Loading
Possibly related PRs
Suggested labels
enhancement
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 3f7e461 and 6cb572d.
📒 Files selected for processing (2)
packages/core/__tests__/view/Graph.test.ts (1 hunks)
packages/core/src/view/Graph.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/core/src/view/Graph.ts
- packages/core/tests/view/Graph.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: build (windows-2022)
- GitHub Check: build (macos-14)
- GitHub Check: build (ubuntu-22.04)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.
Generate unit testing code for this file.
Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitai in a new review comment at the desired location with your query. Examples:
@coderabbitai generate unit testing code for this file.
@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
@coderabbitai read src/utils.ts and generate unit testing code.
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pause to pause the reviews on a PR.
@coderabbitai resume to resume the paused reviews.
@coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
@coderabbitai full review to do a full review from scratch and review all the files again.
@coderabbitai summary to regenerate the summary of the PR.
@coderabbitai generate docstrings to generate docstrings for this PR.
@coderabbitai resolve resolve all the CodeRabbit review comments.
@coderabbitai configuration to show the current CodeRabbit configuration for the repository.
@coderabbitai help to get help.
Other keywords and placeholders
- Add
@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
- Add
@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
- Add
@coderabbitai anywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yaml file to the root of your repository.
- Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/core/__tests__/view/Graph.test.ts (1)
95-96: Incorrect test description.
The test description states "Expect EdgeSegmentHandler" but the assertion is actually checking for EdgeHandler.
-])('Expect EdgeSegmentHandler for edgeStyle: %s', (_name, edgeStyle) => {
+])('Expect EdgeHandler for edgeStyle: %s', (_name, edgeStyle) => {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 5b4dbde and 3f7e461.
📒 Files selected for processing (2)
packages/core/__tests__/view/Graph.test.ts (1 hunks)
packages/core/src/view/Graph.ts (3 hunks)
🔇 Additional comments (10)
packages/core/__tests__/view/Graph.test.ts (6)
31-36: Well-structured test for orthogonal property check in CellState.
The test correctly validates that a CellState with the orthogonal property set to true returns true when passed to graph.isOrthogonal(). This properly tests the first condition in the isOrthogonal method.
38-41: Good edge case test for undefined style.
Testing with no style in the CellState is an important edge case to validate the method returns false when no style is defined.
43-52: Great use of parameterized testing for edge styles.
Using test.each for testing multiple edge styles is efficient and maintains test clarity. The explicit inclusion of ManhattanConnector in this test case list validates the PR objective.
54-60: Good negative test case for Loop edge style.
Testing that the Loop edge style is not considered orthogonal is important for complete test coverage of the isOrthogonal method's behavior.
63-76: Comprehensive test for ElbowEdgeHandler creation.
This test correctly validates that the createEdgeHandler method returns an ElbowEdgeHandler for the specified edge styles, including Loop which was added to this condition in the implementation.
78-90: Proper test for EdgeSegmentHandler creation.
The test correctly verifies that ManhattanConnector, OrthogonalConnector, and SegmentConnector result in an EdgeSegmentHandler, which aligns with the implementation changes.
packages/core/src/view/Graph.ts (4)
1027-1033: Added EdgeStyle.Loop to the elbow edge handler condition.
The Loop edge style is now properly included in the condition that creates an ElbowEdgeHandler. This is a good improvement to the code organization.
1034-1039: ManhattanConnector now correctly recognized for EdgeSegmentHandler.
The ManhattanConnector is now properly included in the condition for creating an EdgeSegmentHandler, which fulfills the PR objective to consider ManhattanConnector as orthogonal.
1229-1233: Improved null check using isNullish utility.
Replacing the direct null check with the isNullish utility function is a good practice that improves code consistency and handles both null and undefined values.
1235-1249: Enhanced orthogonal edge style detection with ManhattanConnector.
The isOrthogonal method now properly includes ManhattanConnector in the list of orthogonal edge styles. The refactoring to use an array includes check improves code readability.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced May 2, 2025
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
bug
Something isn't working
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|