"""Tests for the web_server component index page builder and validation."""
import logging
import pytest
from esphome.components.web_server import (
_final_validate_ap_only_hosted_ui,
build_index_html,
)
from esphome.const import (
CONF_AP,
CONF_CSS_URL,
CONF_JS_URL,
CONF_LOCAL,
CONF_NETWORKS,
CONF_SSID,
CONF_WIFI,
)
import esphome.final_validate as fv
JS_URL = "https://oi.esphome.io/v2/www.js"
def test_build_index_html_has_offline_hint() -> None:
"""A hidden hint is shown after a timeout unless www.js registered esp-app."""
html = build_index_html({CONF_JS_URL: JS_URL, CONF_CSS_URL: ""})
assert "" in html
assert "
The web interface is not loading." in html assert "local: true" in html assert "' in html assert "
" not in html def test_build_index_html_without_js_url() -> None: """No hosted script and no hint when js_url is empty.""" html = build_index_html({CONF_JS_URL: "", CONF_CSS_URL: ""}) assert "