diff --git a/tests/integration/middleware/conftest.py b/tests/integration/middleware/conftest.py index 20373424..19a16f0e 100644 --- a/tests/integration/middleware/conftest.py +++ b/tests/integration/middleware/conftest.py @@ -65,13 +65,20 @@ def client(db): # Patch get_db in middleware modules - they have their own imports # The middleware calls: db_gen = get_db(); db = next(db_gen) # Also patch settings.platform_domain so subdomain detection works with test hosts + # Also bypass StorefrontAccessMiddleware subscription check for test routes — + # these tests verify store context detection, not subscription access. + from middleware.storefront_access import SKIP_PATH_PREFIXES + + test_skip_prefixes = SKIP_PATH_PREFIXES + ("/middleware-test/",) + with patch("middleware.platform_context.get_db", override_get_db): with patch("middleware.store_context.get_db", override_get_db): with patch("middleware.theme_context.get_db", override_get_db): with patch("middleware.store_context.settings") as mock_settings: - mock_settings.platform_domain = "platform.com" - client = TestClient(app) - yield client + with patch("middleware.storefront_access.SKIP_PATH_PREFIXES", test_skip_prefixes): + mock_settings.platform_domain = "platform.com" + client = TestClient(app) + yield client # Clean up if get_db in app.dependency_overrides: