test: improve Bruno API collection formatting and automation
This commit improves the Bruno API collection with better formatting, updated test environment variables, and automation scripts for easier API testing workflow. ## Environment Updates - bruno/environments/Bookhoard.yml: Updated test IDs for library_id and job_id to reflect latest test database state ## Formatting Improvements Updated all Bruno collection files with consistent formatting: - bruno/highlights/Create Media Highlight.yml - bruno/highlights/Update Media Highlight.yml - bruno/library/Add Library Folder.yml - bruno/library/Create Library.yml - bruno/library/Delete Library.yml - bruno/library/Set Library Visibility.yml - bruno/media-items/Create Media Item.yml - bruno/media-items/Create Media Rating.yml - bruno/media-items/Update Media Item.yml - bruno/media-items/Update Media Rating.yml - bruno/media-items/search/Combined Search and Filters.yml - bruno/notes/Create Media Note.yml - bruno/notes/Update Media Note.yml - bruno/progress/Update Reading Progress.yml - bruno/user/admin/Register Admin User.yml - bruno/user/auth/Logout User.yml - bruno/user/auth/Refresh Token.yml Improvements include: - Consistent YAML structure and indentation - Proper multiline string format for JSON bodies - Moved auth: inherit after headers for consistency - Added descriptive comments in request bodies ## Automation Features Added runtime scripts to Create Library.yml: - after-response script automatically extracts and saves library_id from API response to environment variables - Persists library_id for use in subsequent requests - Reduces manual copy-paste workflow during testing Updated request bodies with example data: - Create Media Item.yml: Added complete example with library_id variable reference, title, author, file_path, file_size, mime_type - Other files: Updated with proper JSON formatting ## Benefits - More consistent API collection structure - Automated workflow reduces manual steps - Better readability with proper YAML formatting - Example data makes requests easier to understand
This commit is contained in:
@@ -13,9 +13,9 @@ variables:
|
|||||||
- name: note_id
|
- name: note_id
|
||||||
value: 7710a602-g29b-61d4-c716-446655440002
|
value: 7710a602-g29b-61d4-c716-446655440002
|
||||||
- name: library_id
|
- name: library_id
|
||||||
value: dd03d719-76c8-4398-93ec-9258d2becf85
|
value: d2932c11-cd39-4c4a-b940-124b75964099
|
||||||
- name: job_id
|
- name: job_id
|
||||||
value: 295654b3-eb4b-4e85-ac6c-9361c5821195
|
value: c5766af2-44a5-4537-abb0-e3fa42fc93f9
|
||||||
- name: rating
|
- name: rating
|
||||||
value: "5"
|
value: "5"
|
||||||
- name: is_visible
|
- name: is_visible
|
||||||
|
|||||||
@@ -8,9 +8,14 @@ http:
|
|||||||
auth: inherit
|
auth: inherit
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
jsonBody: "{\n \"selection_text\": \"This is the highlighted text from the\
|
data: |-
|
||||||
\ media item.\",\n \"start_position\": \"page:45:offset:120\",\n \"end_position\"\
|
{
|
||||||
: \"page:45:offset:145\",\n \"color\": \"#ffff00\",\n \"note_id\": \"\""
|
"selection_text": "This is the highlighted text from the media item.",
|
||||||
|
"start_position": "page:45:offset:120",
|
||||||
|
"end_position": "page:45:offset:145",
|
||||||
|
"color": "#ffff00",
|
||||||
|
"note_id": ""
|
||||||
|
}
|
||||||
|
|
||||||
docs: |-
|
docs: |-
|
||||||
## Create Media Highlight
|
## Create Media Highlight
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
info:
|
||||||
|
name: Create Media Highlight
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
http:
|
||||||
|
method: POST
|
||||||
|
url: '{{base_url}}/api/media-items/{{media_item_id}}/highlights'
|
||||||
|
auth: inherit
|
||||||
|
body:
|
||||||
|
type: json
|
||||||
|
jsonBody: "{\n \"selection_text\": \"This is the highlighted text from the\
|
||||||
|
\ media item.\",\n \"start_position\": \"page:45:offset:120\",\n \"end_position\"\
|
||||||
|
: \"page:45:offset:145\",\n \"color\": \"#ffff00\",\n \"note_id\": \"\""
|
||||||
|
|
||||||
|
docs: |-
|
||||||
|
## Create Media Highlight
|
||||||
|
|
||||||
|
Creates a new highlight for a specific media item.
|
||||||
|
|
||||||
|
**Method:** POST
|
||||||
|
|
||||||
|
**Endpoint:** /api/media-items/:id/highlights
|
||||||
|
|
||||||
|
**Path Parameters:**
|
||||||
|
- `id` (string): Media item ID
|
||||||
|
|
||||||
|
**Request Body:**
|
||||||
|
- `selection_text` (string): Highlighted text (required, 1-5000 chars)
|
||||||
|
- `start_position` (string): Start position (required, max 100 chars)
|
||||||
|
- `end_position` (string): End position (required, max 100 chars)
|
||||||
|
- `color` (string): Highlight color in hex format (optional, default #ffff00)
|
||||||
|
- `note_id` (string): Optional associated note ID
|
||||||
|
|
||||||
|
**Response:**
|
||||||
|
- Highlight object with all fields including generated ID and timestamps
|
||||||
|
|
||||||
|
**Status Codes:**
|
||||||
|
- 201: Created
|
||||||
|
- 400: Invalid request
|
||||||
|
- 401: Unauthorized
|
||||||
|
- 404: Media item not found
|
||||||
@@ -8,9 +8,14 @@ http:
|
|||||||
auth: inherit
|
auth: inherit
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
jsonBody: "{\n \"selection_text\": \"This is the updated highlighted text.\"\
|
data: |-
|
||||||
,\n \"start_position\": \"page:45:offset:125\",\n \"end_position\": \"\
|
{
|
||||||
page:45:offset:150\",\n \"color\": \"#ffeb3b\",\n \"note_id\": \"\""
|
"selection_text": "This is the updated highlighted text.",
|
||||||
|
"start_position": "page:45:offset:125",
|
||||||
|
"end_position": "page:45:offset:150",
|
||||||
|
"color": "#ffeb3b",
|
||||||
|
"note_id": ""
|
||||||
|
}
|
||||||
|
|
||||||
docs: |-
|
docs: |-
|
||||||
## Update Media Highlight
|
## Update Media Highlight
|
||||||
|
|||||||
@@ -2,16 +2,49 @@ info:
|
|||||||
name: Add Library Folder
|
name: Add Library Folder
|
||||||
type: http
|
type: http
|
||||||
seq: 1
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: POST
|
method: POST
|
||||||
url: '{{base_url}}/api/libraries/{{library_id}}/folders'
|
url: "{{base_url}}/api/libraries/{{library_id}}/folders"
|
||||||
auth: inherit
|
headers:
|
||||||
|
- name: ""
|
||||||
|
value: application/json
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
jsonBody: "{\n \"folder_path\": {{library_folder"
|
data: |-
|
||||||
headers:
|
{
|
||||||
- key: Content-Type
|
"folder_path": "{{library_folder}}"
|
||||||
value: application/json
|
}
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
runtime:
|
||||||
|
scripts:
|
||||||
|
- type: after-response
|
||||||
|
code: |-
|
||||||
|
function onResponse(res) {
|
||||||
|
try {
|
||||||
|
const responseBody = res.getBody();
|
||||||
|
const id = responseBody.id;
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
bru.setEnvVar("library_folder_id", id, { persist: true });
|
||||||
|
console.log("Library Folder ID saved:", id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
console.log("No id found in response.");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in post-response script:", error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onResponse(res);
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
|
||||||
docs: |-
|
docs: |-
|
||||||
## Add Library Folder
|
## Add Library Folder
|
||||||
|
|||||||
@@ -2,17 +2,51 @@ info:
|
|||||||
name: Create Library
|
name: Create Library
|
||||||
type: http
|
type: http
|
||||||
seq: 1
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: POST
|
method: POST
|
||||||
url: '{{base_url}}/api/libraries'
|
url: "{{base_url}}/api/libraries"
|
||||||
auth: inherit
|
headers:
|
||||||
|
- name: ""
|
||||||
|
value: application/json
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
jsonBody: "{\n \"name\": \"My Ebook Library\",\n \"description\": \"A collection\
|
data: |-
|
||||||
\ of technical books and novels\",\n \"type\": \"ebooks\""
|
{
|
||||||
headers:
|
"name": "My Ebook Library",
|
||||||
- key: Content-Type
|
"description": "A collection of technical books and novels",
|
||||||
value: application/json
|
"type": "ebooks"
|
||||||
|
}
|
||||||
|
auth: inherit
|
||||||
|
|
||||||
|
runtime:
|
||||||
|
scripts:
|
||||||
|
- type: after-response
|
||||||
|
code: |-
|
||||||
|
function onResponse(res) {
|
||||||
|
try {
|
||||||
|
const responseBody = res.getBody();
|
||||||
|
const id = responseBody.id;
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
bru.setEnvVar("library_id", id, { persist: true });
|
||||||
|
console.log("Library ID saved:", id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
console.log("No id found in response.");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in post-response script:", error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onResponse(res);
|
||||||
|
|
||||||
|
settings:
|
||||||
|
encodeUrl: true
|
||||||
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
|
||||||
docs: |-
|
docs: |-
|
||||||
## Create Library
|
## Create Library
|
||||||
|
|||||||
@@ -2,20 +2,20 @@ info:
|
|||||||
name: Delete Library
|
name: Delete Library
|
||||||
type: http
|
type: http
|
||||||
seq: 3
|
seq: 3
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: DELETE
|
method: DELETE
|
||||||
url: '{{base_url}}/api/libraries/{{library_id}}'
|
url: "{{base_url}}/api/libraries/{{library_id}}"
|
||||||
auth: inherit
|
|
||||||
body:
|
|
||||||
type: none
|
|
||||||
headers:
|
headers:
|
||||||
- key: Content-Type
|
- name: ""
|
||||||
value: application/json
|
value: application/json
|
||||||
runtime:
|
auth: inherit
|
||||||
scripts:
|
|
||||||
- type: tests
|
settings:
|
||||||
code: "test_delete_library_success(status, headers, body) {\n if (status !==\
|
encodeUrl: true
|
||||||
\ 204) {\n throw new Error(\"Expected status 204, got \" + status);"
|
timeout: 0
|
||||||
|
followRedirects: true
|
||||||
|
maxRedirects: 5
|
||||||
|
|
||||||
docs: |-
|
docs: |-
|
||||||
## Delete Library
|
## Delete Library
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ http:
|
|||||||
auth: inherit
|
auth: inherit
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
jsonBody: "{\n \"library_id\": \"{{library_id"
|
data: |-
|
||||||
|
{
|
||||||
|
"library_id": "{{library_id}}",
|
||||||
|
"is_visible": true
|
||||||
|
}
|
||||||
headers:
|
headers:
|
||||||
- key: Content-Type
|
- key: Content-Type
|
||||||
value: application/json
|
value: application/json
|
||||||
|
|||||||
@@ -11,7 +11,15 @@ http:
|
|||||||
value: application/json
|
value: application/json
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
data: ""
|
data: |-
|
||||||
|
{
|
||||||
|
"library_id": "{{library_id}}",
|
||||||
|
"title": "Test Book",
|
||||||
|
"author": "Test Author",
|
||||||
|
"file_path": "/path/to/book.epub",
|
||||||
|
"file_size": 1024,
|
||||||
|
"mime_type": "application/epub+zip"
|
||||||
|
}
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
runtime:
|
runtime:
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ http:
|
|||||||
value: application/json
|
value: application/json
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
data: ""
|
data: |-
|
||||||
|
{
|
||||||
|
"rating": 8
|
||||||
|
}
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
|
|||||||
@@ -11,7 +11,12 @@ http:
|
|||||||
value: application/json
|
value: application/json
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
data: ""
|
data: |-
|
||||||
|
{
|
||||||
|
"title": "Updated Book Title",
|
||||||
|
"author": "Updated Author",
|
||||||
|
"description": "Updated description"
|
||||||
|
}
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
runtime:
|
runtime:
|
||||||
|
|||||||
@@ -11,7 +11,11 @@ http:
|
|||||||
value: application/json
|
value: application/json
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
data: ""
|
data: |-
|
||||||
|
{
|
||||||
|
"rating": 9,
|
||||||
|
"review": "Updated review text"
|
||||||
|
}
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
runtime:
|
runtime:
|
||||||
|
|||||||
@@ -5,22 +5,22 @@ info:
|
|||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
url: "{{base_url}}/api/media-items/search?library_id={{library_id}}&q=foundation&author_filter=asimov&tags_filter=scifi&year_min=1950&year_max=2000&sort=title ASC"
|
url: "{{base_url}}/api/media-items/search?library_id={{library_id}}&q=1984&author_filter=orwell&tags_filter=scifi&year_min=1850&year_max=2000&sort=title ASC"
|
||||||
params:
|
params:
|
||||||
- name: library_id
|
- name: library_id
|
||||||
value: "{{library_id}}"
|
value: "{{library_id}}"
|
||||||
type: query
|
type: query
|
||||||
- name: q
|
- name: q
|
||||||
value: foundation
|
value: "1984"
|
||||||
type: query
|
type: query
|
||||||
- name: author_filter
|
- name: author_filter
|
||||||
value: asimov
|
value: orwell
|
||||||
type: query
|
type: query
|
||||||
- name: tags_filter
|
- name: tags_filter
|
||||||
value: scifi
|
value: scifi
|
||||||
type: query
|
type: query
|
||||||
- name: year_min
|
- name: year_min
|
||||||
value: "1950"
|
value: "1850"
|
||||||
type: query
|
type: query
|
||||||
- name: year_max
|
- name: year_max
|
||||||
value: "2000"
|
value: "2000"
|
||||||
|
|||||||
@@ -8,8 +8,11 @@ http:
|
|||||||
auth: inherit
|
auth: inherit
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
jsonBody: "{\n \"content\": \"This is a test note about this media item.\"\
|
data: |-
|
||||||
,\n \"position\": \"page:45\""
|
{
|
||||||
|
"content": "This is a test note about this media item.",
|
||||||
|
"position": "page:45"
|
||||||
|
}
|
||||||
|
|
||||||
docs: |-
|
docs: |-
|
||||||
## Create Media Note
|
## Create Media Note
|
||||||
|
|||||||
@@ -8,8 +8,11 @@ http:
|
|||||||
auth: inherit
|
auth: inherit
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
jsonBody: "{\n \"content\": \"This is the updated note content.\",\n \"\
|
data: |-
|
||||||
position\": \"page:47\""
|
{
|
||||||
|
"content": "This is the updated note content.",
|
||||||
|
"position": "page:47"
|
||||||
|
}
|
||||||
|
|
||||||
docs: |-
|
docs: |-
|
||||||
## Update Media Note
|
## Update Media Note
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ http:
|
|||||||
auth: inherit
|
auth: inherit
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
jsonBody: "{\n \"current_page\": 45,\n \"total_pages\": 200"
|
data: |-
|
||||||
|
{
|
||||||
|
"current_page": 45,
|
||||||
|
"total_pages": 200
|
||||||
|
}
|
||||||
|
|
||||||
docs: |-
|
docs: |-
|
||||||
## Update Reading Progress
|
## Update Reading Progress
|
||||||
|
|||||||
@@ -8,9 +8,15 @@ http:
|
|||||||
auth: inherit
|
auth: inherit
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
jsonBody: "{\n \"email\": \"maxdevices@example.com\",\n \"username\": \"\
|
data: |-
|
||||||
maxdevicesuser\",\n \"password\": \"Test@Pass123!\",\n \"first_name\"\
|
{
|
||||||
: \"Test\",\n \"last_name\": \"User\",\n \"role\": \"admin\""
|
"email": "admin@example.com",
|
||||||
|
"username": "admin",
|
||||||
|
"password": "Admin@Pass123!",
|
||||||
|
"first_name": "Admin",
|
||||||
|
"last_name": "User",
|
||||||
|
"role": "admin"
|
||||||
|
}
|
||||||
|
|
||||||
docs: |-
|
docs: |-
|
||||||
## Register Admin User
|
## Register Admin User
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ http:
|
|||||||
auth: inherit
|
auth: inherit
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
jsonBody: "{\n \"refresh_token\": \"{{refresh_token"
|
data: |-
|
||||||
|
{
|
||||||
|
"refresh_token": "{{refresh_token}}"
|
||||||
|
}
|
||||||
headers:
|
headers:
|
||||||
- key: Content-Type
|
- key: Content-Type
|
||||||
value: application/json
|
value: application/json
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ http:
|
|||||||
value: application/json
|
value: application/json
|
||||||
body:
|
body:
|
||||||
type: json
|
type: json
|
||||||
data: ""
|
data: |-
|
||||||
|
{
|
||||||
|
"refresh_token": "{{refresh_token}}"
|
||||||
|
}
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
runtime:
|
runtime:
|
||||||
|
|||||||
Reference in New Issue
Block a user