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

Update validation schemas #603

Merged
merged 14 commits into from
Apr 18, 2024
Merged

Update validation schemas #603

merged 14 commits into from
Apr 18, 2024

Conversation

mira-kine
Copy link
Member

Closes #595

What changes did you make?

  • Updated regex in SignInForm with special characters regex in PasswordValidationSchema

Testing done for these changes

  • Tried signing up with special characters not explicit in SignIn but passes in SignUp, then tried signing back in. SignIn button was disabled until I used the same regex code for both.

Copy link
Member

@paulespinosa paulespinosa left a comment

Choose a reason for hiding this comment

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

@mira-kine Good start! Why isn't utils password validation schema being used here? And please add tests. Let us know if you would like any help.

Here's some ideas for test cases:

test123!
Testing!
Test123!
Test1234
12345678
7væVPj¼±mó5÷ÙÞW
Xin chào 1 bạn!

app/src/components/authentication/SignInForm.tsx Outdated Show resolved Hide resolved
…ema for password and kept only validation for presence of pw
@mira-kine
Copy link
Member Author

@paulespinosa the utils validation schemas is not shared across the components because we are validating differently here. In SignUp, we are using Formik + Yup to check that a user inputs a valid password before it is entered into the db, but for SignIn, we are only validating that there is a password at all. We had made this change after I made my PR, so I forgot to update it. Good catch - the PR should be updated with these changes now. I also updated the PR with the regex changes. Will be pushing up tests on SignUpForm special characters next.

@paulespinosa
Copy link
Member

@mira-kine Got it, makes sense. Thank you! The changes look good so far.

Copy link
Member

@Joshua-Douglas Joshua-Douglas left a comment

Choose a reason for hiding this comment

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

Hey @mira-kine,

Thanks for the changes. The code changes look great, but the test cases are failing and I have some comments on the docs.

I made some suggestions that should help fix the test cases but I have a few more observations:

  1. Running the test cases gives this warning:
Warning: An update to PasswordValidation inside a test was not wrapped in act(...).

When testing, code that causes React state updates should be wrapped into act(...):

act(() => {
  /* fire events that update state */
});
/* assert on the output */

I was able to dismiss it by wrapping the render and fireEvent calls in the act block. I'm not sure if there is a more elegant solution.

  1. SignInForm.should display error text test case is failing because the login form no longer contains the password must contain message. We removed that message in this PR, so you can remove that check.
  2. I couldn't get the 7væVPj¼±mó5÷ÙÞW test case to pass, even though this validation passes in the browser. I suspect there is an issue with the testing code, but I couldn't find it. Maybe @erikguntner might see the issue if you can't sort it out.

api/README.md Outdated Show resolved Hide resolved
api/README.md Outdated Show resolved Hide resolved
api/README.md Outdated Show resolved Hide resolved
app/src/components/__tests__/SignUpForm.test.tsx Outdated Show resolved Hide resolved
app/src/components/__tests__/SignUpForm.test.tsx Outdated Show resolved Hide resolved
@erikguntner erikguntner merged commit cc4c495 into main Apr 18, 2024
2 checks passed
@tylerthome tylerthome deleted the update-validation-schemas branch June 26, 2024 01:26
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.

Unifying Sign In and Sign Up Password Validation Schemes
5 participants