test: verify AbstractGraph.createHandler factory method delegation#819
test: verify AbstractGraph.createHandler factory method delegation#819
Conversation
Add tests ensuring `AbstractGraph.createEdgeHandler` properly delegates to specialized factory methods (createElbowEdgeHandler and createEdgeSegmentHandler) based on edge style registry configuration. Tests cover both built-in edge styles and custom handler implementations.
WalkthroughThe test suite for the Graph's Changes
Sequence Diagram(s)sequenceDiagram
participant TestSuite
participant Graph
participant EdgeStyleRegistry
participant CustomEdgeHandler
TestSuite->>Graph: createEdgeHandler(edge)
Graph->>EdgeStyleRegistry: getHandlerKind(style)
alt handlerKind is 'elbow'
Graph->>CustomEdgeHandler: createElbowEdgeHandler()
else handlerKind is 'segment'
Graph->>CustomEdgeHandler: createEdgeSegmentHandler()
else
Graph->>CustomEdgeHandler: createEdgeHandlerInstance()
end
Graph-->>TestSuite: returns instance of custom handler
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (5)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/core/__tests__/view/Graph.test.ts (1)
215-215: Consider cleaning up registered edge stylesThe tests register custom edge styles but don't unregister them afterward. While this doesn't appear to affect the current test suite (due to the isolated nature of each test), consider adding cleanup code to ensure test isolation.
test('elbow', () => { class CustomEdgeHandler extends ElbowEdgeHandler {} const edgeStyle = customEdgeStyle; EdgeStyleRegistry.add('custom', edgeStyle, { handlerKind: 'elbow' }); + afterAll(() => { + EdgeStyleRegistry.remove('custom'); + }); // ...test implementation... });Also applies to: 231-231
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/core/__tests__/view/Graph.test.ts(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/core/__tests__/view/Graph.test.ts (2)
packages/core/src/index.ts (1)
BaseGraph(21-21)packages/core/src/view/style/edge/EdgeStyleRegistry.ts (1)
EdgeStyleRegistry(65-65)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: build (windows-2022)
- GitHub Check: build (ubuntu-22.04)
- GitHub Check: build (macos-14)
- GitHub Check: build
🔇 Additional comments (6)
packages/core/__tests__/view/Graph.test.ts (6)
27-27: Appropriate import additionAdded
EdgeStyleRegistryimport is necessary for the new tests to register custom edge styles with specific handler kinds.
195-195: Well-named test groupThe "Custom edge handler" describe block clearly indicates its purpose of testing custom edge handler functionality.
196-210: Good test for default handler customizationThis test properly verifies that the graph uses a custom
EdgeHandlersubclass whencreateEdgeHandlerInstanceis overridden.Note that line 199 is commented out, which appears intentional as this test doesn't require the style to be registered with the registry (it's testing the default case).
212-226: Correct verification of elbow handler delegationThis test properly verifies that when a custom style is registered with
handlerKind: 'elbow', the graph delegates to the overriddencreateElbowEdgeHandlermethod.
228-242: Correct verification of segment handler delegationThis test properly verifies that when a custom style is registered with
handlerKind: 'segment', the graph delegates to the overriddencreateEdgeSegmentHandlermethod.
195-243: Good test coverage for createEdgeHandler factory method delegationThese tests effectively verify that
AbstractGraph.createEdgeHandlercorrectly delegates to specialized factory methods based on edge style registry configuration. The tests cover both built-in edge styles (in the existing tests) and custom handler implementations (in the new tests).The tests are well-structured with consistent patterns:
- Define a custom handler class
- Register the edge style with appropriate handler kind
- Override the appropriate factory method
- Verify the correct handler instance is created
This aligns perfectly with the PR objectives to verify factory method delegation.
|



Add tests ensuring
AbstractGraph.createEdgeHandlerproperly delegates to specialized factory methods(createElbowEdgeHandler and createEdgeSegmentHandler) based on edge style registry configuration.
Tests cover both built-in edge styles and custom handler implementations.
This prepares the move of these methods to
SelectionCellsHandlerwhere they are used.Notes
Covers #762
Summary by CodeRabbit
Summary by CodeRabbit