Phase 12 - Bruno API Tests Standardization Convert all custom section builder tests to .yml format: - preview-collection.bru → preview-collection.yml - create-custom-section-manual.bru → create-custom-section-manual.yml - create-custom-section-missing-fields.bru → create-custom-section-missing-fields.yml - create-custom-section-rules.bru → create-custom-section-rules.yml All Bruno tests now consistently use .yml extension across the project. Tests cover: - Preview collection with filter rules - Create collection with manual book selection - Validation of required fields - Multiple filter rules with operators Part of Carousel Dashboard Plan completion
61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
meta:
|
|
name: Preview Collection
|
|
type: http
|
|
seq: 1
|
|
http:
|
|
method: POST
|
|
url: '{{base_url}}/api/collections/preview'
|
|
auth: inherit
|
|
body:
|
|
type: json
|
|
jsonBody: "{\n \"library_id\": \"{{library_id}}\",\n \"rules\": [\n\
|
|
{\n \"id\": \"rule1\",\n \"field\": \"genre\",\n\
|
|
\"operator\": \"equals\",\n \"value\": \"Fiction\",\n\
|
|
\"priority\": 1\n }\n ],\n \"manual_book_ids\": [],\n \"limit\": 20\n}"
|
|
runtime:
|
|
scripts:
|
|
- type: tests
|
|
code: "test(\"status must be 200 with valid request\", function() {\n expect(res.status).to.eql(200);\n\
|
|
});\n\ntest(\"response contains items array\", function() {\n expect(res.body.items).to.exist;\n\
|
|
expect(res.body.items).to.be.an('array');\n });"
|
|
|
|
docs: |-
|
|
Preview collection with filter rules before saving.
|
|
|
|
**Endpoint**: POST /api/collections/preview
|
|
**Auth**: Required (Bearer token)
|
|
|
|
## Request Body
|
|
|
|
| Field | Type | Required | Description |
|
|
|-------|------|----------|-------------|
|
|
| library_id | string | Yes | Library UUID |
|
|
| rules | array | No | Filter rules to evaluate |
|
|
| manual_book_ids | array | No | Manually selected book IDs |
|
|
| limit | int | No | Max items to return (default: 20, max: 100) |
|
|
|
|
## Example Request
|
|
|
|
```json
|
|
{
|
|
"library_id": "cc23c3a7-f8fb-451a-a78d-2a16df1b725a",
|
|
"rules": [
|
|
{
|
|
"id": "rule1",
|
|
"field": "genre",
|
|
"operator": "equals",
|
|
"value": "Fiction",
|
|
"priority": 1
|
|
}
|
|
],
|
|
"manual_book_ids": [],
|
|
"limit": 20
|
|
}
|
|
```
|
|
|
|
## Response
|
|
|
|
Returns array of matching book items.
|
|
|
|
This endpoint is used by the Custom Section Builder to show users what books will match their filter rules before they save the collection.
|