333 lines
7.8 KiB
ReStructuredText
333 lines
7.8 KiB
ReStructuredText
@base = http://localhost:3000
|
|
@apiKey = bnt_727d2f4f72bd03ed96da5278bb971a00cb0a2454d4d70f9748b5c39f3f69d88d
|
|
|
|
###############################################################################
|
|
# IMAGE UPLOAD & CRUD TESTS
|
|
# Tests: Upload, list, filter, pagination, metadata updates, alias management
|
|
###############################################################################
|
|
|
|
### Test 1.1: Upload image with project-scoped alias
|
|
# @name uploadWithAlias
|
|
POST {{base}}/api/v1/images/upload
|
|
X-API-Key: {{apiKey}}
|
|
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
|
|
|
|
------WebKitFormBoundary7MA4YWxkTrZu0gW
|
|
Content-Disposition: form-data; name="file"; filename="test-image2.png"
|
|
Content-Type: image/png
|
|
|
|
< ./fixture/test-image.png
|
|
------WebKitFormBoundary7MA4YWxkTrZu0gW
|
|
Content-Disposition: form-data; name="alias"
|
|
|
|
@test-logo
|
|
------WebKitFormBoundary7MA4YWxkTrZu0gW
|
|
Content-Disposition: form-data; name="description"
|
|
|
|
Test logo image for CRUD tests
|
|
------WebKitFormBoundary7MA4YWxkTrZu0gW--
|
|
|
|
###
|
|
|
|
@uploadedImageId = {{uploadWithAlias.response.body.$.data.id}}
|
|
@uploadedImageAlias = {{uploadWithAlias.response.body.$.data.alias}}
|
|
@uploadedImageSource = {{uploadWithAlias.response.body.$.data.source}}
|
|
|
|
### Test 1.2: Verify uploaded image details
|
|
# Expected: alias = @test-logo, source = uploaded
|
|
GET {{base}}/api/v1/images/{{uploadedImageId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 2.1: Upload image without alias
|
|
# @name uploadWithoutAlias
|
|
POST {{base}}/api/v1/images/upload
|
|
X-API-Key: {{apiKey}}
|
|
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
|
|
|
|
------WebKitFormBoundary7MA4YWxkTrZu0gW
|
|
Content-Disposition: form-data; name="file"; filename="test-image.png"
|
|
Content-Type: image/png
|
|
|
|
< ./fixture/test-image.png
|
|
------WebKitFormBoundary7MA4YWxkTrZu0gW
|
|
Content-Disposition: form-data; name="description"
|
|
|
|
Image without alias
|
|
------WebKitFormBoundary7MA4YWxkTrZu0gW--
|
|
|
|
###
|
|
|
|
@uploadedImageId2 = {{uploadWithoutAlias.response.body.$.data.id}}
|
|
|
|
### Test 2.2: Verify image has no alias
|
|
# Expected: alias = null
|
|
GET {{base}}/api/v1/images/{{uploadedImageId2}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 3: List all images
|
|
# Expected: Returns array with pagination
|
|
GET {{base}}/api/v1/images
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 4: List images - filter by source=uploaded
|
|
# Expected: All results have source="uploaded"
|
|
GET {{base}}/api/v1/images?source=uploaded
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 5: List images with pagination
|
|
# Expected: limit=3, offset=0, hasMore=true/false
|
|
GET {{base}}/api/v1/images?limit=3&offset=0
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 6: Get image by ID
|
|
# Expected: Returns full image details
|
|
GET {{base}}/api/v1/images/{{uploadedImageId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 7: Resolve project-scoped alias
|
|
# Expected: Resolves to uploadedImageId (Section 6.2: direct alias support)
|
|
GET {{base}}/api/v1/images/@test-logo
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 8.1: Update image metadata (focal point + meta)
|
|
# @name updateMetadata
|
|
PUT {{base}}/api/v1/images/{{uploadedImageId}}
|
|
X-API-Key: {{apiKey}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"focalPoint": {
|
|
"x": 0.5,
|
|
"y": 0.3
|
|
},
|
|
"meta": {
|
|
"description": "Updated description",
|
|
"tags": ["test", "logo", "updated"]
|
|
}
|
|
}
|
|
|
|
###
|
|
|
|
### Test 8.2: Verify metadata update
|
|
# Expected: focalPoint x=0.5, y=0.3, meta has tags
|
|
GET {{base}}/api/v1/images/{{uploadedImageId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 9.1: Update image alias (dedicated endpoint)
|
|
# @name updateAlias
|
|
PUT {{base}}/api/v1/images/{{uploadedImageId}}/alias
|
|
X-API-Key: {{apiKey}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"alias": "@new-test-logo"
|
|
}
|
|
|
|
###
|
|
|
|
### Test 9.2: Verify new alias works
|
|
# Expected: Resolves to same uploadedImageId (Section 6.2: direct alias support)
|
|
GET {{base}}/api/v1/images/@new-test-logo
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 10: Verify old alias doesn't work after update
|
|
# Expected: 404 - Alias not found
|
|
GET {{base}}/api/v1/images/@test-logo
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 11.1: Remove image alias
|
|
# @name removeAlias
|
|
PUT {{base}}/api/v1/images/{{uploadedImageId}}/alias
|
|
X-API-Key: {{apiKey}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"alias": null
|
|
}
|
|
|
|
###
|
|
|
|
### Test 11.2: Verify image exists but has no alias
|
|
# Expected: alias = null
|
|
GET {{base}}/api/v1/images/{{uploadedImageId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 11.3: Verify alias resolution fails
|
|
# Expected: 404 - Alias not found
|
|
GET {{base}}/api/v1/images/@new-test-logo
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 12.1: Reassign alias for reference image test
|
|
# @name reassignAlias
|
|
PUT {{base}}/api/v1/images/{{uploadedImageId}}/alias
|
|
X-API-Key: {{apiKey}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"alias": "@reference-logo"
|
|
}
|
|
|
|
###
|
|
|
|
### Test 12.2: Generate with manual reference image
|
|
# @name genWithReference
|
|
POST {{base}}/api/v1/generations
|
|
X-API-Key: {{apiKey}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"prompt": "A product photo with the logo in corner",
|
|
"aspectRatio": "1:1",
|
|
"referenceImages": ["@reference-logo"]
|
|
}
|
|
|
|
###
|
|
|
|
@genWithReferenceId = {{genWithReference.response.body.$.data.id}}
|
|
|
|
### Test 12.3: Poll generation status
|
|
# Run this multiple times until status = success
|
|
GET {{base}}/api/v1/generations/{{genWithReferenceId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 12.4: Verify referenced images tracked
|
|
# Expected: referencedImages array contains @reference-logo
|
|
GET {{base}}/api/v1/generations/{{genWithReferenceId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 13.1: Generate with auto-detected reference in prompt
|
|
# @name genAutoDetect
|
|
POST {{base}}/api/v1/generations
|
|
X-API-Key: {{apiKey}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"prompt": "Create banner using @reference-logo with blue background",
|
|
"aspectRatio": "16:9"
|
|
}
|
|
|
|
###
|
|
|
|
@genAutoDetectId = {{genAutoDetect.response.body.$.data.id}}
|
|
|
|
### Test 13.2: Poll until complete
|
|
GET {{base}}/api/v1/generations/{{genAutoDetectId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 13.3: Verify auto-detection worked
|
|
# Expected: referencedImages contains @reference-logo
|
|
GET {{base}}/api/v1/generations/{{genAutoDetectId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 14.1: Generate with project alias assignment
|
|
# @name genWithAlias
|
|
POST {{base}}/api/v1/generations
|
|
X-API-Key: {{apiKey}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"prompt": "A hero banner image",
|
|
"aspectRatio": "21:9",
|
|
"alias": "@hero-banner"
|
|
}
|
|
|
|
###
|
|
|
|
@genWithAliasId = {{genWithAlias.response.body.$.data.id}}
|
|
|
|
### Test 14.2: Poll until complete
|
|
GET {{base}}/api/v1/generations/{{genWithAliasId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
@heroImageId = {{genWithAlias.response.body.$.data.outputImageId}}
|
|
|
|
### Test 14.3: Verify alias assigned to output image
|
|
# Expected: alias = @hero-banner
|
|
GET {{base}}/api/v1/images/{{heroImageId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 14.4: Verify alias resolution works
|
|
# Expected: Resolves to heroImageId (Section 6.2: direct alias support)
|
|
GET {{base}}/api/v1/images/@hero-banner
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 15.1: Alias conflict - create second generation with same alias
|
|
# @name genConflict
|
|
POST {{base}}/api/v1/generations
|
|
X-API-Key: {{apiKey}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"prompt": "A different hero image",
|
|
"aspectRatio": "21:9",
|
|
"alias": "@hero-banner"
|
|
}
|
|
|
|
###
|
|
|
|
@genConflictId = {{genConflict.response.body.$.data.id}}
|
|
|
|
### Test 15.2: Poll until complete
|
|
GET {{base}}/api/v1/generations/{{genConflictId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
@secondHeroImageId = {{genConflict.response.body.$.data.outputImageId}}
|
|
|
|
### Test 15.3: Verify second image has the alias
|
|
# Expected: Resolves to secondHeroImageId (not heroImageId) (Section 6.2: direct alias support)
|
|
GET {{base}}/api/v1/images/@hero-banner
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
### Test 15.4: Verify first image lost the alias but still exists
|
|
# Expected: alias = null, image still exists
|
|
GET {{base}}/api/v1/images/{{heroImageId}}
|
|
X-API-Key: {{apiKey}}
|
|
|
|
###
|
|
|
|
###############################################################################
|
|
# END OF IMAGE UPLOAD & CRUD TESTS
|
|
###############################################################################
|