Add CI workflow and comprehensive test suite#52
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds GitHub Actions CI workflow and a comprehensive test suite for the frontend Next.js application. The PR includes Jest configuration, 132 tests across 11 test files covering various components and pages, and a CI pipeline for automated testing.
Changes:
- Added GitHub Actions CI workflow for linting, type-checking, testing, and building
- Configured Jest with Next.js integration and testing library setup
- Added 132 comprehensive unit tests for components (LoginForm, Header, Toast, ConfirmDialog, SearchableSelect, EquipmentList, SaveToCartButton, ProtectedRoute) and pages (CartPage), plus context hook validation tests
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/ci.yml | Adds CI pipeline with lint, type-check, test, and build steps |
| jest.config.ts | Configures Jest for Next.js with module mapping and coverage settings |
| jest.setup.ts | Imports testing-library/jest-dom for test assertions |
| package.json | Adds test scripts and testing dependencies (Jest, Testing Library, etc.) |
| src/tests/pages/CartPage.test.tsx | Tests cart display, item removal, clear cart, and empty state (17 tests) |
| src/tests/contexts/CartContext.test.tsx | Tests CartContext hook validation (1 test) |
| src/tests/contexts/AuthContext.test.tsx | Tests AuthContext hook validation (1 test) |
| src/tests/components/Toast.test.tsx | Tests toast display, auto-dismiss, and timing (6 tests) |
| src/tests/components/SearchableSelect.test.tsx | Tests dropdown, filtering, selection, and keyboard interactions (12 tests) |
| src/tests/components/SaveToCartButton.test.tsx | Tests button states, validation, and cart payload (15 tests) |
| src/tests/components/ProtectedRoute.test.tsx | Tests auth guards and route protection (8 tests) |
| src/tests/components/LoginForm.test.tsx | Tests form validation, submission, and error handling (14 tests) |
| src/tests/components/Header.test.tsx | Tests navigation, cart icon, and logout functionality (11 tests) |
| src/tests/components/EquipmentList.test.tsx | Tests equipment display, toggle, and quantity changes (11 tests) |
| src/tests/components/ConfirmDialog.test.tsx | Tests modal display, buttons, and keyboard handling (12 tests) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Tests all login functionality including validation, submission, error handling | ||
| */ | ||
| import React from 'react'; | ||
| import { render, screen, fireEvent, waitFor } from '@testing-library/react'; |
There was a problem hiding this comment.
Unused import fireEvent.
| import { render, screen, fireEvent, waitFor } from '@testing-library/react'; | |
| import { render, screen, waitFor } from '@testing-library/react'; |
There was a problem hiding this comment.
Fixed - Removed unused fireEvent import. The test uses userEvent instead for user interactions.
NoamBenShimon
left a comment
There was a problem hiding this comment.
Thanks for implementing that. It's useful to have in the repository.
- Add GitHub Actions CI workflow (.github/workflows/ci.yml) - Add Jest configuration for Next.js (jest.config.ts, jest.setup.ts) - Add 132 tests covering all components: - LoginForm: validation, submission, error handling - ProtectedRoute: auth guards, redirects - Header: navigation, cart icon, logout - SearchableSelect: filtering, selection, dropdown - EquipmentList: toggle, quantity changes - SaveToCartButton: validation, payload, temp disable - ConfirmDialog: buttons, keyboard, backdrop - Toast: timing, auto-dismiss - CartPage: empty state, items, remove, clear - Auth/Cart contexts: hook validation - Update package.json with test scripts
- Fix grammar: '1 items' -> '1 item' in SaveToCartButton test - Simplify button selector in CartPage removeFromCart test - Add assertion to Toast cleanup test
606ac09 to
c081053
Compare
Summary
Adds GitHub Actions CI and a comprehensive test suite for the frontend.
Changes
CI Workflow (
.github/workflows/ci.yml)Jest Configuration
jest.config.ts- Jest setup for Next.jsjest.setup.ts- Testing library setup132 Tests covering:
LoginForm- validation, submission, error handling (14 tests)ProtectedRoute- auth guards, redirects (8 tests)Header- navigation, cart icon, logout (11 tests)SearchableSelect- filtering, selection, dropdown (12 tests)EquipmentList- toggle, quantity changes (11 tests)SaveToCartButton- validation, payload, temp disable (15 tests)ConfirmDialog- buttons, keyboard, backdrop (12 tests)Toast- timing, auto-dismiss (6 tests)CartPage- empty state, items, remove, clear (17 tests)AuthContext/CartContext- hook validation (2 tests)Testing
npm test