test: add ApiDocsLive full-packet path to exercise format functions
This commit is contained in:
parent
e3dfdf03ba
commit
0a1c5aa61d
1 changed files with 33 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
defmodule AprsmeWeb.ApiDocsLiveTest do
|
||||
use AprsmeWeb.ConnCase
|
||||
|
||||
import Aprsme.PacketsFixtures
|
||||
import Phoenix.LiveViewTest
|
||||
|
||||
describe "ApiDocsLive" do
|
||||
|
|
@ -74,5 +75,37 @@ defmodule AprsmeWeb.ApiDocsLiveTest do
|
|||
# packet result. Both exercise the happy path of make_http_request.
|
||||
assert rendered =~ "No packets found" or rendered =~ "data"
|
||||
end
|
||||
|
||||
test "valid callsign with existing packet returns JSON data", %{conn: conn} do
|
||||
# Create a packet in the DB so the test_api event actually returns data.
|
||||
_packet =
|
||||
packet_fixture(%{
|
||||
sender: "K5ABC-9",
|
||||
base_callsign: "K5ABC",
|
||||
ssid: "9",
|
||||
received_at: DateTime.utc_now(),
|
||||
lat: Decimal.new("33.0"),
|
||||
lon: Decimal.new("-96.5"),
|
||||
has_position: true,
|
||||
comment: "API test packet",
|
||||
temperature: 72.5,
|
||||
humidity: 50
|
||||
})
|
||||
|
||||
{:ok, lv, _html} = live(conn, ~p"/api", on_error: :warn)
|
||||
|
||||
lv
|
||||
|> element("#test_callsign")
|
||||
|> render_change(%{"callsign" => "K5ABC-9"})
|
||||
|
||||
lv
|
||||
|> form("form[phx-submit=\"test_api\"]", %{"callsign" => "K5ABC-9"})
|
||||
|> render_submit()
|
||||
|
||||
:ok = Process.sleep(150)
|
||||
rendered = render(lv)
|
||||
assert rendered =~ "K5ABC"
|
||||
assert rendered =~ "data"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue