58 lines
2.2 KiB
Python
58 lines
2.2 KiB
Python
|
|
"""Aircraft popup enrichment + emergency/MIL layer contract (static HTML)."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
ROOT = Path(__file__).resolve().parent.parent
|
||
|
|
HTML = (ROOT / "app/static/index.html").read_text()
|
||
|
|
|
||
|
|
|
||
|
|
def _fn(name: str, nxt: str) -> str:
|
||
|
|
return HTML.split(f"function {name}", 1)[1].split(f"function {nxt}", 1)[0]
|
||
|
|
|
||
|
|
|
||
|
|
def test_popup_has_required_adsb_fields_and_photo():
|
||
|
|
js = _fn("pointPopup", "loadPlanePhoto")
|
||
|
|
for field in ("callsign", "hex", "registration", "type", "alt", "gs", "squawk"):
|
||
|
|
assert f"add('{field}'" in js
|
||
|
|
assert "class=\"ps-photo\"" in js or "class='ps-photo'" in js
|
||
|
|
assert "wikipedia" not in js.lower()
|
||
|
|
assert "ceo" not in js.lower()
|
||
|
|
|
||
|
|
|
||
|
|
def test_emergency_badge_and_squawk_codes():
|
||
|
|
assert "role-badge emergency" in HTML
|
||
|
|
assert "hdg-emerg" in HTML
|
||
|
|
assert "EMERG_SQUAWK" in HTML
|
||
|
|
assert "['7700', '7600', '7500']" in HTML
|
||
|
|
emerg = HTML.split("function acIsEmergency", 1)[1].split("function acVisible", 1)[0]
|
||
|
|
assert "EMERG_SQUAWK.has(sq)" in emerg
|
||
|
|
color = HTML.split("function acColor", 1)[1].split("function connectLiveWs", 1)[0]
|
||
|
|
assert "acIsEmergency(p)" in color
|
||
|
|
assert "#ff5d5d" in color
|
||
|
|
|
||
|
|
|
||
|
|
def test_mil_toggle_hidden_until_role_flag_and_never_hits_adsb_lol():
|
||
|
|
assert 'id="lp-ac-mil-row"' in HTML
|
||
|
|
assert 'id="lp-ac-mil-on"' in HTML
|
||
|
|
row = HTML.split('id="lp-ac-mil-row"', 1)[1].split(">", 1)[0]
|
||
|
|
assert "hidden" in row
|
||
|
|
on = HTML.split('id="lp-ac-mil-on"', 1)[1].split(">", 1)[0]
|
||
|
|
assert "checked" not in on
|
||
|
|
load = HTML.split("async function loadAircraft", 1)[1].split("async function toggleTrains", 1)[0]
|
||
|
|
assert "/api/aircraft?bbox=" in load
|
||
|
|
assert "api.adsb.lol" not in load
|
||
|
|
assert "noteMilSupport" in load
|
||
|
|
assert "acMilOn" in load
|
||
|
|
note = HTML.split("function noteMilSupport", 1)[1].split("function acColor", 1)[0]
|
||
|
|
assert "extra.role" in note
|
||
|
|
assert "lp-ac-mil-row" in note
|
||
|
|
assert "hidden = false" in note
|
||
|
|
|
||
|
|
|
||
|
|
def test_planespotters_lazy_photo_still_wired():
|
||
|
|
assert "function loadPlanePhoto" in HTML
|
||
|
|
assert "/api/aircraft/photo?" in HTML
|
||
|
|
assert "map.on('popupopen', (e) => { loadPlanePhoto(e.popup); });" in HTML
|