prop/test/microwaveprop_web/controllers/api/v1/profile_controller_test.exs
Graham McIntire e3d430f8c4
feat(weather): add duct cutoff band map layer
Show on /weather where the detected duct geometry traps each microwave
band. Overview mode bins cells by their lowest trapped frequency
(Bean & Dutton cutoff); band-picker mode masks cells whose duct doesn't
reach the selected band. Cutoff is pre-computed per cell in both
writers (Elixir derive + Rust derive_row reads best_duct_freq_ghz from
CellValues), persisted to ScalarFile, and shipped to the JS hook via
the existing binary cell pack. Also cleans up six pre-existing
length/1 credo warnings in unrelated test files.
2026-05-15 19:51:24 -05:00

65 lines
1.9 KiB
Elixir

defmodule MicrowavepropWeb.Api.V1.ProfileControllerTest do
use MicrowavepropWeb.ConnCase, async: true
alias Microwaveprop.AccountsFixtures
alias Microwaveprop.Beacons
alias Microwaveprop.Radio
alias MicrowavepropWeb.Api.RateLimiter
setup do
RateLimiter.reset()
:ok
end
describe "GET /api/v1/profiles/:callsign" do
test "returns the profile + contacts + approved beacons", %{conn: conn} do
user = AccountsFixtures.user_fixture(%{callsign: "W5TEST"})
{:ok, _contact} =
Radio.create_contact(
%{
"station1" => "W5TEST",
"station2" => "K5OK",
"qso_timestamp" => "2026-01-02T00:00:00Z",
"band" => "10000",
"grid1" => "EM12",
"grid2" => "EM13",
"mode" => "CW",
"submitter_email" => "fixture@example.com"
},
user.id
)
{:ok, beacon} =
Beacons.create_beacon(user, %{
frequency_mhz: 10_368.1,
callsign: "W5HN",
lat: 32.897,
lon: -97.038,
power_mw: 1000.0,
height_ft: 100,
keying: "on_off"
})
{:ok, _approved} = Beacons.approve_beacon(beacon)
body = conn |> get(~p"/api/v1/profiles/W5TEST") |> json_response(200)
assert body["user"]["callsign"] == "W5TEST"
refute Map.has_key?(body["user"], "email")
assert body["contacts"] != []
assert body["beacons"] != []
end
test "case-insensitive lookup", %{conn: conn} do
_user = AccountsFixtures.user_fixture(%{callsign: "W5LOWER"})
body = conn |> get(~p"/api/v1/profiles/w5lower") |> json_response(200)
assert body["user"]["callsign"] == "W5LOWER"
end
test "404 when callsign is not registered", %{conn: conn} do
conn = get(conn, ~p"/api/v1/profiles/Z9NOPE")
assert json_response(conn, 404)
end
end
end