"""Compression contract for the HTTP layer.
Session history is ~1 MB of JSON and the built SPA bundle is ~1.5 MB; without
gzip both crossed the wire at full size on every session open (the measured
payloads shrink 5.1× and 3.2× respectively).
"""
from starlette.middleware.gzip import GZipMiddleware
def test_gzip_middleware_is_installed():
from navi.main import app
installed = [m for m in app.user_middleware if m.cls is GZipMiddleware]
assert installed, "GZipMiddleware is not registered on the app"
# Small payloads (health, tiny JSON) stay uncompressed; anything above the
# threshold — history pages, the SPA bundle — is compressed.
assert installed[0].kwargs.get("minimum_size") == 1024