Files
brain-of-reese/tests/e2e/test_stale_ui_copy.py
T
ducoterra 9188be259b
Build and Push Containers / build-and-push-app (push) Successful in 1m56s
Build and Push Containers / build-and-push-db (push) Successful in 11s
phase: 93_theme_semantic_completion
All verification is complete. Final report:

**Phase 93 — Theme semantic completion: FINAL VERIFICATION PASS — ALL GREEN**

- Verified full implementation in tree: migration `0016` (8 nullable semantic columns, applied at head), 17-var `BUILTIN_COLORS`/`COLOR_FIELDS`/`effective_settings`, API validation, `#view-theme` State-colors fieldset (17 pickers), `theme.js` FIELDS/PAIRS (5→8), `.page-head` surface panel (6 shell views + doc-edit + shared.html; login card / document sticky header audited as already-surfaced), mock_llm `content: None` fix
- Fixed 2 pre-existing defects (both fail identically on baseline `d4f38ad`, proven via worktree A/B): `test_nav_rename_sources` — expected nav tail missing the phase-91 "Theme" link; `test_stale_ui_copy` — now truncates `saved_chats` before/after (house `test_suggestion_chips` pattern) so the seed-chip contract is deterministic on the shared dev DB (owner's 22 saved chats triggered phase-80 last-3-questions)
- Tests: `uv run pytest --cov=app --cov-report=term-missing` → **1868 passed, app/ 99%** (>90% ✓); `uv run ruff check .` → clean; `uv run pyright` → **0 errors**
- E2E: dedicated `uv run pytest tests/e2e/test_theme_semantic_completion.py -v --no-cov` → **8/8 in isolation** (all-gray 17-color theme: zero residual color on saved-result/Stale/Revoked/Local/tool-call elements, text labels intact, gray heads non-transparent, pre-paint tag, Reset → byte-identical no-tag); 15 theme/header/nav/responsive suites green in isolation; full 85-file combined run: only the 2 fixed pre-existing failures + 1 combined-run artifact (`test_sync_upload_progress`, green in isolation)
- Completion criteria: (1) monochrome E2E ✓ (2) default byte-identical, no `#bor-theme` tag ✓ (3) all page heads on solid surface ✓ (4) suite/coverage/lint/E2E green ✓ (5) phases 01–92 no behavior change ✓ (6) commit left to harness per protocol
- Notable: cleaned stray uvicorn leftovers from prior implementation pass (owner's `--reload` dev server untouched); no deviations from the phase design
- Next pending phase: `94_ls_tree_drilldown`
2026-09-10 16:43:08 -04:00

153 lines
6.3 KiB
Python

"""Phase 61 E2E (Playwright): the retired homelab-era copy is gone — the
visitor SEES the locked neutral copy on the shared default server.
Story: n/a (TODO-derived — TODO.md L4 "Clean up the UI, there's text
that references old features…"). Run in isolation (DB must be up:
``podman compose up -d db``):
uv run pytest tests/e2e/test_stale_ui_copy.py -v --no-cov
The shared conftest server boots with the default env — and the code
defaults are exactly this phase's locked copy (A1/A2; the conftest
forces ``BOR_SUGGESTIONS`` from the ``Settings`` field so an operator's
local ``.env`` cannot leak corpus-specific chips). Every assertion is a
settled-state check: static HTML + one ``GET /api/suggestions`` fetch;
Playwright's ``expect`` retries ride out the chip rendering.
``saved_chats`` reset: the chips the chat page renders are the phase-80
contract (the last 3 questions across ALL saved chats; the locked seed
list is the FRESH-deployment fallback). An autouse fixture truncates
``saved_chats`` before and after every test so the suite is deterministic
on the shared dev DB (the ``test_suggestion_chips.py`` /
``test_history_page_width.py`` precedent — other suites leave saved
chats, incl. the owner's, on the shared DB).
Test → lock mapping (Playwright Mapping Rule):
1. ``test_chat_page_placeholder_meta_footer_are_the_locked_copy``
2. ``test_chat_page_shows_no_homelab_or_deployment_text``
3. ``test_chat_page_suggestion_chips_are_the_locked_list``
4. ``test_sources_page_sub_describes_the_current_source_model``
5. ``test_git_sources_example_url_is_neutral``
"""
from __future__ import annotations
from collections.abc import Iterator
import pytest
from playwright.sync_api import Page, expect
from sqlalchemy import text
from app.db import SessionLocal
from e2e.auth_helpers import login
# The locked replacement copy (owner-locked A1 / A2 / A3 — same literals
# as tests/unit/test_stale_ui_copy.py; the unit pins guard the files,
# this suite guards what the visitor actually sees).
META = "Ask anything about your indexed documents — every answer cites the exact doc."
PLACEHOLDER = "Ask me anything…"
FOOTER = "Powered by self-hosted models"
GIT_EXAMPLE = "https://github.com/you/your-repo.git"
CHIPS = [
"What documents are in the knowledge base?",
"Which source does each answer come from?",
"How do I add a new source?",
"Summarize the most recent document.",
]
@pytest.fixture(autouse=True)
def clean_chats(db_ready: None) -> Iterator[None]:
"""The seed-list chip contract reads ``saved_chats`` (phase 80: the
chips are the last 3 questions asked; the locked list is the
zero-saved-question fallback). Truncate before AND after every test
so each test sees a fresh deployment (the
``test_suggestion_chips.py`` pattern — the shared dev DB may hold
the owner's saved chats; the suites that assert on the chips own
the table state, house precedent)."""
with SessionLocal() as db:
db.execute(text("TRUNCATE saved_chats"))
db.commit()
yield
with SessionLocal() as db:
db.execute(text("TRUNCATE saved_chats"))
db.commit()
def test_chat_page_placeholder_meta_footer_are_the_locked_copy(
page: Page, app_url: str, db_ready: None
) -> None:
"""The composer placeholder, the <meta description> content and the
footer span all read the locked (A1) copy — read from the DOM a
visitor gets."""
page.goto(f"{app_url}/")
expect(page.locator("#message-input")).to_have_attribute(
"placeholder", PLACEHOLDER
)
meta = page.eval_on_selector('meta[name="description"]', "el => el.content")
assert meta == META, "the rendered meta description must be the locked copy"
expect(page.locator(".footer-text").first).to_have_text(FOOTER)
def test_chat_page_shows_no_homelab_or_deployment_text(
page: Page, app_url: str, db_ready: None
) -> None:
"""The entire rendered chat page (nav, empty state, composer, footer)
shows no homelab-era text — the empty-state sub AND the four
rendered suggestion chips are covered by this body scan (case-
insensitive; a fresh page context has no saved chats, so the empty
state is what renders)."""
login(page, app_url, next="/")
expect(page.locator("#suggestions .suggestion-chip")).to_have_count(len(CHIPS))
body = page.evaluate("() => document.body.innerText.toLowerCase()")
assert "homelab" not in body, f"homelab-era text rendered on the chat page: {body!r}"
assert "deployment" not in body, (
f"homelab-era text rendered on the chat page: {body!r}"
)
def test_chat_page_suggestion_chips_are_the_locked_list(
page: Page, app_url: str, db_ready: None
) -> None:
"""The four rendered empty-state chips (from ``GET
/api/suggestions``, the code default) are the locked (A2) list, in
order."""
login(page, app_url, next="/")
chips = page.locator("#suggestions .suggestion-chip")
expect(chips).to_have_count(len(CHIPS))
for i, chip in enumerate(CHIPS):
expect(chips.nth(i)).to_have_text(chip)
def test_sources_page_sub_describes_the_current_source_model(
page: Page, app_url: str, db_ready: None
) -> None:
"""The KB page-sub (the string the TODO cited by name) no longer
names ~/Homelab or ~/Deployments and describes the current source
model. The page is anonymously viewable — the catalog gate hides
the table, not the page-head."""
page.goto(f"{app_url}/sources.html")
# Phase 76 (task 02): the shell carries the hidden tuning view's
# .page-sub earlier in the DOM — scope to the RAG view.
sub = page.locator("#view-rag .page-sub")
expect(sub).to_be_visible()
text = sub.inner_text().lower()
assert "homelab" not in text, f"retired copy in the page-sub: {text!r}"
assert "deployments" not in text, f"retired copy in the page-sub: {text!r}"
assert "configured sources" in text, (
f"the page-sub must name the current source model: {text!r}"
)
def test_git_sources_example_url_is_neutral(
page: Page, app_url: str, db_ready: None
) -> None:
"""The repo-URL form example (A3) is the neutral your-repo.git —
read from the DOM; the element exists even while
``#git-sources-content`` is hidden for an anonymous visitor (no
sign-in needed)."""
page.goto(f"{app_url}/git-sources.html")
expect(page.locator("#git-source-url")).to_have_attribute(
"placeholder", GIT_EXAMPLE
)