Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds workflow parsing to the diagram editor store so consumers can access a parsed workflow model and parsing/validation errors via context.
Changes:
- Introduces
contentprop toDiagramEditorand threads it through stories/tests. - Parses
contentinsideDiagramEditorContextProviderand exposesmodel+errorson context. - Expands test coverage to validate model/errors behavior for valid/invalid content.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/serverless-workflow-diagram-editor/src/diagram-editor/DiagramEditor.tsx | Adds required content prop and passes it into the context provider. |
| packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContextProvider.tsx | Parses content into model and errors and publishes them on context. |
| packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContext.tsx | Extends context type with model and errors. |
| packages/serverless-workflow-diagram-editor/tests/store/DiagramEditorContextProvider.test.tsx | Updates existing context tests and adds model/errors parsing tests. |
| packages/serverless-workflow-diagram-editor/tests/diagram-editor/DiagramEditor.test.tsx | Updates DiagramEditor test to pass content. |
| packages/serverless-workflow-diagram-editor/tests/diagram-editor/DiagramEditor.story.test.tsx | Updates story test to pass content. |
| packages/serverless-workflow-diagram-editor/stories/DiagramEditor.tsx | Threads content prop into the underlying component. |
| packages/serverless-workflow-diagram-editor/stories/DiagramEditor.stories.ts | Adds content arg placeholder for Storybook. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/serverless-workflow-diagram-editor/src/diagram-editor/DiagramEditor.tsx
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContextProvider.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContext.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContextProvider.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/store/DiagramEditorContextProvider.test.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/store/DiagramEditorContextProvider.test.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/store/DiagramEditorContextProvider.test.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/store/DiagramEditorContextProvider.test.tsx
Outdated
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/store/DiagramEditorContextProvider.test.tsx
Outdated
Show resolved
Hide resolved
15d2f92 to
3a36f43
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/serverless-workflow-diagram-editor/tests/store/DiagramEditorContextProvider.test.tsx
Show resolved
Hide resolved
packages/serverless-workflow-diagram-editor/tests/store/DiagramEditorContextProvider.test.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Lorna-Kelly <lornakelly88@gmail.com>
3a36f43 to
e93d57d
Compare
fantonangeli
left a comment
There was a problem hiding this comment.
Thanks @lornakelly , I suggested a small improvement to reduce the render numbers
| const [model, setModel] = React.useState<Specification.Workflow | null>(null); | ||
| const [errors, setErrors] = React.useState<Error[]>([]); |
There was a problem hiding this comment.
Adding this:
console.log("######## render");and changing the content you can see 2 renders because of the useEffect.
The code can be simplified with the following, to avoid re-rendering:
| const [model, setModel] = React.useState<Specification.Workflow | null>(null); | |
| const [errors, setErrors] = React.useState<Error[]>([]); | |
| const { model, errors } = React.useMemo(() => parseWorkflow(props.content), [props.content]); |
There was a problem hiding this comment.
Thanks for the suggestion Fabrizio! Yeah, I think this might introduce issues when editing features comes in but agree for MVP we can move to useMemo and evaluate in next phase when we need to change for editing.
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContextProvider.tsx
Outdated
Show resolved
Hide resolved
| React.useEffect(() => { | ||
| const result = parseWorkflow(props.content); | ||
| setModel(result.model); | ||
| setErrors(result.errors); | ||
| }, [props.content]); |
There was a problem hiding this comment.
| React.useEffect(() => { | |
| const result = parseWorkflow(props.content); | |
| setModel(result.model); | |
| setErrors(result.errors); | |
| }, [props.content]); |
| // 2 rendering cycles are expected: 1- first render, 2- content useEffect triggers state update | ||
| expect(renderCount).toHaveTextContent(/2/i); |
There was a problem hiding this comment.
| // 2 rendering cycles are expected: 1- first render, 2- content useEffect triggers state update | |
| expect(renderCount).toHaveTextContent(/2/i); | |
| expect(renderCount).toHaveTextContent(/1/i); |
| // 4 rendering cycles are expected 1- first render, 2- content useEffect triggers state update, 3- forced by rerender and 4- isReadOnly/locale useeffect state update | ||
| expect(renderCount).toHaveTextContent(/4/i); |
There was a problem hiding this comment.
| // 4 rendering cycles are expected 1- first render, 2- content useEffect triggers state update, 3- forced by rerender and 4- isReadOnly/locale useeffect state update | |
| expect(renderCount).toHaveTextContent(/4/i); | |
| expect(renderCount).toHaveTextContent(/3/i); |
| // 3 rendering cycles are expected 1- first render, 2- content useEffect triggers state update and 3- forced by rerender | ||
| expect(renderCount).toHaveTextContent(/3/i); |
There was a problem hiding this comment.
| // 3 rendering cycles are expected 1- first render, 2- content useEffect triggers state update and 3- forced by rerender | |
| expect(renderCount).toHaveTextContent(/3/i); | |
| expect(renderCount).toHaveTextContent(/2/i); |
Signed-off-by: Lorna-Kelly <lornakelly88@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await waitFor(() => { | ||
| // Model is still returned as parsing succeeded but has validation errors | ||
| expect(modelElement).toBeInTheDocument(); | ||
| expect(errorsElement).toHaveTextContent("1"); | ||
| }); |
There was a problem hiding this comment.
Asserting an exact error count (\"1\") is brittle: validation can legitimately return multiple errors as rules evolve, causing unrelated test failures. Prefer asserting errors.length > 0 (or checking for a specific error shape/message/code if stable) so the test verifies the intended behavior without over-constraining the exact number.
Closes: #49
Summary
Adds parsed workflow model and validation errors to the
DiagramEditorstore, establishing a single source of truth for workflow data accessible throughout the componentFiles Modified