diff --git a/tests/integration/api/v1/store/test_dashboard.py b/tests/integration/api/v1/store/test_dashboard.py index 72b281ab..34554d77 100644 --- a/tests/integration/api/v1/store/test_dashboard.py +++ b/tests/integration/api/v1/store/test_dashboard.py @@ -11,10 +11,36 @@ Tests cover: import pytest +from app.modules.tenancy.models import Platform + + +@pytest.fixture +def _ensure_main_platform(db): + """Ensure a 'main' platform exists for the PlatformContextMiddleware. + + The TestClient uses 'testserver' as Host, which the middleware treats as + localhost and resolves to the 'main' platform via path_prefix lookup. + """ + platform = db.query(Platform).filter(Platform.code == "main").first() + if not platform: + platform = Platform( + code="main", + name="Main Platform", + path_prefix="main", + is_active=True, + is_public=True, + default_language="en", + supported_languages=["en"], + ) + db.add(platform) + db.commit() + return platform + @pytest.mark.integration @pytest.mark.api @pytest.mark.store +@pytest.mark.usefixtures("_ensure_main_platform") class TestStoreDashboardAPI: """Test store dashboard stats endpoint"""