Skip to content

Commit 992d9bf

Browse files
chore: adding clear filter tests
1 parent 3594ac3 commit 992d9bf

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/components/resource/data_table_filtering_test.exs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,4 +418,37 @@ defmodule AshAdmin.Test.Components.Resource.DataTableFilteringTest do
418418
refute html =~ "Third post about Testing"
419419
end
420420
end
421+
422+
describe "clear filters" do
423+
test "clearing filters restores all results", %{conn: conn} do
424+
{view, _html} =
425+
live_and_wait(conn, "/api/admin?domain=Domain&resource=Post&action_type=read&action=read")
426+
427+
# Apply a filter first
428+
view
429+
|> element("form")
430+
|> render_change(%{"filters" => %{"body" => "Phoenix"}})
431+
432+
# Wait for Cinder to re-query
433+
html = render_async(view)
434+
435+
# Should show only filtered result
436+
assert html =~ "Second post about Phoenix"
437+
refute html =~ "First post about Elixir"
438+
refute html =~ "Third post about Testing"
439+
440+
# Clear the filter by setting it to empty string
441+
view
442+
|> element("form")
443+
|> render_change(%{"filters" => %{"body" => ""}})
444+
445+
# Wait for Cinder to re-query
446+
html = render_async(view)
447+
448+
# Should show all posts again
449+
assert html =~ "First post about Elixir"
450+
assert html =~ "Second post about Phoenix"
451+
assert html =~ "Third post about Testing"
452+
end
453+
end
421454
end

0 commit comments

Comments
 (0)