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
|
||||
value: 7710a602-g29b-61d4-c716-446655440002
|
||||
- name: library_id
|
||||
value: dd03d719-76c8-4398-93ec-9258d2becf85
|
||||
value: d2932c11-cd39-4c4a-b940-124b75964099
|
||||
- name: job_id
|
||||
value: 295654b3-eb4b-4e85-ac6c-9361c5821195
|
||||
value: c5766af2-44a5-4537-abb0-e3fa42fc93f9
|
||||
- name: rating
|
||||
value: "5"
|
||||
- name: is_visible
|
||||
|
||||
@@ -8,9 +8,14 @@ http:
|
||||
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\": \"\""
|
||||
data: |-
|
||||
{
|
||||
"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: |-
|
||||
## 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
|
||||
body:
|
||||
type: json
|
||||
jsonBody: "{\n \"selection_text\": \"This is the updated highlighted text.\"\
|
||||
,\n \"start_position\": \"page:45:offset:125\",\n \"end_position\": \"\
|
||||
page:45:offset:150\",\n \"color\": \"#ffeb3b\",\n \"note_id\": \"\""
|
||||
data: |-
|
||||
{
|
||||
"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: |-
|
||||
## Update Media Highlight
|
||||
|
||||
@@ -2,16 +2,49 @@ info:
|
||||
name: Add Library Folder
|
||||
type: http
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: '{{base_url}}/api/libraries/{{library_id}}/folders'
|
||||
auth: inherit
|
||||
url: "{{base_url}}/api/libraries/{{library_id}}/folders"
|
||||
headers:
|
||||
- name: ""
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
jsonBody: "{\n \"folder_path\": {{library_folder"
|
||||
headers:
|
||||
- key: Content-Type
|
||||
value: application/json
|
||||
data: |-
|
||||
{
|
||||
"folder_path": "{{library_folder}}"
|
||||
}
|
||||
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: |-
|
||||
## Add Library Folder
|
||||
|
||||
@@ -2,17 +2,51 @@ info:
|
||||
name: Create Library
|
||||
type: http
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: '{{base_url}}/api/libraries'
|
||||
auth: inherit
|
||||
url: "{{base_url}}/api/libraries"
|
||||
headers:
|
||||
- name: ""
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
jsonBody: "{\n \"name\": \"My Ebook Library\",\n \"description\": \"A collection\
|
||||
\ of technical books and novels\",\n \"type\": \"ebooks\""
|
||||
headers:
|
||||
- key: Content-Type
|
||||
value: application/json
|
||||
data: |-
|
||||
{
|
||||
"name": "My Ebook Library",
|
||||
"description": "A collection of technical books and novels",
|
||||
"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: |-
|
||||
## Create Library
|
||||
|
||||
@@ -2,20 +2,20 @@ info:
|
||||
name: Delete Library
|
||||
type: http
|
||||
seq: 3
|
||||
|
||||
http:
|
||||
method: DELETE
|
||||
url: '{{base_url}}/api/libraries/{{library_id}}'
|
||||
auth: inherit
|
||||
body:
|
||||
type: none
|
||||
url: "{{base_url}}/api/libraries/{{library_id}}"
|
||||
headers:
|
||||
- key: Content-Type
|
||||
value: application/json
|
||||
runtime:
|
||||
scripts:
|
||||
- type: tests
|
||||
code: "test_delete_library_success(status, headers, body) {\n if (status !==\
|
||||
\ 204) {\n throw new Error(\"Expected status 204, got \" + status);"
|
||||
- name: ""
|
||||
value: application/json
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
followRedirects: true
|
||||
maxRedirects: 5
|
||||
|
||||
docs: |-
|
||||
## Delete Library
|
||||
|
||||
@@ -8,7 +8,11 @@ http:
|
||||
auth: inherit
|
||||
body:
|
||||
type: json
|
||||
jsonBody: "{\n \"library_id\": \"{{library_id"
|
||||
data: |-
|
||||
{
|
||||
"library_id": "{{library_id}}",
|
||||
"is_visible": true
|
||||
}
|
||||
headers:
|
||||
- key: Content-Type
|
||||
value: application/json
|
||||
|
||||
@@ -11,7 +11,15 @@ http:
|
||||
value: application/json
|
||||
body:
|
||||
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
|
||||
|
||||
runtime:
|
||||
|
||||
@@ -11,7 +11,10 @@ http:
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
data: ""
|
||||
data: |-
|
||||
{
|
||||
"rating": 8
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
|
||||
@@ -11,7 +11,12 @@ http:
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
data: ""
|
||||
data: |-
|
||||
{
|
||||
"title": "Updated Book Title",
|
||||
"author": "Updated Author",
|
||||
"description": "Updated description"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
|
||||
@@ -11,7 +11,11 @@ http:
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
data: ""
|
||||
data: |-
|
||||
{
|
||||
"rating": 9,
|
||||
"review": "Updated review text"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
|
||||
@@ -5,22 +5,22 @@ info:
|
||||
|
||||
http:
|
||||
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:
|
||||
- name: library_id
|
||||
value: "{{library_id}}"
|
||||
type: query
|
||||
- name: q
|
||||
value: foundation
|
||||
value: "1984"
|
||||
type: query
|
||||
- name: author_filter
|
||||
value: asimov
|
||||
value: orwell
|
||||
type: query
|
||||
- name: tags_filter
|
||||
value: scifi
|
||||
type: query
|
||||
- name: year_min
|
||||
value: "1950"
|
||||
value: "1850"
|
||||
type: query
|
||||
- name: year_max
|
||||
value: "2000"
|
||||
|
||||
@@ -8,8 +8,11 @@ http:
|
||||
auth: inherit
|
||||
body:
|
||||
type: json
|
||||
jsonBody: "{\n \"content\": \"This is a test note about this media item.\"\
|
||||
,\n \"position\": \"page:45\""
|
||||
data: |-
|
||||
{
|
||||
"content": "This is a test note about this media item.",
|
||||
"position": "page:45"
|
||||
}
|
||||
|
||||
docs: |-
|
||||
## Create Media Note
|
||||
|
||||
@@ -8,8 +8,11 @@ http:
|
||||
auth: inherit
|
||||
body:
|
||||
type: json
|
||||
jsonBody: "{\n \"content\": \"This is the updated note content.\",\n \"\
|
||||
position\": \"page:47\""
|
||||
data: |-
|
||||
{
|
||||
"content": "This is the updated note content.",
|
||||
"position": "page:47"
|
||||
}
|
||||
|
||||
docs: |-
|
||||
## Update Media Note
|
||||
|
||||
@@ -8,7 +8,11 @@ http:
|
||||
auth: inherit
|
||||
body:
|
||||
type: json
|
||||
jsonBody: "{\n \"current_page\": 45,\n \"total_pages\": 200"
|
||||
data: |-
|
||||
{
|
||||
"current_page": 45,
|
||||
"total_pages": 200
|
||||
}
|
||||
|
||||
docs: |-
|
||||
## Update Reading Progress
|
||||
|
||||
@@ -8,9 +8,15 @@ http:
|
||||
auth: inherit
|
||||
body:
|
||||
type: json
|
||||
jsonBody: "{\n \"email\": \"maxdevices@example.com\",\n \"username\": \"\
|
||||
maxdevicesuser\",\n \"password\": \"Test@Pass123!\",\n \"first_name\"\
|
||||
: \"Test\",\n \"last_name\": \"User\",\n \"role\": \"admin\""
|
||||
data: |-
|
||||
{
|
||||
"email": "admin@example.com",
|
||||
"username": "admin",
|
||||
"password": "Admin@Pass123!",
|
||||
"first_name": "Admin",
|
||||
"last_name": "User",
|
||||
"role": "admin"
|
||||
}
|
||||
|
||||
docs: |-
|
||||
## Register Admin User
|
||||
|
||||
@@ -8,7 +8,10 @@ http:
|
||||
auth: inherit
|
||||
body:
|
||||
type: json
|
||||
jsonBody: "{\n \"refresh_token\": \"{{refresh_token"
|
||||
data: |-
|
||||
{
|
||||
"refresh_token": "{{refresh_token}}"
|
||||
}
|
||||
headers:
|
||||
- key: Content-Type
|
||||
value: application/json
|
||||
|
||||
@@ -11,7 +11,10 @@ http:
|
||||
value: application/json
|
||||
body:
|
||||
type: json
|
||||
data: ""
|
||||
data: |-
|
||||
{
|
||||
"refresh_token": "{{refresh_token}}"
|
||||
}
|
||||
auth: inherit
|
||||
|
||||
runtime:
|
||||
|
||||
Reference in New Issue
Block a user