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,35 +1,88 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Get Device Usage",
|
||||
"type": "http",
|
||||
"event": [
|
||||
meta {
|
||||
name: Get Device Usage
|
||||
type: http
|
||||
seq: 2
|
||||
}
|
||||
|
||||
get {
|
||||
url: {{baseUrl}}/api/analytics/device-usage
|
||||
body: none
|
||||
auth: inherit
|
||||
}
|
||||
|
||||
tests {
|
||||
test("status must be 200", function() {
|
||||
expect(res.status).to.eql(200);
|
||||
});
|
||||
|
||||
test("response has devices array", function() {
|
||||
const body = JSON.parse(res.body);
|
||||
expect(body).to.have.property("devices");
|
||||
expect(body.devices).to.be.an("array");
|
||||
});
|
||||
|
||||
test("devices have required fields", function() {
|
||||
const body = JSON.parse(res.body);
|
||||
if (body.devices.length > 0) {
|
||||
expect(body.devices[0]).to.have.property("device_name");
|
||||
expect(body.devices[0]).to.have.property("device_type");
|
||||
expect(body.devices[0]).to.have.property("sync_count");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
settings {
|
||||
encodeUrl: true
|
||||
timeout: 0
|
||||
}
|
||||
|
||||
docs {
|
||||
Get usage statistics for all devices.
|
||||
|
||||
**Endpoint**: GET /api/analytics/device-usage
|
||||
**Auth**: Required (Bearer token)
|
||||
|
||||
## Response Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| devices | array | List of device usage statistics |
|
||||
| devices[].id | string | Device ID |
|
||||
| devices[].device_name | string | Device name |
|
||||
| devices[].device_type | string | Device type (kobo, kindle, koreader) |
|
||||
| devices[].sync_count | int | Number of sync operations |
|
||||
| devices[].last_sync | string | Last sync timestamp |
|
||||
| devices[].total_reading_minutes | int | Total reading time on device |
|
||||
| devices[].books_read | int | Number of books completed on device |
|
||||
|
||||
## Example Response
|
||||
|
||||
```json
|
||||
{
|
||||
"devices": [
|
||||
{
|
||||
"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;",
|
||||
"}"
|
||||
]
|
||||
}
|
||||
"id": "789e4567-e89b-12d3-a456-426614174001",
|
||||
"device_name": "My Kobo Clara",
|
||||
"device_type": "kobo",
|
||||
"sync_count": 45,
|
||||
"last_sync": "2026-02-08T17:25:00Z",
|
||||
"total_reading_minutes": 1250,
|
||||
"books_read": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
"req": {
|
||||
"url": "{{baseUrl}}/api/analytics/device-usage",
|
||||
"method": "GET",
|
||||
"headers": {
|
||||
"Authorization": "Bearer {{authToken}}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Error Responses
|
||||
|
||||
| Code | Description |
|
||||
|------|-------------|
|
||||
| 401 | Unauthorized |
|
||||
| 500 | Internal server error |
|
||||
|
||||
## Notes
|
||||
|
||||
- Only shows devices registered to the authenticated user
|
||||
- Devices are sorted by sync_count in descending order
|
||||
- Includes both active and inactive devices
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user