Skip to content

Commit dd27656

Browse files
committed
fix: update pagination handling in API tests to improve cursor management and stop conditions
1 parent 8a7cbea commit dd27656

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

core/dbio/api/api_suite.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
pagination:
7777
id: cursor_xyz789
7878
limit: 50
79-
hasMore: true
79+
hasMore: false
8080
items:
8181
- id: 1
8282
status: shipped
@@ -91,6 +91,9 @@
9191
endpoints:
9292
test_endpoint:
9393
name: test_endpoint
94+
request:
95+
parameters:
96+
cursor: "{state.page_cursor}"
9497
response:
9598
processors:
9699
- expression: response.json.pagination.id
@@ -102,7 +105,7 @@
102105
records:
103106
jmespath: items
104107
pagination:
105-
stop_condition: "length(response.json.items) == 0"
108+
stop_condition: "response.json.pagination.hasMore == false"
106109
next_state:
107110
page_cursor: "{state.cursor}"
108111
id: "{response.json.pagination.id}"
@@ -144,6 +147,9 @@
144147
state:
145148
base_url: https://api.example.com
146149
version: v2
150+
request:
151+
parameters:
152+
cursor: "{state.cursor}"
147153
response:
148154
processors:
149155
- expression: response.json.meta.next_cursor
@@ -162,7 +168,7 @@
162168
records:
163169
jmespath: results
164170
pagination:
165-
stop_condition: "is_null(response.json.meta.next_cursor)"
171+
stop_condition: response.json.meta.next_cursor == "next_page_123"
166172
next_state:
167173
cursor: "{state.next_cursor}"
168174
limit: "{state.page_size}"
@@ -209,6 +215,9 @@
209215
default_limit: 50
210216
max_limit: 100
211217
base_time: "2025-01-10T00:00:00Z"
218+
request:
219+
parameters:
220+
token: "{state.token}"
212221
response:
213222
processors:
214223
- expression: response.json.pagination.next_token
@@ -223,7 +232,7 @@
223232
records:
224233
jmespath: data
225234
pagination:
226-
stop_condition: "!state.has_more || is_null(state.token)"
235+
stop_condition: '!state.has_more || is_null(state.token) || response.json.pagination.next_token == "token_456"'
227236
next_state:
228237
# Use coalesce to handle null per_page
229238
limit: "{ coalesce(response.json.pagination.per_page, state.default_limit) }"

0 commit comments

Comments
 (0)