fix: UX deep dive — 28 fixes across authoring, navigation, consistency, and cleanup #86

Merged
chihlasm merged 11 commits from feat/ux-deep-dive into main 2026-02-20 03:10:47 +00:00
Showing only changes of commit efb3ec13b4 - Show all commits

View File

@@ -27,8 +27,20 @@ def _configure_seed_module(mod: object, api_url: str, email: str, password: str)
mod.ADMIN_PASSWORD = password # type: ignore[attr-defined]
async def _seed_users_directly() -> None:
"""Seed test users directly via DB if they don't exist yet."""
try:
from scripts.seed_test_users import main as seed_users
logger.info("[seed] Seeding test users directly via DB...")
await seed_users()
logger.info("[seed] Test users seeded!")
except Exception as e:
logger.warning(f"[seed] User seeding failed: {e}")
raise
async def _seed_trees_background() -> None:
"""Background task: seed all flows via HTTP API after server is ready."""
"""Background task: seed test users + all flows after server is ready."""
await asyncio.sleep(5) # Wait for server to be fully ready
port = os.environ.get("PORT", "8000")
api_url = f"http://127.0.0.1:{port}/api/v1"
@@ -37,12 +49,17 @@ async def _seed_trees_background() -> None:
try:
import httpx
# Login to verify admin user exists
# Try to login — if it fails, seed users first
async with httpx.AsyncClient(base_url=api_url, timeout=30) as client:
login_resp = await client.post("/auth/login/json", json={"email": email, "password": password})
if login_resp.status_code != 200:
logger.warning("[seed] Could not login as admin — skipping flow seeding")
return
logger.warning("[seed] Admin login failed — seeding users first")
await _seed_users_directly()
# Retry login after seeding users
login_resp = await client.post("/auth/login/json", json={"email": email, "password": password})
if login_resp.status_code != 200:
logger.error(f"[seed] Admin login still failing after user seed (status={login_resp.status_code}) — aborting")
return
token = login_resp.json()["access_token"]
# Check if trees already exist