Replaces the SVG schematic on /eme with a textured WebGL scene: NASA Blue Marble Earth, real-size Moon, outbound beam, dashed return ray to the sub-lunar point, and a red shading on the anti-moon hemisphere that marks who can't see the Moon (outside the bounce footprint). Three.js (~680 kB) now lives in its own chunk; esbuild --splitting keeps it out of the main bundle so it only loads when a user hits /eme. Main app.js drops from 1.6 MB to 922 kB. Also swaps the Elevation/SNR rows so the badge comes before the number.
74 lines
2.4 KiB
Elixir
74 lines
2.4 KiB
Elixir
defmodule MicrowavepropWeb.EmeLiveTest do
|
||
use MicrowavepropWeb.ConnCase, async: true
|
||
|
||
import Phoenix.LiveViewTest
|
||
|
||
describe "GET /eme" do
|
||
test "renders the empty form when no source is supplied", %{conn: conn} do
|
||
{:ok, _view, html} = live(conn, ~p"/eme")
|
||
|
||
assert html =~ "EME Calculator"
|
||
assert html =~ "Station (callsign, grid, or"
|
||
assert html =~ "Calculate"
|
||
# No aim readout yet.
|
||
refute html =~ "Antenna aim"
|
||
end
|
||
|
||
test "renders the live Moon aim + link budget when a grid source is provided", %{conn: conn} do
|
||
{:ok, _view, html} = live(conn, ~p"/eme?source=EM13&band=1296&tx_power_dbm=50&tx_gain_dbi=30")
|
||
|
||
assert html =~ "Antenna aim"
|
||
assert html =~ "Link budget"
|
||
assert html =~ "EM13"
|
||
assert html =~ "Azimuth"
|
||
assert html =~ "Elevation"
|
||
assert html =~ "Slant range"
|
||
# Path loss should be in the high 200s (dB) for 1296 MHz.
|
||
assert html =~ "dB"
|
||
end
|
||
|
||
test "submitting the form patches the URL with the supplied params", %{conn: conn} do
|
||
{:ok, view, _html} = live(conn, ~p"/eme")
|
||
|
||
view
|
||
|> form("form",
|
||
source: "EM13",
|
||
band: "432",
|
||
tx_power_dbm: "60",
|
||
tx_gain_dbi: "25",
|
||
bandwidth_hz: "100",
|
||
t_sys_k: "150"
|
||
)
|
||
|> render_submit()
|
||
|
||
# Flush any pending assign updates to catch redirects/patches.
|
||
html = render(view)
|
||
|
||
assert html =~ "EM13"
|
||
assert html =~ "Antenna aim"
|
||
end
|
||
|
||
test "coordinate pair 'lat,lon' resolves without touching the callsign API", %{conn: conn} do
|
||
{:ok, _view, html} = live(conn, ~p"/eme?source=32.9,-97.0&band=1296")
|
||
assert html =~ "Antenna aim"
|
||
assert html =~ "32.9"
|
||
assert html =~ "-97.0"
|
||
end
|
||
|
||
test "renders the Earth–Moon geometry WebGL hook with initial station geometry", %{conn: conn} do
|
||
{:ok, _view, html} = live(conn, ~p"/eme?source=EM13&band=1296")
|
||
|
||
assert html =~ "Earth–Moon geometry"
|
||
# The WebGL globe is rendered by a LiveView hook — assert the
|
||
# hook element + the initial station/moon data attributes that
|
||
# feed the Three.js scene on mount.
|
||
assert html =~ ~s(id="eme-globe")
|
||
assert html =~ ~s(phx-hook="EmeGlobe")
|
||
assert html =~ ~s(phx-update="ignore")
|
||
assert html =~ ~s(data-station-lat=")
|
||
assert html =~ ~s(data-station-lon=")
|
||
assert html =~ ~s(data-moon-az=")
|
||
assert html =~ ~s(data-moon-el=")
|
||
end
|
||
end
|
||
end
|