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:
@@ -1,30 +1,95 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Get Reading Stats with Date Range",
|
||||
"type": "http",
|
||||
"event": [
|
||||
meta {
|
||||
name: Get Reading Stats Date Range
|
||||
type: http
|
||||
seq: 3
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{baseUrl}}/api/analytics/reading-stats?start_date=2024-01-01&end_date=2024-01-31
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
tests {
|
||||
test("status must be 200", function() {
|
||||
expect(res.status).to.eql(200);
|
||||
});
|
||||
|
||||
test("response has daily_reading_minutes array", function() {
|
||||
const body = JSON.parse(res.body);
|
||||
expect(body).to.have.property("daily_reading_minutes");
|
||||
expect(body.daily_reading_minutes).to.be.an("array");
|
||||
});
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
Get reading statistics for a specific date range.
|
||||
|
||||
**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, default: 30 days ago) |
|
||||
| end_date | string | No | End date (ISO 8601 format, default: today) |
|
||||
|
||||
## Response Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| total_books_read | int | Total books completed in range |
|
||||
| total_pages_read | int | Total pages read in range |
|
||||
| total_reading_time_minutes | int | Total reading time in minutes |
|
||||
| completion_rate | float | Percentage of books completed (0-1) |
|
||||
| daily_reading_minutes | array | Daily reading time per day |
|
||||
| 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?start_date=2024-01-01&end_date=2024-01-31
|
||||
```
|
||||
|
||||
## Example Response
|
||||
|
||||
```json
|
||||
{
|
||||
"total_books_read": 2,
|
||||
"total_pages_read": 450,
|
||||
"total_reading_time_minutes": 720,
|
||||
"completion_rate": 0.85,
|
||||
"daily_reading_minutes": [
|
||||
{
|
||||
"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;",
|
||||
"}"
|
||||
]
|
||||
}
|
||||
"date": "2024-01-01",
|
||||
"minutes": 30
|
||||
},
|
||||
{
|
||||
"date": "2024-01-02",
|
||||
"minutes": 45
|
||||
}
|
||||
]
|
||||
},
|
||||
"req": {
|
||||
"url": "{{baseUrl}}/api/analytics/reading-stats?start_date=2024-01-01&end_date=2024-01-31",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Authorization": "Bearer {{authToken}}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Error Responses
|
||||
|
||||
| Code | Description |
|
||||
|------|-------------|
|
||||
| 400 | Invalid date format |
|
||||
| 401 | Unauthorized |
|
||||
| 500 | Internal server error |
|
||||
|
||||
## Notes
|
||||
|
||||
- Dates must be in ISO 8601 format (YYYY-MM-DD)
|
||||
- The range is inclusive of both start and end dates
|
||||
- Daily data only includes days with reading activity > 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user