Files that outlived the chats that held them, and a page that led with its footnotes
The second audit pass. Four things, and the first two were reported. The Prompts page put a screen of variables and a screen of preview above the editor, so the tabs began two screens down and switching one had to drag the whole page to be any use -- and on a short tab it could not drag far enough, leaving the panel stranded above a screenful of nothing. Editor first, reference after, bar sticky. Custom themes were three fixed slots: fifty-seven empty colour boxes on a fresh instance and no way to make a fourth theme. One block per theme plus a blank one, colours behind a disclosure. Both measured rather than argued about -- rendered through TestClient and driven under headless Chromium, where the tab bar moved 385->642px before and does not move now, and the themes page went from 5495px to 2820px. Asking where generated images go found the other two. Deleting a chat cascades to the attachment rows and leaves every file on disk; the helper written for exactly that was called from one place, and it was not the delete button, a schedule's chat, a helper's chat or deleting an account. Underneath it, `claim` bound message_id and never chat_id, so anything picked before a chat existed kept an empty chat_id forever -- which six readers filter on, so those files were also unnamed in the prompt, unopenable in the canvas, and invisible to the one caller the cleanup had. And folders nest now. The route has handled parent_id since folders existed, with a cycle guard and a depth cap the move path never applied; the sidebar has always drawn a tree. Nothing could ask for one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -232,6 +232,80 @@ def test_clearing_an_id_removes_the_theme(db, client, registered):
|
||||
assert "dusk" not in branding.snapshot().theme_ids
|
||||
|
||||
|
||||
def test_the_page_offers_one_blank_theme_and_no_more(db, client, registered):
|
||||
"""It rendered three blocks whether or not anybody had made a theme, so a
|
||||
fresh instance opened on fifty-seven empty colour boxes under three
|
||||
identical headings -- and the fourth theme was unreachable without editing
|
||||
the template. One block per theme plus a single blank one is the
|
||||
no-JavaScript way to say "add another"."""
|
||||
page = client.get("/admin/customization").text
|
||||
assert page.count('name="theme_0_id"') == 1
|
||||
assert 'name="theme_1_id"' not in page
|
||||
|
||||
_save_theme(client, theme_0_bg="#123456")
|
||||
page = client.get("/admin/customization").text
|
||||
# The saved one, and a fresh blank below it.
|
||||
assert 'name="theme_1_id"' in page
|
||||
assert 'name="theme_2_id"' not in page
|
||||
|
||||
|
||||
def test_a_fourth_theme_is_reachable(db, client, registered):
|
||||
"""Three was a template constant, and the page is what made it a limit."""
|
||||
data = {}
|
||||
for index, name in enumerate(("one", "two", "three", "four")):
|
||||
data[f"theme_{index}_id"] = name
|
||||
data[f"theme_{index}_base"] = "moria"
|
||||
client.post("/admin/customization/themes", data=data, follow_redirects=False)
|
||||
|
||||
ids = branding.snapshot().theme_ids
|
||||
assert {"one", "two", "three", "four"} <= set(ids)
|
||||
|
||||
|
||||
def test_the_page_stops_offering_at_the_cap(db, client, registered):
|
||||
from lembas.api.admin_branding import MAX_THEMES
|
||||
|
||||
data = {}
|
||||
for index in range(MAX_THEMES):
|
||||
data[f"theme_{index}_id"] = f"t{index}"
|
||||
data[f"theme_{index}_base"] = "moria"
|
||||
client.post("/admin/customization/themes", data=data, follow_redirects=False)
|
||||
|
||||
page = client.get("/admin/customization").text
|
||||
assert f'name="theme_{MAX_THEMES}_id"' not in page
|
||||
assert "which is the limit" in page
|
||||
|
||||
|
||||
def test_the_cap_is_enforced_on_save_as_well_as_offered(db, client, registered):
|
||||
"""The template's job is to stop offering; the route's is to stop accepting.
|
||||
A crafted POST is not the page."""
|
||||
from lembas.api.admin_branding import MAX_THEMES
|
||||
|
||||
data = {}
|
||||
for index in range(MAX_THEMES + 5):
|
||||
data[f"theme_{index}_id"] = f"t{index}"
|
||||
data[f"theme_{index}_base"] = "moria"
|
||||
client.post("/admin/customization/themes", data=data, follow_redirects=False)
|
||||
|
||||
custom = [t for t in branding.snapshot().themes if not t.built_in]
|
||||
assert len(custom) == MAX_THEMES
|
||||
|
||||
|
||||
def test_a_gap_in_the_middle_does_not_disturb_the_rest(db, client, registered):
|
||||
"""Clearing an id leaves a hole in the numbering, and nothing renumbers."""
|
||||
data = {}
|
||||
for index, name in enumerate(("one", "two", "three")):
|
||||
data[f"theme_{index}_id"] = name
|
||||
data[f"theme_{index}_base"] = "moria"
|
||||
client.post("/admin/customization/themes", data=data, follow_redirects=False)
|
||||
|
||||
data["theme_1_id"] = ""
|
||||
client.post("/admin/customization/themes", data=data, follow_redirects=False)
|
||||
|
||||
ids = set(branding.snapshot().theme_ids)
|
||||
assert "one" in ids and "three" in ids
|
||||
assert "two" not in ids
|
||||
|
||||
|
||||
# --- The stylesheet -------------------------------------------------------------
|
||||
def test_custom_css_is_served_as_a_stylesheet(db, client, registered):
|
||||
"""A route rather than an inline `<style>`, which is a security property
|
||||
|
||||
Reference in New Issue
Block a user