Testing Strategy
This document outlines the testing strategy for the OAuth functionality in the application.
OAuth Helper Tests
We've implemented several types of tests for the OAuth functionality:
1. Unit Tests (src/lib/oauth.test.ts)
These tests verify that the OAuth helper functions work correctly in isolation:
- Tests for
getRedirectUrifunction. - Tests for service-specific OAuth configuration functions.
- Tests for environment variable handling and fallbacks.
2. OAuth Integration Tests (src/lib/oauth.integration.test.ts)
These tests verify that the OAuth helper functions integrate correctly with the Google OAuth client:
- Tests for creating a Google OAuth client with the helper functions.
- Tests for environment-specific redirect URI handling.
3. Token Refresh Tests (src/lib/token-refresh.test.ts)
These tests verify that the token refresh functionality works correctly:
- Tests for refreshing expired Google OAuth tokens.
- Tests for the token refresh flow.
4. API Route Integration Tests (src/app/api/oauth-integration.test.ts)
These tests verify that the OAuth helper functions can be used correctly in the API routes:
- Tests for generating auth URLs with the correct redirect URIs.
- Tests for handling custom redirect URIs.
5. OAuth Route Integration Tests (src/lib/oauth-route-integration.test.ts)
These tests verify that the OAuth helper functions work correctly in a route-like context: