phase: 92_theme_save_and_coverage
**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:
@@ -36,7 +36,8 @@ from app.models import UiSettings
|
||||
ALL_NULL_BODY: dict[str, str | None] = {
|
||||
"app_name": None, "input_placeholder": None, "footer_text": None,
|
||||
"bg": None, "surface": None, "ink": None, "ink_soft": None,
|
||||
"line": None, "brand": None, "brand_soft": None, "brand_ink": None,
|
||||
"line": None, "grid_line": None, "brand": None, "brand_soft": None,
|
||||
"brand_ink": None,
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +80,7 @@ def test_put_too_long_string_422_names_the_field(
|
||||
|
||||
|
||||
def test_put_bad_hex_422_names_the_field(admin_client: TestClient) -> None:
|
||||
"""Each of the 8 colors: anything not ``^#[0-9a-fA-F]{6}$`` is a 422
|
||||
"""Each of the 9 colors: anything not ``^#[0-9a-fA-F]{6}$`` is a 422
|
||||
naming that field — 3-digit shorthand, 8 hex digits, a bare hex
|
||||
without ``#``, a named color, and the empty string (the color clear
|
||||
operation is ``null``, not ``""``)."""
|
||||
@@ -88,6 +89,12 @@ def test_put_bad_hex_422_names_the_field(admin_client: TestClient) -> None:
|
||||
r = admin_client.put("/api/ui-settings", json={field: bad})
|
||||
assert r.status_code == 422, (field, bad, r.text)
|
||||
assert r.json()["detail"] == f"{field} must be a #rrggbb hex color"
|
||||
# Phase 92 (task 01): the 9th identity color names its 422 the same
|
||||
# fixed way as the other 8 (the loop above already covers it via
|
||||
# COLOR_FIELDS; the explicit case pins the field name in the detail).
|
||||
r = admin_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"
|
||||
|
||||
|
||||
def test_put_lowercases_colors_on_store(
|
||||
@@ -127,6 +134,30 @@ def test_put_built_in_color_is_stored_as_null(
|
||||
assert getattr(row, field) is None, f"{field} must be stored as NULL"
|
||||
|
||||
|
||||
def test_put_grid_line_built_in_is_stored_as_null(
|
||||
admin_client: TestClient, db: Session
|
||||
) -> None:
|
||||
"""Phase 92 (task 01): the 9th identity color gets the same
|
||||
owner-locked normalization as the other 8 — PUTting the built-in
|
||||
grid hex stores NULL (the response still reports the built-in, and
|
||||
the row's grid column stays empty); a NON-built-in value is stored
|
||||
as-is (lowercased)."""
|
||||
r = admin_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 = _row(db)
|
||||
assert row is not None
|
||||
assert row.grid_line is None # built-in → NULL
|
||||
|
||||
r = admin_client.put("/api/ui-settings", json={"grid_line": "#123123"})
|
||||
assert r.status_code == 200, r.text
|
||||
assert r.json()["grid_line"] == "#123123"
|
||||
db.expire_all() # drop the test session's pre-second-PUT view (house pattern)
|
||||
row = _row(db)
|
||||
assert row is not None
|
||||
assert row.grid_line == "#123123" # non-built-in is stored as-is
|
||||
|
||||
|
||||
def test_put_empty_string_is_the_clear_operation(
|
||||
admin_client: TestClient, db: Session
|
||||
) -> None:
|
||||
@@ -147,7 +178,7 @@ def test_put_empty_string_is_the_clear_operation(
|
||||
def test_get_effective_merge_partial_row(admin_client: TestClient, db: Session) -> None:
|
||||
"""GET reports the DB values over the defaults, column by column: a
|
||||
row with ONLY ``bg`` set (hand-inserted) reports that color plus the
|
||||
built-ins and the env strings — all 11 keys, no nulls."""
|
||||
built-ins and the env strings — all 12 keys, no nulls."""
|
||||
db.add(UiSettings(id=1, bg="#123456"))
|
||||
db.commit()
|
||||
r = admin_client.get("/api/ui-settings")
|
||||
|
||||
Reference in New Issue
Block a user