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

[test(auth)]: Add unit tests for useSignInUpForm hook #9648

Merged
merged 3 commits into from
Jan 15, 2025

Conversation

AMoreaux
Copy link
Contributor

Introduce unit tests to validate the behavior of the useSignInUpForm hook. Tests cover default initialization, handling of developer defaults, and prefilled values based on state.

Verified

This commit was signed with the committer’s verified signature.
Introduce unit tests to validate the behavior of the useSignInUpForm hook. Tests cover default initialization, handling of developer defaults, and prefilled values based on state.
@AMoreaux AMoreaux self-assigned this Jan 15, 2025
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 comprehensive unit tests for the useSignInUpForm hook, validating form initialization and state-dependent prefill behavior in the authentication flow.

  • Added test cases in /packages/twenty-front/src/modules/auth/sign-in-up/hooks/__tests__/useSignInUpForm.test.tsx for form initialization and developer default prefilling
  • Tests verify correct handling of URL email parameters and developer prefill state
  • Hardcoded password 'Applecar2025' in tests should be moved to a test constants file
  • Commented-out test case for prefilled email functionality should be implemented
  • Missing test coverage for password validation using PASSWORD_REGEX

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

</MemoryRouter>
),
});
expect(result.current.form).toBeDefined();
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This assertion only checks if form exists. Should verify the actual default values.

Comment on lines 24 to 27
// it('should set prefilled email if available', () => {
// renderHook(() => useSignInUpForm());
// expect(mockSetValue).toHaveBeenCalledWith('email', mockPrefilledEmail);
// });
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Incomplete test case left commented out. Either implement or remove.

jest.clearAllMocks();
});

it('should initialize the form with default values', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Test is marked async but doesn't use any await statements

Introduce unit tests to validate the behavior of the useSignInUpForm hook. Tests cover default initialization, handling of developer defaults, and prefilled values based on state.
@Weiko Weiko merged commit 266b771 into main Jan 15, 2025
34 checks passed
@Weiko Weiko deleted the chore/increase-coverage branch January 15, 2025 17:07
Copy link
Contributor

Fails
🚫

node failed.

Log

�[31mError: �[39m SyntaxError: Unexpected token C in JSON at position 0
    at JSON.parse (<anonymous>)
�[90m    at parseJSONFromBytes (node:internal/deps/undici/undici:5584:19)�[39m
�[90m    at successSteps (node:internal/deps/undici/undici:5555:27)�[39m
�[90m    at fullyReadBody (node:internal/deps/undici/undici:1665:9)�[39m
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)�[39m
�[90m    at async specConsumeBody (node:internal/deps/undici/undici:5564:7)�[39m
danger-results://tmp/danger-results-404d273f.json

Generated by 🚫 dangerJS against 72a909e

pacyL2K19 pushed a commit to pacyL2K19/twenty that referenced this pull request Jan 16, 2025
Introduce unit tests to validate the behavior of the useSignInUpForm
hook. Tests cover default initialization, handling of developer
defaults, and prefilled values based on state.
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.

None yet

2 participants