Ok, I have this test:
@tag :integration
test "saves new funcionario", %{conn: conn} do
{:ok, index_live, _html} = live(conn, Routes.funcionario_index_path(conn, :index))
assert index_live |> element("a", "New Funcionario") |> render_click() =~
"New Funcionario"
assert_patch(index_live, Routes.funcionario_index_path(conn, :new))
assert index_live
|> form("#funcionario-form", funcionario: @invalid_attrs)
|> render_change() =~ "can't be blank"
%{id: empresa_id} = insert(:empresa)
valid_fields = valid_fields()
create_attrs = @create_attrs |> Map.merge(valid_fields) |> Map.put(:empresa_id, empresa_id)
{:ok, _, html} =
index_live
|> form("#funcionario-form", funcionario: create_attrs)
|> render_submit()
|> follow_redirect(conn, Routes.funcionario_index_path(conn, :index))
assert html =~ valid_fields.cpf
assert html =~ valid_fields.rg
end
However, it fails on the follow_redirect/3
function, giving me this error:
1) test Index saves new funcionario (ContsWeb.FuncionarioLiveTest)
test/conts_web/live/funcionario_live_test.exs:132
** (RuntimeError) LiveView did not redirect
code: |> follow_redirect(conn, Routes.funcionario_index_path(conn, :index))
stacktrace:
test/conts_web/live/funcionario_live_test.exs:152: (test)
So I tried to make this path manually on a dev server. And it worked!
Could anyone explain me what exactly this error is complaining about? How it could work without errors manually and on tests it fails?