From 785263e514b201ffa2a91e726b107144e343f459 Mon Sep 17 00:00:00 2001 From: Darren Black Date: Sun, 18 Jul 2021 05:57:27 +1000 Subject: [PATCH] test: Add failing test (#9) --- test/form_test.exs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/form_test.exs b/test/form_test.exs index 3d3e6e6..c52f9d7 100644 --- a/test/form_test.exs +++ b/test/form_test.exs @@ -552,5 +552,40 @@ defmodule AshPhoenix.FormTest do assert [%Phoenix.HTML.Form{source: %AshPhoenix.Form{resource: AshPhoenix.Test.Post}}] = inputs_for(form_for(form, "action"), :post) end + + test "failing single intermediate form" do + post_id = Ash.UUID.generate() + comment = %Comment{text: "text", post: %Post{id: post_id, text: "Some text"}} + + form = + comment + |> Form.for_update(:update, + forms: [ + post: [ + data: comment.post, + type: :single, + resource: Post, + update_action: :update, + create_action: :create, + forms: [ + comments: [ + data: & &1.comments, + type: :list, + resource: Comment, + update_action: :update, + create_action: :create + ] + ] + ] + ] + ) + + assert [%Phoenix.HTML.Form{source: %AshPhoenix.Form{resource: AshPhoenix.Test.Post}}] = + form + |> form_for("action") + |> inputs_for(:post) + |> hd() + |> inputs_for(:comments) + end end end