-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
https://developers.cloudflare.com/workers/testing/vitest-integration/write-your-first-test/
Possible tests (AI generated):
High Priority - Core Business Logic
- Service Endpoint Tests (packages/service)
These are your critical path - the actual link management logic:
// linkCreate.test.ts
- ✅ Creating link with auto-generated slug
- ✅ Creating link with custom slug
- ✅ Rejecting reserved slugs (links, list)
- ✅ Rejecting duplicate slugs (409 conflict)
- ✅ Validating auth token (401 if missing/wrong)
// linkUpdate.test.ts
- ✅ Updating URL
- ✅ Updating isPermanent flag
- ✅ 404 for non-existent slug
// linkDelete.test.ts
- ✅ Deleting existing link
- ✅ 404 for non-existent slug
// linkRedirect.test.ts
- ✅ 302 redirect for temporary links
- ✅ 301 redirect for permanent links
- ✅ 404 for non-existent slug
Why: These tests protect your data integrity and ensure the API contract. If these break, the whole app breaks.
- Bot Command Handler Tests (packages/bot)
Test the Discord interaction parsing and routing:
// commands.test.ts
- ✅ Discord signature verification (reject invalid signatures)
- ✅ PING/PONG response
- ✅ Guild ID validation (reject commands from wrong server)
- ✅ URL validation (isValidUrl function)
- ✅ Add command: valid URL
- ✅ Add command: invalid URL
- ✅ Delete command parsing
- ✅ Update command: no modifications provided (error)
- ✅ Unknown subcommand handling
Why: These ensure you handle Discord's webhook correctly and don't expose security vulnerabilities.
Medium Priority - Integration & Utilities
- Client API Tests (packages/bot/src/client.ts)
Test the HTTP client that talks to your service:
// client.test.ts
- ✅ addLink success (mock fetch)
- ✅ addLink failure handling
- ✅ deleteLink success
- ✅ updateLink success
- ✅ Proper auth header formatting
Why: Validates error handling and ensures bot gracefully handles service failures
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels