diff --git a/tests/dashboard/test_web_server.py b/tests/dashboard/test_web_server.py index 1ea9c73f32..cd02200d0b 100644 --- a/tests/dashboard/test_web_server.py +++ b/tests/dashboard/test_web_server.py @@ -53,6 +53,8 @@ async def dashboard() -> DashboardTestHelper: assert DASHBOARD.settings.on_ha_addon is True assert DASHBOARD.settings.using_auth is False task = asyncio.create_task(DASHBOARD.async_run()) + # Wait for initial device loading to complete + await DASHBOARD.entries.async_request_update_entries() client = AsyncHTTPClient() io_loop = IOLoop(make_current=False) yield DashboardTestHelper(io_loop, client, port) diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 0ac5676667..35586519e4 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -5,6 +5,7 @@ from __future__ import annotations import asyncio from collections.abc import AsyncGenerator, Generator from contextlib import AbstractAsyncContextManager, asynccontextmanager +import logging from pathlib import Path import platform import signal @@ -40,6 +41,29 @@ from .types import ( ) +@pytest.fixture(scope="module", autouse=True) +def enable_aioesphomeapi_debug_logging(): + """Enable debug logging for aioesphomeapi to help diagnose connection issues.""" + # Get the aioesphomeapi logger + logger = logging.getLogger("aioesphomeapi") + # Save the original level + original_level = logger.level + # Set to DEBUG level + logger.setLevel(logging.DEBUG) + # Also ensure we have a handler that outputs to console + if not logger.handlers: + handler = logging.StreamHandler() + handler.setLevel(logging.DEBUG) + formatter = logging.Formatter( + "%(asctime)s - %(name)s - %(levelname)s - %(message)s" + ) + handler.setFormatter(formatter) + logger.addHandler(handler) + yield + # Restore original level + logger.setLevel(original_level) + + @pytest.fixture def integration_test_dir() -> Generator[Path]: """Create a temporary directory for integration tests.""" diff --git a/tests/integration/const.py b/tests/integration/const.py index db5e8f5ae1..6876bbd443 100644 --- a/tests/integration/const.py +++ b/tests/integration/const.py @@ -2,7 +2,7 @@ # Network constants DEFAULT_API_PORT = 6053 -LOCALHOST = "localhost" +LOCALHOST = "127.0.0.1" # Timeout constants API_CONNECTION_TIMEOUT = 30.0 # seconds