Add extended graph and dummy auto-layout #59#77
Add extended graph and dummy auto-layout #59#77handreyrc wants to merge 1 commit intoserverlessworkflow:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds SDK graph generation support to the diagram editor core by introducing extended graph types (node size/position, edge types/waypoints), exposing a buildGraph wrapper, and providing a dummy auto-layout implementation with accompanying tests/snapshots.
Changes:
- Added extended graph type definitions and edge-type enrichment (
solveEdgeTypes). - Exposed
buildGraphvia the core SDK wrapper and re-exported core modules. - Added a dummy
applyAutoLayoutimplementation plus integration/unit tests and snapshots.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/serverless-workflow-diagram-editor/tests/fixtures/workflows.ts | Added new JSON/YAML workflow fixtures used by graph + auto-layout tests. |
| packages/serverless-workflow-diagram-editor/tests/core/workflowSdk.integration.test.ts | Added integration coverage for buildGraph and extended graph typing/snapshot. |
| packages/serverless-workflow-diagram-editor/tests/core/graph.test.ts | New unit tests for edge type enrichment across default/error/condition/nested cases. |
| packages/serverless-workflow-diagram-editor/tests/core/autoLayout.integration.test.ts | New integration test verifying dummy auto-layout positions/sizes and snapshot. |
| packages/serverless-workflow-diagram-editor/tests/core/snapshots/workflowSdk.integration.test.ts.snap | Snapshot for buildGraph result. |
| packages/serverless-workflow-diagram-editor/tests/core/snapshots/autoLayout.integration.test.ts.snap | Snapshot for applyAutoLayout result. |
| packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts | Switched to SDK namespace import; added buildGraph wrapper returning extended graph. |
| packages/serverless-workflow-diagram-editor/src/core/index.ts | Re-exported graph and autoLayout modules. |
| packages/serverless-workflow-diagram-editor/src/core/graph.ts | Added extended graph types and solveEdgeTypes. |
| packages/serverless-workflow-diagram-editor/src/core/autoLayout.ts | Added dummy applyAutoLayout implementation to set size/position. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/serverless-workflow-diagram-editor/tests/fixtures/workflows.ts
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/core/graph.test.ts
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/src/core/autoLayout.ts
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/core/graph.test.ts
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/fixtures/workflows.ts
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/fixtures/workflows.ts
Outdated
Show resolved
Hide resolved
lornakelly
left a comment
There was a problem hiding this comment.
Thanks for PR Handrey, nice work. Just a few comments
| } | ||
|
|
||
| export function buildGraph(model: sdk.Specification.Workflow): ExtendedGraph { | ||
| return solveEdgeTypes(sdk.buildGraph(model)); |
There was a problem hiding this comment.
Wondering should we wrap this in a try/catch in case sdk buildGraph throws and maybe worth splitting into 2 steps first call sdk.buildGraph(model) and get result and then pass to solveEdgeTypes? wdyt?
There was a problem hiding this comment.
The buildGraph is an extension of the original function in the SDK. A try/catch would just catch the exception and throw the same exception to the caller to be handled. I think we should leave the exception handling to the callers. Same as using the original method from the skd.
WDYT?
packages/serverless-workflow-diagram-editor/tests/core/graph.test.ts
Outdated
Show resolved
Hide resolved
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
There was a problem hiding this comment.
Would be good to have some negative test cases as well?
There was a problem hiding this comment.
@lornakelly
The code that builds the graph is actually in the sdk, so we should trust it from the perspective of the editor's components. We are just adding some properties on top of it.
WDYT?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/serverless-workflow-diagram-editor/src/core/autoLayout.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const { model } = parseWorkflow(BASIC_VALID_WORKFLOW_JSON_TASKS); | ||
| expect(model).not.toBeNull(); |
There was a problem hiding this comment.
This buildGraph integration test uses parseWorkflow but doesn't assert that errors is empty before calling buildGraph(model!). Since parseWorkflow includes SDK validation, the test should explicitly check there are no validation errors to avoid masking fixture/SDK regressions.
| const { model } = parseWorkflow(BASIC_VALID_WORKFLOW_JSON_TASKS); | |
| expect(model).not.toBeNull(); | |
| const { model, errors } = parseWorkflow(BASIC_VALID_WORKFLOW_JSON_TASKS); | |
| expect(model).not.toBeNull(); | |
| expect(errors).toHaveLength(0); |
| const graph = buildGraph(result.model!); | ||
|
|
There was a problem hiding this comment.
In this test, parseWorkflow can return a non-null model and validation errors. Since the test is asserting behavior on a "valid" workflow graph, it should also assert result.errors is empty (and avoid relying on model!) to prevent silently passing with an invalid fixture/SDK validation failure.
| const graph = buildGraph(result.model!); | |
| expect(result.errors).toEqual([]); | |
| expect(result.model).toBeDefined(); | |
| if (!result.model) { | |
| throw new Error("Expected parseWorkflow to return a model for a valid workflow fixture."); | |
| } | |
| const graph = buildGraph(result.model); |
| const { model } = parseWorkflow(BASIC_VALID_WORKFLOW_JSON_TASKS); | ||
| expect(model).not.toBeNull(); | ||
|
|
||
| const graph = buildGraph(model!); | ||
| expect(graph).not.toBeNull(); |
There was a problem hiding this comment.
These tests treat the workflows as valid inputs to buildGraph, but they only check model and ignore parseWorkflow(...).errors. Since parseWorkflow performs SDK validation, please assert errors is empty (and only then call buildGraph) so the graph edge-type assertions don't pass when validation fails for the fixture.
Closes #59
Summary
This PR adds dummy auto-layout and extended graph types.
Changes