refactor(bruno): migrate API tests to Bruno DSL format

- Convert all existing .bru files from JSON to Bruno DSL format
- Remove obsolete files (conflicts/api.bru, kobo/Kobo Initialization.bru)
- Update auth configuration to use 'inherit' instead of explicit bearer tokens
- Add comprehensive documentation to all test files
- Improve test scripts with proper assertions and error handling
This commit is contained in:
2026-02-08 20:49:06 -05:00
parent cb76b9ca05
commit 3117ce54ec
93 changed files with 3974 additions and 1576 deletions
+99 -29
View File
@@ -1,34 +1,104 @@
{
"meta": {
"name": "Get Reading Stats",
"type": "http",
"event": [
meta {
name: Get Reading Stats
type: http
seq: 4
}
get {
url: {{baseUrl}}/api/analytics/reading-stats
body: none
auth: inherit
}
tests {
test("status must be 200", function() {
expect(res.status).to.eql(200);
});
test("response has required stats fields", function() {
const body = JSON.parse(res.body);
expect(body).to.have.property("total_books_read");
expect(body).to.have.property("total_pages_read");
expect(body).to.have.property("total_reading_time_minutes");
expect(body).to.have.property("completion_rate");
expect(body).to.have.property("daily_reading_minutes");
});
test("daily_reading_minutes is an array", function() {
const body = JSON.parse(res.body);
expect(body.daily_reading_minutes).to.be.an("array");
});
}
settings {
encodeUrl: true
timeout: 0
}
docs {
Get overall reading statistics for the authenticated user.
**Endpoint**: GET /api/analytics/reading-stats
**Auth**: Required (Bearer token)
## Query Parameters
| Parameter | Type | Required | Description |
|-----------|------|-----------|-------------|
| start_date | string | No | Start date (ISO 8601 format) |
| end_date | string | No | End date (ISO 8601 format) |
## Response Fields
| Field | Type | Description |
|-------|------|-------------|
| total_books_read | int | Total books completed |
| total_pages_read | int | Total pages read |
| total_reading_time_minutes | int | Total reading time in minutes |
| completion_rate | float | Average book completion rate (0-1) |
| daily_reading_minutes | array | Daily reading time breakdown |
| daily_reading_minutes[].date | string | Date (ISO 8601) |
| daily_reading_minutes[].minutes | int | Minutes read on that date |
## Example Request
```
GET /api/analytics/reading-stats
```
## Example Response
```json
{
"total_books_read": 12,
"total_pages_read": 3450,
"total_reading_time_minutes": 5400,
"completion_rate": 0.78,
"daily_reading_minutes": [
{
"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;",
"}"
]
}
"date": "2026-01-15",
"minutes": 45
},
{
"date": "2026-01-16",
"minutes": 60
}
]
},
"req": {
"url": "{{baseUrl}}/api/analytics/reading-stats",
"method": "GET",
"headers": {
"Authorization": "Bearer {{authToken}}"
}
}
```
## Error Responses
| Code | Description |
|------|-------------|
| 400 | Invalid date format |
| 401 | Unauthorized |
| 500 | Internal server error |
## Notes
- Without date parameters, returns stats for the last 30 days
- Dates must be in ISO 8601 format (YYYY-MM-DD) when provided
- Only includes reading activity from the authenticated user
- Daily data includes all days with reading activity
}