from pathlib import Path


def test_installation_form_uses_backend_options_and_safe_hardware_states():
    template = (Path(__file__).parents[1] / "app" / "templates" / "add_customer.html").read_text()
    assert 'name="package_id"' in template
    assert "Pilih paket" in template
    assert "leaflet@1.9.4" in template
    assert "openstreetmap.org" in template
    assert 'name="ont_management_mode"' in template
    assert 'name="management_pppoe_username"' in template
    assert 'name="service_modes_json"' in template
    assert 'value="pppoe"' in template
    assert '1Play PPPoE' in template
    assert 'value="hotspot"' not in template
    assert 'value="iptv"' not in template
    assert "Form PSB ini khusus pelanggan bulanan PPPoE" in template
    for key in ("ont_sn", "onu_id", "olt_port", "ont_brand"):
        assert key in template
    assert "Belum tersedia" in template
    assert 'id="auto-sn-pon-port"' in template
    assert 'id="auto-sn-results"' in template
    assert '/api/olt-devices/${encodeURIComponent(oltId)}/auto-sn' in template


def test_installation_route_is_registered():
    import sys
    sys.path.insert(0, str(Path(__file__).parents[1]))
    from main import app

    assert "/add-customer" in app.openapi()["paths"]
