9f4295b77e
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
25 lines
1.2 KiB
Python
25 lines
1.2 KiB
Python
"""Deployed topology (launch-app SPEC §2): nginx proxies EVERYTHING to the backend, so
|
|
the backend must serve the built SPA (frontend/dist) itself. Dev is unaffected — Vite
|
|
serves the frontend and the default dist dir simply doesn't exist."""
|
|
from fastapi.testclient import TestClient
|
|
|
|
from app.main import create_app
|
|
|
|
|
|
def test_spa_served_when_dist_present(fresh_db_url, tmp_path):
|
|
(tmp_path / "index.html").write_text("<!doctype html><title>ecomm spa</title>")
|
|
with TestClient(create_app(database_url=fresh_db_url, static_dir=tmp_path)) as client:
|
|
root = client.get("/")
|
|
assert root.status_code == 200
|
|
assert "ecomm spa" in root.text
|
|
# API + health still win over the mount
|
|
assert client.get("/healthz").json()["status"] == "ok"
|
|
assert client.get("/api/auth/me").status_code == 401
|
|
|
|
|
|
def test_no_mount_when_dist_absent(fresh_db_url, tmp_path):
|
|
# An empty/missing dist (the dev case) must not 500 the app — / just 404s.
|
|
with TestClient(create_app(database_url=fresh_db_url, static_dir=tmp_path / "nope")) as client:
|
|
assert client.get("/").status_code == 404
|
|
assert client.get("/healthz").json()["status"] == "ok"
|