297 lines
7.9 KiB
ReStructuredText
297 lines
7.9 KiB
ReStructuredText
@base = http://localhost:3000
|
|
@apiKey = bnt_727d2f4f72bd03ed96da5278bb971a00cb0a2454d4d70f9748b5c39f3f69d88d
|
|
|
|
###############################################################################
|
|
# FLOW LIFECYCLE TESTS
|
|
# Tests: Lazy flow creation, Eager flow creation, Flow operations
|
|
#
|
|
# Test Coverage:
|
|
# 1. Lazy flow pattern - first generation without flowId
|
|
# 2. Lazy flow - verify flow not created yet
|
|
# 3. Lazy flow - second generation creates flow
|
|
# 4. Eager flow creation with flowAlias
|
|
# 5. List all flows
|
|
# 6. Get flow with computed counts
|
|
# 7. List flow generations
|
|
# 8. List flow images
|
|
# 9. Update flow aliases
|
|
# 10. Remove specific flow alias
|
|
# 11. Regenerate flow
|
|
###############################################################################
|
|
|
|
|
|
###############################################################################
|
|
# TEST 1: Lazy Flow Pattern - First Generation
|
|
# Generation without flowId should return auto-generated flowId
|
|
# but NOT create flow in database yet (Section 4.1)
|
|
###############################################################################
|
|
|
|
### Step 1.1: Create Generation without flowId
|
|
# @name lazyFlowGen1
|
|
POST {{base}}/api/v1/generations
|
|
Content-Type: application/json
|
|
X-API-Key: {{apiKey}}
|
|
|
|
{
|
|
"prompt": "A red sports car on a mountain road",
|
|
"aspectRatio": "16:9"
|
|
}
|
|
|
|
###
|
|
|
|
@lazyFlowId = {{lazyFlowGen1.response.body.$.data.flowId}}
|
|
@lazyGenId1 = {{lazyFlowGen1.response.body.$.data.id}}
|
|
|
|
### Step 1.2: Poll Generation Status
|
|
# @name checkLazyGen1
|
|
GET {{base}}/api/v1/generations/{{lazyGenId1}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - flowId is returned (auto-generated UUID)
|
|
# - status = "success"
|
|
|
|
|
|
###############################################################################
|
|
# TEST 2: Verify Lazy Flow Not Created Yet
|
|
# Flow should NOT exist in database after first generation
|
|
###############################################################################
|
|
|
|
### Step 2.1: Try to get flow (should return 404)
|
|
# @name checkLazyFlowNotExists
|
|
GET {{base}}/api/v1/flows/{{lazyFlowId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Expected: 404 Not Found
|
|
# Flow record not created yet (lazy creation pattern)
|
|
|
|
|
|
###############################################################################
|
|
# TEST 3: Lazy Flow - Second Generation Creates Flow
|
|
# Using same flowId should create the flow record
|
|
###############################################################################
|
|
|
|
### Step 3.1: Create second generation with same flowId
|
|
# @name lazyFlowGen2
|
|
POST {{base}}/api/v1/generations
|
|
Content-Type: application/json
|
|
X-API-Key: {{apiKey}}
|
|
|
|
{
|
|
"prompt": "Same car but blue color",
|
|
"aspectRatio": "16:9",
|
|
"flowId": "{{lazyFlowId}}"
|
|
}
|
|
|
|
###
|
|
|
|
@lazyGenId2 = {{lazyFlowGen2.response.body.$.data.id}}
|
|
|
|
### Step 3.2: Poll Generation Status
|
|
# @name checkLazyGen2
|
|
GET {{base}}/api/v1/generations/{{lazyGenId2}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Step 3.3: Verify flow now exists
|
|
# @name verifyLazyFlowExists
|
|
GET {{base}}/api/v1/flows/{{lazyFlowId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Expected: 200 OK
|
|
# Flow record now exists after second use
|
|
|
|
|
|
###############################################################################
|
|
# TEST 4: Eager Flow Creation with flowAlias
|
|
# Using flowAlias should create flow immediately
|
|
###############################################################################
|
|
|
|
### Step 4.1: Create generation with flowAlias
|
|
# @name eagerFlowGen
|
|
POST {{base}}/api/v1/generations
|
|
Content-Type: application/json
|
|
X-API-Key: {{apiKey}}
|
|
|
|
{
|
|
"prompt": "A hero banner image",
|
|
"aspectRatio": "21:9",
|
|
"flowAlias": "@hero-flow"
|
|
}
|
|
|
|
###
|
|
|
|
@eagerFlowId = {{eagerFlowGen.response.body.$.data.flowId}}
|
|
@eagerGenId = {{eagerFlowGen.response.body.$.data.id}}
|
|
|
|
### Step 4.2: Poll Generation Status
|
|
# @name checkEagerGen
|
|
GET {{base}}/api/v1/generations/{{eagerGenId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Step 4.3: Verify flow exists immediately (eager creation)
|
|
# @name verifyEagerFlowExists
|
|
GET {{base}}/api/v1/flows/{{eagerFlowId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - Flow exists immediately
|
|
# - aliases contains "@hero-flow"
|
|
|
|
|
|
###############################################################################
|
|
# TEST 5: List All Flows
|
|
###############################################################################
|
|
|
|
### Step 5.1: List flows
|
|
# @name listFlows
|
|
GET {{base}}/api/v1/flows
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - Returns array of flows
|
|
# - Contains our lazyFlowId and eagerFlowId
|
|
|
|
|
|
###############################################################################
|
|
# TEST 6: Get Flow with Computed Counts
|
|
###############################################################################
|
|
|
|
### Step 6.1: Get flow details
|
|
# @name getFlowDetails
|
|
GET {{base}}/api/v1/flows/{{lazyFlowId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - generationCount is number (should be 2)
|
|
# - imageCount is number (should be 2)
|
|
# - aliases object present
|
|
|
|
|
|
###############################################################################
|
|
# TEST 7: List Flow Generations
|
|
###############################################################################
|
|
|
|
### Step 7.1: Get flow's generations
|
|
# @name getFlowGenerations
|
|
GET {{base}}/api/v1/flows/{{lazyFlowId}}/generations
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - Returns array of generations
|
|
# - Contains 2 generations from lazy flow tests
|
|
|
|
|
|
###############################################################################
|
|
# TEST 8: List Flow Images
|
|
###############################################################################
|
|
|
|
### Step 8.1: Get flow's images
|
|
# @name getFlowImages
|
|
GET {{base}}/api/v1/flows/{{lazyFlowId}}/images
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - Returns array of images
|
|
# - Contains output images from generations
|
|
|
|
|
|
###############################################################################
|
|
# TEST 9: Update Flow Aliases
|
|
###############################################################################
|
|
|
|
### Step 9.1: Update flow aliases
|
|
# @name updateFlowAliases
|
|
PUT {{base}}/api/v1/flows/{{lazyFlowId}}/aliases
|
|
Content-Type: application/json
|
|
X-API-Key: {{apiKey}}
|
|
|
|
{
|
|
"aliases": {
|
|
"@latest": "{{checkLazyGen2.response.body.$.data.outputImageId}}",
|
|
"@best": "{{checkLazyGen2.response.body.$.data.outputImageId}}"
|
|
}
|
|
}
|
|
|
|
###
|
|
# Verify:
|
|
# - Returns updated flow with new aliases
|
|
# - aliases contains @latest and @best
|
|
|
|
|
|
### Step 9.2: Verify aliases set
|
|
# @name verifyAliasesSet
|
|
GET {{base}}/api/v1/flows/{{lazyFlowId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
|
|
###############################################################################
|
|
# TEST 10: Remove Specific Flow Alias
|
|
###############################################################################
|
|
|
|
### Step 10.1: Delete @best alias
|
|
# @name deleteFlowAlias
|
|
DELETE {{base}}/api/v1/flows/{{lazyFlowId}}/aliases/@best
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Step 10.2: Verify alias removed
|
|
# @name verifyAliasRemoved
|
|
GET {{base}}/api/v1/flows/{{lazyFlowId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
# Verify:
|
|
# - @best not in aliases
|
|
# - @latest still in aliases
|
|
|
|
|
|
###############################################################################
|
|
# TEST 11: Regenerate Flow
|
|
# Regenerates the most recent generation in a flow
|
|
###############################################################################
|
|
|
|
### Step 11.1: Trigger regeneration
|
|
# @name regenerateFlow
|
|
POST {{base}}/api/v1/flows/{{lazyFlowId}}/regenerate
|
|
Content-Type: application/json
|
|
X-API-Key: {{apiKey}}
|
|
|
|
{}
|
|
|
|
###
|
|
# Verify:
|
|
# - Returns new generation object
|
|
# - New generation is in the same flow
|
|
|
|
|
|
###############################################################################
|
|
# NOTES
|
|
###############################################################################
|
|
#
|
|
# Lazy Flow Pattern (Section 4.1):
|
|
# 1. First request without flowId -> return generated flowId, but DO NOT create in DB
|
|
# 2. Any request with valid flowId -> create flow in DB if doesn't exist
|
|
# 3. If flowAlias specified -> create flow immediately (eager creation)
|
|
#
|
|
# Flow Aliases:
|
|
# - Stored in flow.aliases JSONB field
|
|
# - Map alias names to image IDs
|
|
# - Can be updated via PUT /flows/:id/aliases
|
|
# - Individual aliases deleted via DELETE /flows/:id/aliases/:alias
|
|
#
|