test(api): add Bruno tests for analytics, books, and bulk operations

Analytics:
- Reading stats endpoint tests
- Device usage tests
- Popular books tests

Books:
- Bulk delete tests
- Bulk update tests

Collections:
- Bulk add books to collections tests

Conflicts:
- Bulk resolve conflicts tests
- Bulk dismiss conflicts tests
- Bulk resolve highest progress tests

All tests cover no user, user, and admin contexts
This commit is contained in:
2026-02-01 12:16:07 -05:00
parent ef8f39bd5a
commit 2df5ca3325
10 changed files with 395 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
{
"meta": {
"name": "Get Device Usage",
"type": "http",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Test device usage response",
"if (response.status === 200) {",
" tests['Device usage loaded'] = true;",
" const body = JSON.parse(response.body);",
" tests['Has devices array'] = Array.isArray(body.devices);",
" if (body.devices.length > 0) {",
" tests['Device has device_name'] = body.devices[0].device_name !== undefined;",
" tests['Device has device_type'] = body.devices[0].device_type !== undefined;",
" tests['Device has sync_count'] = body.devices[0].sync_count !== undefined;",
" }",
"} else {",
" tests['Device usage failed'] = false;",
"}"
]
}
}
]
},
"req": {
"url": "{{baseUrl}}/api/analytics/device-usage",
"method": "GET",
"headers": {
"Authorization": "Bearer {{authToken}}"
}
}
}
+36
View File
@@ -0,0 +1,36 @@
{
"meta": {
"name": "Get Popular Books",
"type": "http",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Test popular books response",
"if (response.status === 200) {",
" tests['Popular books loaded'] = true;",
" const body = JSON.parse(response.body);",
" tests['Has books array'] = Array.isArray(body.books);",
" if (body.books.length > 0) {",
" tests['Book has title'] = body.books[0].title !== undefined;",
" tests['Book has author'] = body.books[0].author !== undefined;",
" tests['Book has read_count'] = body.books[0].read_count !== undefined;",
" tests['Book has avg_completion'] = body.books[0].avg_completion !== undefined;",
" }",
"} else {",
" tests['Popular books failed'] = false;",
"}"
]
}
}
]
},
"req": {
"url": "{{baseUrl}}/api/analytics/popular-books?limit=10",
"method": "GET",
"headers": {
"Authorization": "Bearer {{authToken}}"
}
}
}
@@ -0,0 +1,30 @@
{
"meta": {
"name": "Get Reading Stats with Date Range",
"type": "http",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Test reading stats with custom date range",
"if (response.status === 200) {",
" tests['Date range stats loaded'] = true;",
" const body = JSON.parse(response.body);",
" tests['Has daily_reading_minutes'] = Array.isArray(body.daily_reading_minutes);",
"} else {",
" tests['Date range stats failed'] = false;",
"}"
]
}
}
]
},
"req": {
"url": "{{baseUrl}}/api/analytics/reading-stats?start_date=2024-01-01&end_date=2024-01-31",
"method": "GET",
"headers": {
"Authorization": "Bearer {{authToken}}"
}
}
}
+34
View File
@@ -0,0 +1,34 @@
{
"meta": {
"name": "Get Reading Stats",
"type": "http",
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Test reading stats response",
"if (response.status === 200) {",
" tests['Reading stats loaded'] = true;",
" const body = JSON.parse(response.body);",
" tests['Has total_books_read'] = body.total_books_read !== undefined;",
" tests['Has total_pages_read'] = body.total_pages_read !== undefined;",
" tests['Has total_reading_time_minutes'] = body.total_reading_time_minutes !== undefined;",
" tests['Has completion_rate'] = body.completion_rate !== undefined;",
" tests['Has daily_reading_minutes array'] = Array.isArray(body.daily_reading_minutes);",
"} else {",
" tests['Reading stats failed'] = false;",
"}"
]
}
}
]
},
"req": {
"url": "{{baseUrl}}/api/analytics/reading-stats",
"method": "GET",
"headers": {
"Authorization": "Bearer {{authToken}}"
}
}
}