From e333471888bd417db1899384bc43fb17cfd88bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberts=20Gu=C4=BC=C4=81ns?= Date: Fri, 7 Jun 2024 21:34:28 +0300 Subject: [PATCH] test: form value fill for union (#205) --- test/auto_form_test.exs | 19 +++++++++++++++++++ test/support/resources/simple_post.ex | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/test/auto_form_test.exs b/test/auto_form_test.exs index dfd6246..d5f6f58 100644 --- a/test/auto_form_test.exs +++ b/test/auto_form_test.exs @@ -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 diff --git a/test/support/resources/simple_post.ex b/test/support/resources/simple_post.ex index 7d82699..0e1e24d 100644 --- a/test/support/resources/simple_post.ex +++ b/test/support/resources/simple_post.ex @@ -30,6 +30,6 @@ defmodule AshPhoenix.Test.SimplePost do actions do default_accept(:*) - defaults([:create]) + defaults([:create, :update]) end end