July 3rd - Update landing page

This commit is contained in:
2026-07-03 15:38:31 -04:00
parent 4c275fc0e5
commit 4b6401be43
12 changed files with 414 additions and 19 deletions
+66
View File
@@ -0,0 +1,66 @@
"""
Tests for the public apex landing page (app/routes/landing.py) and the
apex-host routing in the tenant middleware (app/tenancy/middleware.py).
Two invariants:
1. GET /welcome always renders the landing page (tenant-exempt, any host).
2. When multi-tenancy is on, the apex host (TENANT_BASE_DOMAIN + www.) serves
the landing page at '/' and bounces any other non-exempt path back to '/',
while /signup stays reachable. Tenant subdomains are unaffected (still 404
for unknown hosts, dashboard still owns '/').
"""
import pytest
def test_welcome_renders_landing(app):
"""/welcome is public and renders the marketing page (MT inert here)."""
client = app.test_client()
r = client.get('/welcome')
assert r.status_code == 200
assert b'Quality control for janitorial contracts' in r.data
assert b'/signup' in r.data # funnels to existing signup
assert b'Simple plans that grow with you' in r.data # pricing section
@pytest.fixture
def mt_app(app):
"""The shared app with multi-tenancy temporarily enabled (apex = jqc.app).
Reuses the single app instance — create_app cannot be called twice in one
process because the /api/v1 parent blueprint is a module-level singleton.
The middleware reads current_app.config per request, so toggling config here
is sufficient. Config is restored afterwards so other tests are unaffected.
"""
prev_mt = app.config.get('MULTI_TENANT_ENABLED')
prev_base = app.config.get('TENANT_BASE_DOMAIN')
app.config.update(MULTI_TENANT_ENABLED=True, TENANT_BASE_DOMAIN='jqc.app')
yield app
app.config.update(MULTI_TENANT_ENABLED=prev_mt, TENANT_BASE_DOMAIN=prev_base)
def test_apex_root_serves_landing(mt_app):
client = mt_app.test_client()
r = client.get('/', headers={'Host': 'jqc.app'})
assert r.status_code == 200
assert b'Quality control for janitorial contracts' in r.data
def test_www_apex_serves_landing(mt_app):
client = mt_app.test_client()
r = client.get('/', headers={'Host': 'www.jqc.app'})
assert r.status_code == 200
assert b'Quality control for janitorial contracts' in r.data
def test_apex_other_path_redirects_to_root(mt_app):
client = mt_app.test_client()
r = client.get('/issues', headers={'Host': 'jqc.app'})
assert r.status_code == 302
assert r.headers['Location'] == '/'
def test_apex_signup_is_reachable(mt_app):
client = mt_app.test_client()
r = client.get('/signup', headers={'Host': 'jqc.app'})
assert r.status_code == 200