feat: added unit testing for frontend components using vitest #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
🧪 Added Frontend Test Coverage (Vitest + React Testing Library)
Implemented comprehensive test cases for Navbar, Browse (Product Cards), SignIn, and SignUp components to ensure stable and predictable UI behaviour.
🧭 Navbar Component (5 Tests)
Renders brand name and navigation links correctly.
Highlights active link based on current route.
Toggles between light/dark themes.
Opens and closes the mobile menu (hamburger icon).
Navigates correctly when clicking on “Sign In” and “Sign Up” buttons.
🛒 Browse (Product Cards) (5 Tests)
Renders the page heading and product cards.
Filters products using the search bar.
Opens filter drawer and applies category filters.
Clears filters using the “Clear” button.
Displays alert when “Add to Cart” is clicked.
🔐 SignIn Form (5 Tests)
Renders form fields (email, password) and submit button.
Validates empty field errors.
Displays error for invalid credentials.
Navigates on successful login mock.
Renders link to SignUp page.
📝 SignUp Form (5 Tests)
Renders all input fields and the submit button.
Validates required fields and shows errors.
Checks password confirmation mismatch.
Mocks successful submission flow.
Renders link to SignIn page.
✅ All test suites pass successfully (npm run test) — improving reliability and ensuring key UI flows are covered.
Semver Changes
Issues
Checklist