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

Optimize user data fetching and api logic #11

Merged
merged 7 commits into from
Sep 29, 2024
Merged

Optimize user data fetching and api logic #11

merged 7 commits into from
Sep 29, 2024

Conversation

Fingertips18
Copy link
Owner

  • Added Select to the user retrieval query
    to minimize the data fetched from the database,
    improving performance and reducing memory usage.
  • Updated the user object with the latest information
    fetched from the verifyToken function, ensuring that
    only the necessary fields are loaded and modified.
  • This change enhances the efficiency of user operations
    by focusing on relevant fields during database interactions.

- Installed **Vitest** for `unit testing` framework.
- Created test cases for the `formatDate` utility function to ensure correct formatting of valid date strings.
- Added validation tests for `username`, `email`, `password`, and `confirm password` fields to verify proper validation logic.
- Updated the testing configuration to support the new tests and ensure they run successfully.
- Implemented tests for the `useResize` hook to verify behavior across different screen sizes.
- Added tests for the `useTheme` hook to check the default theme and verify that it updates to light or dark when changed.
- Added a test to ensure the `ThemeProvider` correctly applies the selected `theme`
  to the document's `root` element.
- Mocked `localStorage` to return a predefined `theme` value for testing.
- Verified that the appropriate `class` is applied to `document.documentElement`
  based on the `theme`.
- Implemented tests for `userStore` to verify user state
  and persistence in session storage.
- Created tests for `authStore` to ensure authentication
  logic and state management function correctly.
Implemented tests for the following **AuthService** methods:

- `signIn`: Verified successful sign-in and error handling.
- `signUp`: Tested user registration process and error responses.
- `signOut`: Checked the sign-out functionality.
- `verifyEmail`: Confirmed email verification process.
- `resendVerify`: Ensured resend verification logic works as expected.
- `verifyToken`: Tested token verification and error handling.
- `forgotPassword`: Validated forgot password request handling.
- `resetPassword`: Checked password reset process.
- `changePassword`: Tested password change functionality.
- Created unit tests for `AuthGuard` and `PrivateGuard`
  components to ensure proper functionality.
- Verified that guards correctly redirect unauthorized users
  and allow access for authorized users.
- Added `Select` to the user retrieval query
  to minimize the data fetched from the database,
  improving performance and reducing memory usage.
- Updated the user object with the latest information
  fetched from the verifyToken function, ensuring that
  only the necessary fields are loaded and modified.
- This change enhances the efficiency of user operations
  by focusing on relevant fields during database interactions.
@Fingertips18 Fingertips18 merged commit 0b42037 into main Sep 29, 2024
1 check passed
@Fingertips18 Fingertips18 deleted the development branch September 29, 2024 08:50
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.

1 participant