defmodule CartosnapAppWeb.UserLive.SettingsDevicesTest do
use CartosnapAppWeb.ConnCase, async: true
import Phoenix.LiveViewTest
alias CartosnapApp.Accounts
setup :register_and_log_in_user
test "pairs a device with a code, and unpairs it", %{conn: conn, user: user} do
{:ok, view, _html} = live(conn, ~p"/users/settings")
refute has_element?(view, "#pairing-code")
view |> element("#pair-device") |> render_click()
code =
view |> element("#pairing-code") |> render() |> LazyHTML.from_fragment() |> LazyHTML.text()
assert {:ok, _key, _user} = Accounts.redeem_pairing_code(String.trim(code), "Pixel 8")
{:ok, view, _html} = live(conn, ~p"/users/settings")
[device] = Accounts.list_api_tokens(user)
assert has_element?(view, "#device-#{device.id}", "Pixel 8")
view |> element("#device-#{device.id} button") |> render_click()
refute has_element?(view, "#device-#{device.id}")
end
end
neiam
/cartosnap_ex
public · Issues · Pulls · Labels · Forks · Compare · Actions queued · Badges · Packages
⭐
Log in to mark this repository.
946 B · text
History
e569b6d