|
1 | | -# Integration test trigger |
| 1 | +# Integration Tests |
| 2 | + |
| 3 | +This package contains integration tests for the Echo platform. |
| 4 | + |
| 5 | +## Setup |
| 6 | + |
| 7 | +1. Set up the test environment: |
| 8 | +```bash |
| 9 | +pnpm env:setup |
| 10 | +``` |
| 11 | + |
| 12 | +2. Seed the test database: |
| 13 | +```bash |
| 14 | +pnpm db:seed |
| 15 | +``` |
| 16 | + |
| 17 | +## Running Tests |
| 18 | + |
| 19 | +Run all integration tests: |
| 20 | +```bash |
| 21 | +pnpm test:watch |
| 22 | +``` |
| 23 | + |
| 24 | +Run specific test suites: |
| 25 | +```bash |
| 26 | +# Echo Data Server tests |
| 27 | +pnpm test:echo-data-server |
| 28 | + |
| 29 | +# OAuth Protocol tests |
| 30 | +pnpm test:oauth-protocol |
| 31 | +``` |
| 32 | + |
| 33 | +## Test Suites |
| 34 | + |
| 35 | +### Echo Data Server Tests |
| 36 | +Located in `tests/echo-data-server/`: |
| 37 | +- `api-key.client.test.ts` - API key authentication and usage |
| 38 | +- `402-auth.client.test.ts` - Payment required (402) authentication flow |
| 39 | +- `echo-access-jwt.client.test.ts` - JWT token validation |
| 40 | +- `free-tier.client.test.ts` - Free tier functionality |
| 41 | +- `referral-code.client.test.ts` - Referral code creation and application |
| 42 | +- `in-flight-requests.test.ts` - Concurrent request handling |
| 43 | + |
| 44 | +### OAuth Protocol Tests |
| 45 | +Located in `tests/oauth-protocol/`: |
| 46 | +- OAuth authorization flow |
| 47 | +- Token refresh and lifecycle |
| 48 | +- PKCE security |
| 49 | +- CSRF vulnerability testing |
| 50 | + |
| 51 | +## Referral Code Tests |
| 52 | + |
| 53 | +The referral code integration tests (`referral-code.client.test.ts`) cover: |
| 54 | + |
| 55 | +1. **GET endpoint** - Retrieval of referral codes: |
| 56 | + - Retrieving an existing referral code for a user |
| 57 | + - Auto-creating a referral code for users who don't have one |
| 58 | + - Ensuring consistency across multiple requests |
| 59 | + |
| 60 | +2. **POST endpoint** - Application of referral codes: |
| 61 | + - Successfully applying another user's referral code |
| 62 | + - Rejecting invalid referral codes |
| 63 | + - Preventing users from applying codes when they already have a referrer |
| 64 | + |
| 65 | +### Test Data |
| 66 | + |
| 67 | +Referral code test data is defined in `config/test-data.ts`: |
| 68 | +- Primary user has referral code: `TEST-REFERRAL-CODE-PRIMARY` |
| 69 | +- Secondary user has referral code: `TEST-REFERRAL-CODE-SECONDARY` |
| 70 | +- Tertiary user has no referral code (created during tests) |
| 71 | + |
| 72 | +## Database Management |
| 73 | + |
| 74 | +Reset and reseed the database: |
| 75 | +```bash |
| 76 | +pnpm db:reset-and-seed |
| 77 | +``` |
| 78 | + |
| 79 | +Reset only: |
| 80 | +```bash |
| 81 | +pnpm db:reset |
| 82 | +``` |
0 commit comments