Files
orangecat/tests
Your NameandClaude c32403bfaf feat: Standardize API error handling across 5 routes
Migrated API routes to use new standardResponse helpers for consistent error handling:

**Routes Updated:**
- `/api/profile` (GET, PUT) - Profile management
- `/api/projects` (GET, POST) - Project listing and creation
- `/api/projects/[id]` (GET, PUT, DELETE) - Project details and management
- `/api/transparency/[profileId]` (GET) - Transparency scores
- `/api/upload` (POST, DELETE) - File upload/delete

**Error Handler Migration:**
- Updated `@/lib/errors.ts` to use `standardResponse` internally (src/lib/errors.ts:67-96)
- Replaced old error classes with new API helpers:
  - `throw new AuthError()` → `return apiUnauthorized()`
  - `throw new NotFoundError()` → `return apiNotFound()`
  - `throw new ValidationError()` → `return apiValidationError()`
  - Generic errors → `return apiInternalError()`

**Supabase Client Fix:**
- Fixed `projects/[id]/route.ts` to use `@/lib/supabase/server` instead of deprecated `@/lib/db`

**Benefits:**
- Consistent API response format: `{ success: true/false, data/error, metadata }`
- Better error messages with proper HTTP status codes
- Type-safe error handling throughout
- Backward compatibility maintained for existing routes

**Testing:**
- Type-check passes ✅
- 49 uses of new API helpers across 5 routes
- 0 remaining imports of old error handlers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 08:36:06 +02:00
..

Tests Directory

This directory contains all test files organized by type and purpose.

Directory Structure

  • auth/ - Authentication-related tests
  • e2e/ - End-to-end tests using Playwright
  • manual/ - Manual testing scripts and utilities
  • security/ - Security-focused tests
  • setup/ - Test setup and configuration

Test Types

  • Unit Tests: Located in __tests__/ directories next to source files
  • Integration Tests: API and service integration tests
  • E2E Tests: Full user journey tests using Playwright
  • Security Tests: Security vulnerability and policy tests
  • Manual Tests: Scripts for manual testing scenarios

Running Tests

# All tests
npm test

# Unit tests only
npm run test:unit

# Integration tests
npm run test:integration

# E2E tests
npm run test:e2e

# Security tests
npm run test:security

# Auth tests
npm run test:auth

Test Configuration

  • jest.config.js - Jest configuration
  • playwright.config.ts - Playwright E2E configuration
  • setup.ts - Global test setup
  • TestWrapper.tsx - React testing utilities