test: form value fill for union (#205)

This commit is contained in:
Roberts Guļāns 2024-06-07 21:34:28 +03:00 committed by GitHub
parent f347f90f79
commit e333471888
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

@ -333,6 +333,25 @@ defmodule AshPhoenix.AutoFormTest do
Enum.at(result.items, 0).subject
end)
end
test "union filled value is shown in input" do
form =
%SimplePost{union: %Ash.Union{value: :update, type: :predefined}}
|> AshPhoenix.Form.for_update(:update,
domain: Domain,
forms: [
auto?: true
],
params: %{
"text" => "foobar"
}
)
# |> Phoenix.HTML.FormData.to_form([])
# IO.inspect(Phoenix.Component.inputs_for(%{field: form[:union], __changed__: %{}}))
# assert "update" == AshPhoenix.Form.value(form[:union], :value)
end
end
describe "list unions" do

View file

@ -30,6 +30,6 @@ defmodule AshPhoenix.Test.SimplePost do
actions do
default_accept(:*)
defaults([:create])
defaults([:create, :update])
end
end