Add comprehensive Bruno tests for Phase 9 limitations features: Test Collection Rules.bru: - Test rule: genre equals "Science Fiction" - Test rule: author contains "Asimov" - Test rule: copyright_year greater than 2000 - Test rule: non-existent genre (expects 0 matches) - Test validation: empty rules array (expects 400) Bulk Remove Books.bru: - Setup: Create test collection - Add multiple books to collection - Test 1: Bulk remove all books - Test 2: Bulk remove with some invalid IDs - Test 3: Empty list validation - Test 4: Single book removal (bulk should work for 1 too) - Cleanup: Delete test collection Test Coverage: - Rule evaluation API endpoint - Bulk remove API endpoint - Request validation - Response structure verification - Edge cases and error handling Bruno Test Format: - JSON request bodies - Status code assertions - Response structure validation - Setup/teardown for integration tests These tests ensure the new Phase 9 API endpoints work correctly and maintain backward compatibility.
104 lines
1.8 KiB
Plaintext
104 lines
1.8 KiB
Plaintext
meta {
|
|
name: "Bulk Remove Books from Collection"
|
|
type: http
|
|
seq: 1
|
|
}
|
|
|
|
# Setup: Create a test collection first
|
|
post {
|
|
url: {{baseUrl}}/api/collections
|
|
body: {
|
|
name: "Bulk Remove Test Collection"
|
|
description: "Collection for testing bulk remove"
|
|
color: "#FF5733"
|
|
icon: "📚"
|
|
}
|
|
assert {
|
|
res.status: 200
|
|
}
|
|
# Store collection_id from response
|
|
# Note: In actual Bruno, you'd use variables
|
|
}
|
|
|
|
# Add some books to the collection
|
|
post {
|
|
url: {{baseUrl}}/api/collections/{collection_id}/books
|
|
body: {
|
|
book_ids: [
|
|
"book-id-1",
|
|
"book-id-2",
|
|
"book-id-3"
|
|
]
|
|
}
|
|
assert {
|
|
res.status: 204
|
|
}
|
|
}
|
|
|
|
# Test 1: Bulk remove all books
|
|
post {
|
|
url: {{baseUrl}}/api/collections/{collection_id}/books/bulk-remove
|
|
body: {
|
|
book_ids: [
|
|
"book-id-1",
|
|
"book-id-2",
|
|
"book-id-3"
|
|
]
|
|
}
|
|
assert {
|
|
res.status: 200
|
|
res.body.removed: #number
|
|
res.body.total: 3
|
|
}
|
|
}
|
|
|
|
# Test 2: Bulk remove with some invalid IDs
|
|
post {
|
|
url: {{baseUrl}}/api/collections/{collection_id}/books/bulk-remove
|
|
body: {
|
|
book_ids: [
|
|
"book-id-4",
|
|
"invalid-id",
|
|
"book-id-5"
|
|
]
|
|
}
|
|
assert {
|
|
res.status: 200
|
|
res.body.removed: #number
|
|
}
|
|
}
|
|
|
|
# Test 3: Empty list (should fail validation)
|
|
post {
|
|
url: {{baseUrl}}/api/collections/{collection_id}/books/bulk-remove
|
|
body: {
|
|
book_ids: []
|
|
}
|
|
assert {
|
|
res.status: 400
|
|
}
|
|
}
|
|
|
|
# Test 4: Single book (bulk remove should work for 1 book too)
|
|
post {
|
|
url: {{baseUrl}}/api/collections/{collection_id}/books/bulk-remove
|
|
body: {
|
|
book_ids: [
|
|
"book-id-6"
|
|
]
|
|
}
|
|
assert {
|
|
res.status: 200
|
|
res.body.removed: 1
|
|
res.body.total: 1
|
|
}
|
|
}
|
|
|
|
# Cleanup: Delete test collection
|
|
delete {
|
|
url: {{baseUrl}}/api/collections/{collection_id}
|
|
assert {
|
|
res.status: 204
|
|
}
|
|
}
|