-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
aiAI-powered featuresAI-powered featuresphase-1Foundation / infrastructureFoundation / infrastructuretestingTests and quality assuranceTests and quality assurance
Description
Phase 1 — Foundation (4/4)
Comprehensive test coverage for the AI foundation layer.
Scope
tests/ai/providers.test.ts
- All 5 providers are registered with valid config
- Each provider has at least 2 models defined
getProvider()returns correct config or undefined for unknown providersgetModelsForProvider()returns correct model listgetDefaultModel()returns a valid model for each provider- Header builders produce correct auth headers per provider
- Body formatters produce the correct request shape (OpenAI vs Anthropic vs Google)
tests/ai/storage.test.ts
setApiKey/getApiKeyround-trip works for each providerremoveApiKeyclears only the specified providerclearAllApiKeysremoves all AI-related entries, leaves other localStorage intactgetSelectedProvider/setSelectedProviderwork correctlygetSelectedModel/setSelectedModelare per-providerhasAnyKeyConfiguredreturns true/false correctly- Handles missing localStorage gracefully (returns null, no throw)
- Handles corrupted localStorage values gracefully
tests/api/ai-validate.test.ts
- Returns 400 for missing
providerorapiKey - Returns 400 for unknown provider
- Returns correct response shape
{ valid: boolean, error?: string } - Validates request body schema
tests/api/ai-generate.test.ts
- Returns 400 for missing required fields (provider, apiKey, model, prompt)
- Returns 400 for unknown provider or model
- Returns correct response shape
{ content, model, usage } - Rejects oversized prompts (if limit set)
- Validates
maxTokensandtemperatureranges
Mock Strategy
- Mock
fetchfor all provider API calls (no real API calls in tests) - Test both success and error responses from providers
- Test provider-specific error formats (OpenAI vs Anthropic error shapes)
Acceptance Criteria
- All test files created and passing
- Provider registry fully covered
- Storage module fully covered including edge cases
- API endpoints tested for validation, success, and error paths
- No real API calls — all external requests mocked
- Coverage report shows >90% for
src/lib/ai/files
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
aiAI-powered featuresAI-powered featuresphase-1Foundation / infrastructureFoundation / infrastructuretestingTests and quality assuranceTests and quality assurance