Skip to content

Commit 7158ff7

Browse files
committed
test: add array filtering test cases with different query param formats
1 parent 7e0b5d5 commit 7158ff7

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

test/spec_compliance/fetching_data/filtering_test.exs

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,51 @@ defmodule AshJsonApiTest.FetchingData.Filtering do
191191
|> Ash.Changeset.for_create(:create, %{name: "bar", narratives: [:legend]})
192192
|> Ash.create!()
193193

194-
_conn =
195-
Domain
196-
|> get("/posts?filter[narratives][in]=novel,legend", status: 200)
197-
|> assert_valid_resource_objects("post", [post.id, post2.id])
194+
# single value
195+
# _conn =
196+
# Domain
197+
# |> get("/filter[narratives][in]=novel",
198+
# status: 200
199+
# )
200+
# |> assert_valid_resource_objects("post", [post.id, post2.id])
201+
202+
# comma-separated
203+
# _conn =
204+
# Domain
205+
# |> get("/posts?filter[narratives][in]=novel,legend",
206+
# status: 200
207+
# )
208+
# |> assert_valid_resource_objects("post", [post.id, post2.id])
209+
210+
# PHP-style array
211+
# _conn =
212+
# Domain
213+
# |> get("/posts?filter[narratives][in][]=novel&filter[narratives][in][]=legend",
214+
# status: 200
215+
# )
216+
# |> assert_valid_resource_objects("post", [post.id, post2.id])
198217

218+
# nested array
199219
# _conn =
200220
# Domain
201-
# |> get("/posts?filter[narratives][in][][]=novel", status: 200)
221+
# |> get("/posts?filter[narratives][in][][]=novel ",
222+
# status: 200
223+
# )
202224
# |> assert_valid_resource_objects("post", [post.id, post2.id])
203225

226+
# bracket notation
227+
# _conn =
228+
# Domain
229+
# |> get("/posts?filter[narratives][in]=[novel,legend]", status: 200)
230+
# |> assert_valid_resource_objects("post", [post.id, post2.id])
231+
232+
_conn =
233+
Domain
234+
|> get("/posts?filter[narratives][in][0]=novel&filter[narratives][in][1]=legend",
235+
status: 200
236+
)
237+
|> assert_valid_resource_objects("post", [post.id, post2.id])
238+
204239
# _conn =
205240
# Domain
206241
# |> get("/posts?filter[narratives][not_in]=novel,legend", status: 200)

0 commit comments

Comments
 (0)