diff --git a/CHANGELOG.md b/CHANGELOG.md index 850923a8cd..64f2c29c44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ and this project adheres to - Fix issue creating a new credential from the Job editor where the new credential was not being set on the job. [#951](https://github.com/OpenFn/Lightning/issues/951) +- Fix issue where checking a credential type radio button shows as unchecked on + first click. [#976](https://github.com/OpenFn/Lightning/issues/976) ## [v0.7.0-pre5] - 2023-07-28 diff --git a/lib/lightning_web/live/credential_live/type_picker.ex b/lib/lightning_web/live/credential_live/type_picker.ex index 5d97a15dab..fdc0918054 100644 --- a/lib/lightning_web/live/credential_live/type_picker.ex +++ b/lib/lightning_web/live/credential_live/type_picker.ex @@ -28,7 +28,7 @@ defmodule LightningWeb.CredentialLive.TypePicker do <.form :let={f} id="credential-type-picker" - for={%{}} + for={%{"selected" => @selected}} as={:type} phx-target={@myself} phx-change="type_changed" diff --git a/test/support/credential_live_helpers.ex b/test/support/credential_live_helpers.ex index d91c4f9f68..12a461dfa5 100644 --- a/test/support/credential_live_helpers.ex +++ b/test/support/credential_live_helpers.ex @@ -1,10 +1,17 @@ defmodule LightningWeb.CredentialLiveHelpers do import Phoenix.LiveViewTest + import ExUnit.Assertions def select_credential_type(live, type) do - live - |> form("#credential-type-picker", type: %{selected: type}) - |> render_change() + html = + live + |> form("#credential-type-picker", type: %{selected: type}) + |> render_change() + + assert Floki.parse_fragment!(html) + |> Floki.find("input[type=radio][value=#{type}][checked]") + |> Enum.any?(), + "Expected #{type} to be selected" end def click_continue(live) do