This document provides information about the test suite for the Siyoga Travel System, focusing on the tourist registration functionality.
The test suite is organized as follows:
-
UI Component Tests - Located in
frontend/src/tests/pages/auth/TouristRegister.test.jsx- Tests the TouristRegister component rendering and functionality
- Validates form inputs, error handling, and submission
-
End-to-End Tests - Located in
frontend/src/tests/e2e/touristRegistration.test.js- Uses Cypress to test the full registration flow
- Simulates user interactions and API responses
-
Controller Tests - Located in
backend/src/tests/controllers/authController.test.js- Tests the registerTourist controller function
- Validates input handling, error cases, and successful registration
-
Route Tests - Located in
backend/src/tests/routes/authRoutes.test.js- Tests the auth routes for registration, verification, and login
- Ensures proper routing and response handling
-
Integration Tests - Located in
backend/src/tests/integration/touristRegistration.test.js- Tests the full API flow for tourist registration
- Validates the interaction between routes, controllers, and database
To run the frontend tests:
# Navigate to the frontend directory
cd frontend
# Install dependencies if not already installed
npm install
# Run Jest tests
npm test
# Run specific test file
npm test -- src/tests/pages/auth/TouristRegister.test.jsx
# Run E2E tests with Cypress
npm run cypress:open
# Then select touristRegistration.test.js from the Cypress UITo run the backend tests:
# Navigate to the backend directory
cd backend
# Install dependencies if not already installed
npm install
# Run all tests
npm test
# Run specific test file
npm test -- src/tests/controllers/authController.test.jsThe test suite aims to cover:
-
Form Validation
- Required fields
- Email format
- Password strength and matching
- Phone number format
- Date of birth validation
- Gender validation
-
API Validation
- Input validation
- Error handling
- Database interactions
- Email verification
-
User Flow
- Registration process
- Error messages
- Success messages
- Redirection
When adding new features to the tourist registration process, please follow these guidelines:
- Create unit tests for any new components or functions
- Update existing tests if you modify existing functionality
- Add integration tests for new API endpoints
- Update E2E tests to cover the new user flows
The tests use various mocking strategies:
- API Mocks - Using Jest's
jest.fn()andmockImplementation() - Database Mocks - Mocking the database queries to avoid actual database connections
- External Services - Mocking email services, verification services, etc.
- Browser APIs - Mocking
localStorage,fetch, etc.
If tests are failing, check the following:
- Ensure all dependencies are installed
- Check that environment variables are properly set in the test setup files
- Verify that mocks are correctly implemented
- Check for changes in component structure or API contracts
For more help, contact the development team.