Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
],
"rules": {
"@typescript-eslint/no-unused-vars": [
"warn"
"error",
{
"argsIgnorePattern": "^_"
}
],
"no-unused-vars": [
"warn"
"error",
{
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-explicit-any": "warn",
"prettier/prettier": "error",
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:

- name: Extract repo name
id: repo
run: echo "REPO_NAME=$(echo ${{ github.repository }} | awk -F'/' '{print $2}')" >> $GITHUB_ENV
run: echo "REPO_NAME=$(echo ${{ github.repository }} | awk -F'/' '{print tolower($2)}')" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v5
Expand All @@ -62,4 +62,4 @@ jobs:

- name: Image digest
run: |
echo "Image pushed: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}:${{ github.sha }}"
echo "Image pushed: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}:${{ github.sha }}"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.env
.env.local
env.local
docker-compose.yml

# Dependencies
node_modules/
Expand Down
140 changes: 140 additions & 0 deletions TEST_PLAN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Test Coverage Improvement Plan

## Current Coverage Status
- Overall: 27.05%
- Branches: 53.65%
- Functions: 11.47%
- Lines: 27.05%

## Priority Areas

### 1. Controllers (7.8%)

#### High Priority
- `auth.controller.ts` (18.21%)
- [ ] Test successful user registration
- [ ] Test password validation
- [ ] Test email validation
- [ ] Test OTP verification
- [ ] Test OAuth flows (Google/Facebook)
- [ ] Test refresh token functionality

#### Medium Priority
- `product.controller.ts` (7.89%)
- [ ] Test product creation
- [ ] Test product updates
- [ ] Test product deletion
- [ ] Test product listing
- [ ] Test product search

- `order.controller.ts` (5.58%)
- [ ] Test order creation
- [ ] Test order status updates
- [ ] Test order listing
- [ ] Test order cancellation

#### Lower Priority
- `notification.controller.ts` (5.18%)
- `product.search.controller.ts` (4.95%)
- `review.controller.ts` (4.77%)
- `user.controller.ts` (7.1%)

### 2. Middleware (26.07%)

#### High Priority
- `auth-check.ts` (6.77%)
- [ ] Test token validation
- [ ] Test role-based access
- [ ] Test expired tokens
- [ ] Test malformed tokens

#### Medium Priority
- `multerStorage.ts` (33.92%)
- [ ] Test file upload success
- [ ] Test file size limits
- [ ] Test file type validation
- [ ] Test storage configuration

- `handleExpoResponse.ts` (10.86%)
- [ ] Test notification sending
- [ ] Test error handling
- [ ] Test device token validation

#### Lower Priority
- `send-notification.ts` (7.4%)
- `rateLimiter.ts` (76.19% - already decent)

### 3. Models (73.21%)

#### High Priority
- `index.ts` (0%)
- [ ] Test model associations
- [ ] Test database connection
- [ ] Test model synchronization

### 4. Routes (72.39%)

#### High Priority
- `payment.collection.routes.ts` (64.51%)
- [ ] Test payment initiation
- [ ] Test payment callbacks
- [ ] Test payment status updates

#### Medium Priority
- `review.routes.ts` (60%)
- [ ] Test review creation
- [ ] Test review updates
- [ ] Test review deletion

- `user.routes.ts` (63.33%)
- [ ] Test profile updates
- [ ] Test address management
- [ ] Test settings updates

## Implementation Strategy

1. **Setup Improvements**
- [ ] Create test utilities for common operations
- [ ] Set up test database configuration
- [ ] Create mock factories for test data
- [ ] Improve test isolation

2. **Testing Approach**
- Use integration tests for routes
- Use unit tests for utilities and helpers
- Use mock data for external services
- Focus on error cases and edge conditions

3. **Mocking Strategy**
- [ ] Create mock implementations for:
- Database operations
- External APIs (Cloudinary, OAuth providers)
- Email/SMS services
- Payment gateways

4. **CI/CD Integration**
- [ ] Add coverage reporting to CI pipeline
- [ ] Set up coverage thresholds
- [ ] Add test status badges to README

## Long-term Goals

1. Achieve and maintain:
- 80% overall coverage
- 80% branch coverage
- 80% function coverage
- 80% line coverage

2. Implement:
- End-to-end tests for critical flows
- Performance tests for key endpoints
- Security tests for authentication/authorization
- Load tests for high-traffic endpoints

## Notes

- Focus on business-critical paths first
- Prioritize security-related functionality
- Document test patterns and best practices
- Regular review and updates of test coverage
- Consider adding property-based testing for complex logic
Loading