Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a few tests on workflow hooks #8800

Merged
merged 1 commit into from
Nov 28, 2024
Merged

Conversation

thomtrp
Copy link
Contributor

@thomtrp thomtrp commented Nov 28, 2024

As title

@thomtrp thomtrp enabled auto-merge (squash) November 28, 2024 16:43
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Added test coverage for three workflow hooks, focusing on basic functionality verification of schema computation, workflow version creation, and step creation processes.

  • Test for useComputeStepOutputSchema in /packages/twenty-front/src/modules/workflow/hooks/__tests__/useComputeStepOutputSchema.test.ts needs error handling scenarios
  • Test for useCreateNewWorkflowVersion in /packages/twenty-front/src/modules/workflow/hooks/__tests__/useCreateNewWorkflowVersion.test.ts should verify data structure integrity
  • Test for useCreateStep in /packages/twenty-front/src/modules/workflow/hooks/__tests__/useCreateStep.test.ts should validate mock function arguments and test non-draft version scenarios
  • Missing validation for edge cases where input parameters are invalid or undefined
  • Tests should verify the integration between computeStepOutputSchema and step creation workflow

3 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile


describe('useComputeStepOutputSchema', () => {
it('should compute schema successfully', async () => {
const mockInput = { stepId: '123' };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: mockInput doesn't match implementation - useComputeStepOutputSchema expects a full step object, not just stepId


const { result } = renderHook(() => useCreateNewWorkflowVersion());
await result.current.createNewWorkflowVersion(
workflowVersionData as unknown as WorkflowVersion,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Double type assertion is unnecessary and could mask type errors. Consider defining proper types or using a single assertion.

Comment on lines +78 to +79
expect(mockUpdateOneWorkflowVersion).toHaveBeenCalled();
expect(mockOpenRightDrawer).toHaveBeenCalled();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Add expectations for the actual arguments passed to these mocked functions to ensure they're called with correct parameters

@Devessier Devessier self-requested a review November 28, 2024 16:46
Copy link
Contributor

@Devessier Devessier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I love these tests!
We can merge.

@thomtrp thomtrp merged commit 3573d89 into main Nov 28, 2024
19 checks passed
@thomtrp thomtrp deleted the tt-add-tests-on-workflow-hooks branch November 28, 2024 16:54
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