[TASK] Regression Testing for dotAI REST API
Open
@Laura-dotCMS is already working on this.
Since Jan 16, 2026.
dotCMS : AI Multiple Vendors
- Dominant language
- Java
- Stars
- 970
- Forks
- 486
- Avg merge
- 3d 33m
- Merged PRs (30d)
- 170
Description
Description
Complete regression testing of the dotAI REST API which provides headless access to OpenAI operations. The API offers endpoints for text generation, image generation, semantic search, embeddings management, and AI completions.
Base Path: /api/v1/ai
Key Capabilities:
- Text and Image Generation
- Semantic Search Operations
- Embeddings Management
- AI Completions and Configuration
Reference Documentation: https://dev.dotcms.com/docs/dotai-api
Acceptance Criteria
1. Text Generation Endpoints
1.1 Text Generation (GET/POST) - /api/v1/ai/text/generate
HTTP Methods
- Test GET request with query parameters
- Test POST request with JSON body
- Verify both methods return identical results for same input
- Test with
Content-Type: application/jsonheader
Request Parameters
- Test with simple text prompt
- Test with prompt containing special characters
- Test prompt length boundary (1-4096 characters)
- Test with maximum length prompt (4096 chars)
- Test with prompt exceeding 4096 chars (expect error)
- Test with empty prompt (expect error)
- Test with model parameter
- Test with temperature parameter (0-2 range)
- Test temperature clamping (values >2 should clamp to 2)
Response Structure
- Verify
idfield format (chatcmpl-...) - Verify
objectfield equals "chat.completion" - Verify
createdtimestamp is valid - Verify
modelfield matches requested model - Verify
choicesarray structure - Verify
choices[0].message.roleequals "assistant" - Verify
choices[0].message.contentcontains generated text - Verify
choices[0].finish_reasonis present - Verify
usageobject contains token counts - Validate
prompt_tokens,completion_tokens,total_tokens
Status Codes
- Verify 200 OK for successful requests
- Verify 400 Bad Request for invalid parameters
- Verify 401 Unauthorized without authentication
- Verify 500 Internal Server Error for API failures
1.2 Image Test - /api/v1/ai/image/test
- Test endpoint accessibility
- Verify test response structure
- Validate test functionality
2. Image Generation Endpoints
2.1 Image Generation (GET/POST) - /api/v1/ai/image/generate
HTTP Methods
- Test GET request with query parameters
- Test POST request with JSON body
- Verify both methods work correctly
Request Parameters (AIImageRequestDTO)
- Test with required
promptparameter - Test
numberOfImagesparameter (default: 1) - Test multiple image generation (numberOfImages > 1)
- Test
sizeparameter options- Test "1024x1024" (default)
- Test other supported sizes
- Test
qualityparameter- Test "standard" (default)
- Test "hd" quality
- Test
styleparameter- Test "natural" (default)
- Test "vivid" style
Response Structure
- Verify
revised_promptfield is present - Verify
urlfield contains valid image URL - Verify
originalPromptmatches input - Verify
tempFileNameis generated - Verify
responsefield is present - Verify
tempFilepath is accessible - Test image URL accessibility
- Validate generated image format and quality
Edge Cases
- Test with empty prompt (expect error)
- Test with very long prompt
- Test with inappropriate content prompt
- Test numberOfImages boundary values
- Test invalid size parameter
- Test invalid quality/style parameters
3. Search Endpoints
3.1 Semantic Search (GET/POST) - /api/v1/ai/search
HTTP Methods
- Test GET request with query parameters
- Test POST request with JSON body
- Verify consistent results across methods
Request Parameters (CompletionsForm subset)
- Test required
promptparameter (1-4096 chars) - Test
searchLimitparameter (1-1000, default: 50) - Test
searchOffsetparameter for pagination - Test
thresholdparameter (0-1, default: 0.25) - Test
operatorparameter- Test "cosine" (default)
- Test "distance"
- Test "innerProduct"
- Test
contentTypefiltering (comma-separated) - Test
indexNameparameter (default: "default") - Test
languageparameter (ID or code)
Response Structure
- Verify
resultsarray structure - Verify each result contains
identifier - Verify each result contains
title - Verify each result contains
contentType - Verify each result contains
score(similarity) - Verify each result contains
content(excerpt) - Verify
totalResultscount is accurate - Verify
queryechoes input - Verify
thresholdvalue
Functionality
- Test semantic search with various queries
- Verify search relevance and ranking
- Test pagination with limit/offset combinations
- Test threshold filtering (0, 0.5, 1.0)
- Test different operators affect ranking
- Test contentType filtering
- Test language filtering
- Test with multiple indexes
Edge Cases
- Test with query returning no results
- Test with query matching all content
- Test offset beyond total results
- Test limit exceeding 1000 (expect clamping)
- Test threshold outside 0-1 range
3.2 Find Related Content (GET/POST) - /api/v1/ai/search/related
Request Parameters
- Test with contentlet identifier
- Test with
indexNameparameter - Test with
thresholdparameter - Test with
searchLimitparameter
Functionality
- Test finding related content for various contentlets
- Verify similarity ranking
- Test with different content types
- Validate related content accuracy
Edge Cases
- Test with non-existent identifier
- Test with content having no relations
- Test with newly created content
3.3 Search Test - /api/v1/ai/search/test
- Test endpoint accessibility
- Verify test response structure
- Validate test functionality
4. Embeddings Endpoints
4.1 Create Embeddings (POST) - /api/v1/ai/embeddings
Request Parameters (EmbeddingsForm)
- Test required
queryparameter (1-4096 chars) - Test
limitparameter (1-1000, default: 1000) - Test
offsetparameter for batch processing - Test
indexNameparameter (default: "default") - Test
modelparameter - Test
fieldsparameter (comma-separated) - Test
velocityTemplatefor custom extraction
Functionality
- Test embedding creation for single content
- Test batch embedding creation
- Test with different content types
- Test with custom field selection
- Test with Velocity template extraction
- Verify embeddings are stored correctly
- Test with multiple indexes
- Validate embedding vector generation
Edge Cases
- Test with empty query (expect error)
- Test with query exceeding 4096 chars
- Test with invalid field names
- Test with malformed Velocity template
- Test concurrent embedding creation
4.2 Delete Embeddings (DELETE) - /api/v1/ai/embeddings
Request Parameters
- Test with specific contentlet identifiers
- Test with
indexNameparameter - Test batch deletion
Functionality
- Test deleting embeddings for single content
- Test deleting embeddings for multiple content
- Verify embeddings are removed from index
- Test deletion from specific index
- Test deletion from multiple indexes
Edge Cases
- Test deleting non-existent embeddings
- Test deleting from non-existent index
- Test concurrent deletion operations
4.3 Count Embeddings (GET/POST) - /api/v1/ai/embeddings/count
HTTP Methods
- Test GET request
- Test POST request
Request Parameters
- Test without parameters (count all)
- Test with
indexNameparameter - Test with
contentTypefilter
Response
- Verify count accuracy
- Test count after creation
- Test count after deletion
- Validate count per index
4.4 Index Count (GET) - /api/v1/ai/embeddings/indexCount
Authorization
- Verify requires CMS Administrator role
- Verify 401 for unauthenticated users
- Verify 403 for non-admin users
Response Structure
- Verify
tokensPerChunkfield - Verify
tokenTotalfield - Verify
fragmentscount - Verify
contentscount - Test response for each index
Functionality
- Test with single index
- Test with multiple indexes
- Verify counts match actual data
- Test after index modifications
4.5 Drop/Recreate Table (DELETE) - /api/v1/ai/embeddings/db
Authorization
- Verify requires CMS Administrator role
- Verify 401 for unauthenticated users
- Verify 403 for non-admin users
Functionality
- Test table drop operation
- Verify table recreation
- Test data persistence after recreation
- Validate table schema
Safety
- Verify destructive operation confirmation
- Test operation cannot be undone
- Verify backup/recovery procedures
4.6 Embeddings Test - /api/v1/ai/embeddings/test
- Test endpoint accessibility
- Verify test response structure
- Validate test functionality
5. Completions Endpoints
5.1 Generate Completions (POST) - /api/v1/ai/completions
Request Parameters (CompletionsForm - Full)
- Test required
promptparameter (1-4096 chars) - Test
searchLimit(1-1000, default: 50) - Test
searchOffsetfor pagination - Test
responseLengthTokens(minimum: 128) - Test
threshold(0-1, default: 0.25) - Test
temperature(0-2, default: config) - Test
modelparameter - Test
operator(distance/cosine/innerProduct) - Test
streamparameter (boolean) - Test
contentTypefiltering - Test
indexName(default: "default") - Test
languageparameter
Streaming Response
- Test with
stream=true - Verify
Content-Type: application/octet-stream - Test streaming data chunks
- Verify complete response assembly
- Test stream interruption handling
Non-Streaming Response
- Test with
stream=false(default) - Verify
Content-Type: application/json - Verify response contains search results
- Verify
timeToEmbeddingsfield - Verify
dotCMSResultsarray - Verify
openAiResponseobject - Validate combined response structure
Functionality
- Test completions with various prompts
- Verify search integration works
- Test with different models
- Test temperature effects on responses
- Validate response length control
- Test with different operators
- Test content type filtering
- Test language-specific completions
Edge Cases
- Test with responseLengthTokens < 128 (expect clamping)
- Test with temperature > 2 (expect clamping to 2)
- Test with threshold outside 0-1 range
- Test with very long prompts
- Test concurrent completion requests
5.2 Raw Prompt (POST) - /api/v1/ai/completions/rawPrompt
Request Format
- Test with raw JSON prompt
- Test with custom message arrays
- Test with system/user message combinations
- Test with various parameter combinations
Functionality
- Test direct OpenAI API access
- Verify parameter passthrough
- Test custom completion scenarios
- Validate raw response format
Edge Cases
- Test with invalid JSON structure
- Test with unsupported parameters
- Test with malformed message arrays
5.3 Configuration (GET) - /api/v1/ai/completions/config
Response Structure
- Verify
apiUrlfield - Verify
apiKeyfield (should be masked) - Verify
modelnames - Verify
embeddingsModelfield - Verify
availableModelsarray - Verify role prompt templates
- Verify text prompt templates
Functionality
- Test configuration retrieval
- Verify sensitive data masking (API key)
- Test after configuration changes
- Validate all expected fields present
Security
- Verify API key is never exposed in full
- Test with different authentication levels
- Validate permission requirements
Cross-Endpoint Testing
Authentication & Authorization
- Test all endpoints without authentication (expect 401)
- Test all endpoints with valid authentication
- Test admin-only endpoints with non-admin user (expect 403)
- Test admin-only endpoints with admin user (expect success)
- Verify session token handling
- Test with expired authentication tokens
HTTP Standards Compliance
- Verify proper HTTP status codes for all scenarios
- Test
Content-Typeheaders on requests - Verify
Content-Typeheaders on responses - Test with
Acceptheader variations - Verify CORS headers (if applicable)
- Test HTTP method validation (405 for unsupported)
Parameter Validation
- Test boundary values for all numeric parameters
- Test string length limits
- Test invalid parameter types
- Test missing required parameters
- Test extra/unknown parameters (should be ignored)
- Verify parameter type coercion
Error Handling
- Verify 400 Bad Request for invalid input
- Verify 401 Unauthorized for auth failures
- Verify 403 Forbidden for permission failures
- Verify 404 Not Found for non-existent resources
- Verify 500 Internal Server Error for API failures
- Test error message clarity and usefulness
- Verify error response format consistency
Performance & Scalability
- Test response times for all endpoints
- Test with concurrent requests
- Test with large payloads
- Test with high request volume
- Verify timeout handling
- Test rate limiting (if applicable)
- Validate resource cleanup
Data Consistency
- Test create → read → update → delete flows
- Verify index synchronization
- Test transaction rollback scenarios
- Validate data persistence
- Test with simultaneous operations
Integration Testing
- Test workflows combining multiple endpoints
- Test embeddings creation → search → completions flow
- Verify API consistency with ViewTool behavior
- Test with different content types
- Validate cross-index operations
Priority
High
Additional Context
- Test Against: Custom version built from branch
issue-32639-ai-dotai-portlet - Branch URL: https://github.com/dotCMS/core/tree/issue-32639-ai-dotai-portlet
- Base Path: All endpoints under
/api/v1/ai - Authentication: All endpoints require user authentication
- Admin Endpoints:
indexCountanddbdeletion require CMS Administrator role - Testing Tools: Use REST clients (Postman, curl, etc.) and automated API testing frameworks
- Related Documentation: https://dev.dotcms.com/docs/dotai-api
- Related Issues:
- #34072 (dotAI Tool regression testing)
- #34075 (Block Editor AI regression testing)
- #34112 (dotAI Workflows regression testing)
- #34113 (dotAI ViewTool regression testing)
- Test Environment: Should be tested in both dev and staging with proper authentication
- Test Data: Requires diverse content, multiple indexes, and various content types
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.