phase: 92_theme_save_and_coverage
Build and Push Containers / build-and-push-app (push) Successful in 1m47s
Build and Push Containers / build-and-push-db (push) Successful in 11s

**Phase 92 final verification pass — all green.** This pass re-verified the completed tasks (all 5 task files already in `complete/`) against every completion criterion; no defects found, nothing to fix.

- Verified: 9th identity var `grid_line` end-to-end (migration `0015` at head, model/`theming.py`/schemas/API, 422 + built-in→NULL tests present); `styles.css` zero hardcoded literals outside `:root` + derived `--brand-*` vars; 9th picker in theme form; wordmark themed; `theme.js` save/reset/re-show/mount live-sync; dedicated E2E suite + phase-91 suite updated.
- `uv run pytest --cov=app --cov-report=term-missing` → **1845 passed, exit 0, TOTAL 99%** (>90%)
- `uv run ruff check .` → clean; `uv run pyright` → 0 errors, 0 warnings
- `uv run pytest tests/e2e/test_theme_save_and_coverage.py -v --no-cov` → **3 passed** (save-live, reset-live, whole-site)
- `uv run pytest tests/e2e/test_admin_theme_tab.py -v --no-cov` → **5 passed**
- Criteria: (1) Save/Reset repaint open page, no nav, SPA-nav survives, pre-paint intact ✅; (2) both `rg` gates green (only `:root` + documented `#fff` Stop label; zero SVG hex attrs), grid/selection/hovers/wash/wordmark E2E-proven ✅; (3) no-op contract live-checked: row-less `/` = no tag + exact A1 CSP, grid-only row = 9-var tag in `COLOR_FIELDS` order + sha256 CSP, with-row ≡ row-less bytes ✅; (4) full suite/coverage/lint/both E2E ✅; (5) commit left to the harness per instructions.
- Deviations (previously made, probe-verified, kept): live repaint uses CSSOM `<html>` overrides because Chromium blocks `<style>` textContent mutations under the locked sha256-only CSP (tag text still mirrors the next load; `<html>` style exact-saved after Save, empty after Reset); wordmark themed via 3 `.brand-mark` CSS rules instead of inline styles (task 03's inline attrs were CSP-blocked — fixed during task 04).
- Next pending phase: none — `todo/` contains only `92_theme_save_and_coverage`.
This commit is contained in:
2026-09-10 00:23:08 -04:00
parent d22d260b8b
commit df91c6316c
49 changed files with 2282 additions and 189 deletions
+33 -1
View File
@@ -27,12 +27,13 @@ from collections.abc import Iterator
import pytest
from fastapi.testclient import TestClient
from sqlalchemy import text
from sqlalchemy import select, text
from sqlalchemy.orm import Session
from app.config import get_settings
from app.core import theming
from app.main import app as fastapi_app
from app.models import UiSettings
from tests.conftest import ADMIN_PASSWORD
@@ -120,6 +121,37 @@ def test_admin_get_and_put_200(client: TestClient, db: Session) -> None:
assert r.json()["bg"] == theming.BUILTIN_COLORS["bg"]
def test_admin_grid_line_validation_and_normalization(
client: TestClient, db: Session
) -> None:
"""Phase 92 (task 01): the 9th identity color against the LIVE API —
a bad hex is a 422 naming ``grid_line`` (same fixed detail as the
other 8); the built-in value stores NULL (the response still
reports the built-in — the no-op normalization); a non-built-in
value is stored and reported back. The admin gate itself is pinned
unchanged by the tests above (router-wide ``require_admin``)."""
client.post("/api/login", json={"password": ADMIN_PASSWORD})
r = client.put("/api/ui-settings", json={"grid_line": "nope"})
assert r.status_code == 422, r.text
assert r.json()["detail"] == "grid_line must be a #rrggbb hex color"
r = client.put("/api/ui-settings", json={"grid_line": "#4a2626"})
assert r.status_code == 200, r.text
assert r.json()["grid_line"] == theming.BUILTIN_COLORS["grid_line"]
row = db.execute(select(UiSettings).where(UiSettings.id == 1)).scalars().first()
assert row is not None, "the PUT upsert creates the id-1 row"
assert row.grid_line is None # built-in → NULL normalization
r = client.put("/api/ui-settings", json={"grid_line": "#123123"})
assert r.status_code == 200, r.text
assert r.json()["grid_line"] == "#123123"
r = client.get("/api/ui-settings")
assert r.status_code == 200
assert r.json()["grid_line"] == "#123123" # the stored value reads back
assert len(r.json()) == 12 # the 12-key response shape (9 colors + 3 strings)
def _config_keys() -> set[str]:
"""The /api/config key set after task 03: the five phase-39/59/62
keys — the retired CSS-file theming's ``theme`` key is gone."""