refactor: rename platform_domain → main_domain to avoid confusion with platform.domain
Some checks failed
Some checks failed
The setting `settings.platform_domain` (the global/main domain like "wizard.lu") was easily confused with `platform.domain` (per-platform domain like "rewardflow.lu"). Renamed to `settings.main_domain` / `MAIN_DOMAIN` env var across the entire codebase. Also updated docs to reflect the refactored store detection logic with `is_platform_domain` / `is_subdomain_of_platform` guards. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,7 @@ def client(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"
|
||||
mock_settings.main_domain = "platform.com"
|
||||
client = TestClient(app)
|
||||
yield client
|
||||
```
|
||||
|
||||
@@ -49,7 +49,7 @@ def client(db):
|
||||
|
||||
This patches:
|
||||
1. get_db in both middleware modules to use the test database
|
||||
2. settings.platform_domain in store_context to use 'platform.com' for testing
|
||||
2. settings.main_domain in store_context to use 'platform.com' for testing
|
||||
|
||||
This ensures middleware can see test fixtures and detect subdomains correctly.
|
||||
"""
|
||||
@@ -64,7 +64,7 @@ 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 patch settings.main_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
|
||||
@@ -76,7 +76,7 @@ def client(db):
|
||||
with patch("middleware.theme_context.get_db", override_get_db):
|
||||
with patch("middleware.store_context.settings") as mock_settings:
|
||||
with patch("middleware.storefront_access.SKIP_PATH_PREFIXES", test_skip_prefixes):
|
||||
mock_settings.platform_domain = "platform.com"
|
||||
mock_settings.main_domain = "platform.com"
|
||||
client = TestClient(app)
|
||||
yield client
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ async def test_inactive_store_detection(request: Request):
|
||||
|
||||
|
||||
@router.get("/platform-domain")
|
||||
async def test_platform_domain(request: Request):
|
||||
async def test_main_domain(request: Request):
|
||||
"""Test platform domain without subdomain."""
|
||||
store = getattr(request.state, "store", None)
|
||||
return {"store_detected": store is not None}
|
||||
|
||||
@@ -7,7 +7,7 @@ for all routing modes: subdomain, custom domain, and path-based.
|
||||
|
||||
Note: These tests require the middleware conftest.py which patches:
|
||||
1. get_db in middleware modules to use the test database session
|
||||
2. settings.platform_domain to use 'platform.com' for testing subdomain detection
|
||||
2. settings.main_domain to use 'platform.com' for testing subdomain detection
|
||||
"""
|
||||
|
||||
import pytest
|
||||
@@ -137,7 +137,7 @@ class TestStoreContextFlow:
|
||||
data = response.json()
|
||||
assert data["store_detected"] is False
|
||||
|
||||
def test_platform_domain_without_subdomain_no_store(self, client):
|
||||
def test_main_domain_without_subdomain_no_store(self, client):
|
||||
"""Test that platform domain without subdomain doesn't detect store."""
|
||||
response = client.get(
|
||||
"/middleware-test/platform-domain", headers={"host": "platform.com"}
|
||||
|
||||
Reference in New Issue
Block a user