meta { name: Test Collection Rules - No Matches type: http seq: 4 } post { url: {{base_url}}/api/collections/test-rules body: json auth: inherit } headers { Content-Type: application/json Authorization: Bearer {{authToken}} } body:json { { "rules": [ { "field": "genre", "operator": "equals", "value": "NonExistentGenre123456" } ] } } script:post-response { function onResponse(res) { if (res.getStatus() === 200) { const body = res.getBody(); tests['No matches returned'] = body.total === 0; tests['Empty matches array'] = body.matches.length === 0; tests['Success with zero results'] = true; } } onResponse(res); } settings { encodeUrl: true timeout: 0 } docs { ## Test Collection Rules - No Matches Tests behavior when collection rules don't match any books in the library. **Example Use Case:** Validating that a new genre name doesn't exist before creating a collection for it, or testing edge cases. **Expected Result:** 200 OK with empty matches array and total: 0 **Purpose:** Verifies that the API handles zero-match scenarios gracefully: - Returns 200 (success) not 404 - Returns empty array, not null - Returns total: 0 for clarity - No errors thrown for no results **Note:** An empty result set is a valid response and doesn't indicate an error. This allows users to test rules confidently before creating collections. }