test(dashboard): implement Phase 5 Bruno API tests for Carousel-style dashboard
Update and create Bruno API tests to reflect new unified collections architecture:
Updated Tests:
1. get-dashboard-sections.yml
- Updated response structure documentation
- Changed from type field to is_system boolean
- Changed from id to media_item_id in items
- Added priority field documentation
- Updated example response to show unified collections structure
- Added test for sections array in response
2. update-preferences.yml
- Changed HTTP method from POST to PUT (matching handler implementation)
- Updated request body field names:
* hidden_sections → hidden_collections
* section_order → collection_order
- Updated documentation with new field names
- Updated example request with valid system collection names
New Tests:
3. restore-system-collection.yml
- Tests POST /api/dashboard/restore-system-collection endpoint
- Validates collection_name against allowed system collections
- Tests success response with message
- Documents valid collection names:
* continue-reading
* recently-added
* recently-read
* not-started
Test Coverage:
- GET /api/dashboard/sections: Returns all dashboard sections
- PUT /api/dashboard/preferences: Updates user preferences
- POST /api/dashboard/restore-system-collection: Resets system collection
All tests follow Bruno YAML format with proper authentication via auth: inherit.
This commit is contained in:
@@ -4,49 +4,70 @@ info:
|
|||||||
seq: 1
|
seq: 1
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
url: '{{base_url}}/api/dashboard/sections'
|
url: '{{base_url}}/api/dashboard/sections?library_id={{library_id}}'
|
||||||
auth: inherit
|
auth: inherit
|
||||||
body:
|
body:
|
||||||
type: none
|
type: none
|
||||||
runtime:
|
runtime:
|
||||||
scripts:
|
scripts:
|
||||||
- type: tests
|
- type: tests
|
||||||
code: "test(\"status must be 200 with auth\", function() {\n expect(res.status).to.eql(200);"
|
code: "test(\"status must be 200 with auth\", function() {\n expect(res.status).to.eql(200);\n\
|
||||||
|
});\n\ntest(\"response contains sections array\", function() {\n expect(res.body.sections).to.exist;\n\
|
||||||
|
expect(res.body.sections).to.be.an('array');\n });"
|
||||||
|
|
||||||
docs: |-
|
docs: |-
|
||||||
Get all dashboard sections for a specific library.
|
Get all dashboard sections for a specific library.
|
||||||
|
|
||||||
**Endpoint**: GET /api/dashboard/sections
|
**Endpoint**: GET /api/dashboard/sections
|
||||||
**Auth**: Required (Bearer token via auth: inherit)
|
**Auth**: Required (Bearer token via auth: inherit)
|
||||||
|
|
||||||
## Query Parameters
|
## Query Parameters
|
||||||
|
|
||||||
| Parameter | Type | Required | Description |
|
| Parameter | Type | Required | Description |
|
||||||
|-----------|------|----------|-------------|
|
|-----------|------|----------|-------------|
|
||||||
| library_id | string | Yes | Library UUID |
|
| library_id | string | Yes | Library UUID |
|
||||||
|
| limit | int | No | Items per section (default: 20, max: 100) |
|
||||||
## Response
|
|
||||||
|
## Response
|
||||||
Returns array of sections including:
|
|
||||||
- Smart sections (continue-reading, in-progress, recently-added, etc.)
|
Returns array of sections including:
|
||||||
- User collections marked with show_on_dashboard: true
|
- System collections (continue-reading, recently-added, recently-read, not-started)
|
||||||
|
- User collections marked with show_on_dashboard: true
|
||||||
## Section Types
|
|
||||||
|
## Section Structure
|
||||||
| Type | Description |
|
|
||||||
|------|-------------|
|
Each section has:
|
||||||
| smart | Auto-generated sections based on user activity |
|
- `id`: Collection name (string)
|
||||||
| collection | User-created collections with dashboard enabled |
|
- `is_system`: Boolean indicating if this is a system collection
|
||||||
|
- `title`: Display title
|
||||||
## Example Response
|
- `description`: Collection description
|
||||||
|
- `icon`: Emoji icon
|
||||||
```json
|
- `items`: Array of BookInfo objects
|
||||||
{
|
- `view_all_url`: URL to view all items (system collections only)
|
||||||
"sections": [
|
- `priority`: Display order (lower numbers first)
|
||||||
{
|
|
||||||
"id": "continue-reading",
|
## Example Response
|
||||||
"type": "smart",
|
|
||||||
"title": "Continue Reading",
|
```json
|
||||||
"icon": "📖",
|
{
|
||||||
"items": [...],
|
"sections": [
|
||||||
"view_all_url": "/section/continue-reading"
|
{
|
||||||
|
"id": "continue-reading",
|
||||||
|
"is_system": true,
|
||||||
|
"title": "Continue Reading",
|
||||||
|
"description": "Books you're currently reading (0 < progress < 1)",
|
||||||
|
"icon": "📖",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"media_item_id": "uuid",
|
||||||
|
"title": "Book Title",
|
||||||
|
"author": "Author Name",
|
||||||
|
"cover_image_path": "/path/to/cover.jpg"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"view_all_url": "/section/continue-reading",
|
||||||
|
"priority": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
info:
|
||||||
|
name: Restore System Collection
|
||||||
|
type: http
|
||||||
|
seq: 3
|
||||||
|
http:
|
||||||
|
method: POST
|
||||||
|
url: '{{base_url}}/api/dashboard/restore-system-collection'
|
||||||
|
auth: inherit
|
||||||
|
body:
|
||||||
|
type: json
|
||||||
|
jsonBody: "{\n \"collection_name\": \"continue-reading\"\n}"
|
||||||
|
runtime:
|
||||||
|
scripts:
|
||||||
|
- type: tests
|
||||||
|
code: "test(\"status must be 200 with valid collection\", function() {\n expect(res.status).to.eql(200);\n\
|
||||||
|
});\n\ntest(\"response has success message\", function() {\n expect(res.body.message).to.exist;\n\
|
||||||
|
});"
|
||||||
|
|
||||||
|
docs: |-
|
||||||
|
Restore a system collection to its default state.
|
||||||
|
|
||||||
|
**Endpoint**: POST /api/dashboard/restore-system-collection
|
||||||
|
**Auth**: Required (Bearer token)
|
||||||
|
|
||||||
|
## Request Body
|
||||||
|
|
||||||
|
| Field | Type | Required | Description |
|
||||||
|
|-------|------|----------|-------------|
|
||||||
|
| collection_name | string | Yes | Name of system collection to restore |
|
||||||
|
|
||||||
|
Valid collection names:
|
||||||
|
- `continue-reading`: Books you're currently reading (0 < progress < 1)
|
||||||
|
- `recently-added`: Newly added items to this library
|
||||||
|
- `recently-read`: Books you've finished (progress >= 1)
|
||||||
|
- `not-started`: Books you haven't read yet (progress = 0 or no record)
|
||||||
|
|
||||||
|
## Example Request
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"collection_name": "continue-reading"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Response
|
||||||
|
|
||||||
|
Returns success message on restore.
|
||||||
@@ -3,34 +3,46 @@ info:
|
|||||||
type: http
|
type: http
|
||||||
seq: 2
|
seq: 2
|
||||||
http:
|
http:
|
||||||
method: POST
|
method: PUT
|
||||||
url: '{{base_url}}/api/dashboard/preferences'
|
url: '{{base_url}}/api/dashboard/preferences'
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
body:
|
||||||
|
type: json
|
||||||
|
jsonBody: "{\n \"library_id\": \"{{library_id}}\",\n \"hidden_collections\"\
|
||||||
|
: [\"not-started\"],\n \"collection_order\": [\"recently-added\", \"continue-reading\"\
|
||||||
|
, \"recently-read\"],\n \"items_per_section\": 20\n}"
|
||||||
runtime:
|
runtime:
|
||||||
scripts:
|
scripts:
|
||||||
- type: tests
|
- type: tests
|
||||||
code: "test(\"status must be 200 with valid request\", function() {\n expect(res.status).to.eql(200);"
|
code: "test(\"status must be 200 with valid request\", function() {\n expect(res.status).to.eql(200);\n\
|
||||||
|
});"
|
||||||
|
|
||||||
docs: |-
|
docs: |-
|
||||||
Update dashboard preferences for the authenticated user.
|
Update dashboard preferences for the authenticated user.
|
||||||
|
|
||||||
**Endpoint**: POST /api/dashboard/preferences
|
**Endpoint**: PUT /api/dashboard/preferences
|
||||||
**Auth**: Required (Bearer token)
|
**Auth**: Required (Bearer token)
|
||||||
|
|
||||||
## Request Body
|
## Request Body
|
||||||
|
|
||||||
| Field | Type | Required | Description |
|
| Field | Type | Required | Description |
|
||||||
|-------|------|----------|-------------|
|
|-------|------|----------|-------------|
|
||||||
| library_id | string | Yes | Library UUID |
|
| library_id | string | Yes | Library UUID |
|
||||||
| hidden_sections | array | No | Section IDs to hide |
|
| hidden_collections | array | No | Collection names to hide from dashboard |
|
||||||
| section_order | array | No | Section IDs in custom order |
|
| collection_order | array | No | Collection names in custom display order |
|
||||||
| items_per_section | int | No | Items to show per section (10-50) |
|
| items_per_section | int | No | Items to show per section (default: 20) |
|
||||||
|
|
||||||
## Example Request
|
## Example Request
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"library_id": "cc23c3a7-f8fb-451a-a78d-2a16df1b725a",
|
"library_id": "cc23c3a7-f8fb-451a-a78d-2a16df1b725a",
|
||||||
"hidden_sections": ["recently-added"],
|
"hidden_collections": ["not-started"],
|
||||||
"section_order": ["continue-reading", "in-progress"],
|
"collection_order": ["recently-added", "continue-reading", "recently-read"],
|
||||||
"items_per_section": 25
|
"items_per_section": 20
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Response
|
||||||
|
|
||||||
|
Returns updated preferences object on success.
|
||||||
|
|||||||
Reference in New Issue
Block a user