Fix input preview hash -> cid key mismatch

Template uses inp.cid and input.cid but router created previews with
'hash' key. Fixed both input_previews and run_inputs to use 'cid'.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-12 12:27:05 +00:00
parent 2cc7d88d2e
commit 991db29e27
2 changed files with 29 additions and 2 deletions

View File

@@ -36,6 +36,33 @@ class TestCacheNotFoundTemplate:
"Route should pass cid=cid to not_found.html template"
class TestInputPreviewsDataStructure:
"""Tests for input_previews dict keys matching template expectations."""
def test_run_card_template_expects_inp_cid(self) -> None:
"""Run card template uses inp.cid for input previews."""
path = Path('/home/giles/art/art-celery/app/templates/runs/_run_card.html')
content = path.read_text()
assert 'inp.cid' in content, \
"Run card template should use inp.cid for input previews"
def test_input_previews_use_cid_key(self) -> None:
"""
Regression test: input_previews must use 'cid' key not 'hash'.
Bug: Router created input_previews with 'hash' key but template expected 'cid'.
"""
path = Path('/home/giles/art/art-celery/app/routers/runs.py')
content = path.read_text()
# Should have: "cid": input_hash, not "hash": input_hash
assert '"cid": input_hash' in content, \
"input_previews should use 'cid' key"
assert '"hash": input_hash' not in content, \
"input_previews should not use 'hash' key (template expects 'cid')"
class TestArtifactDataStructure:
"""Tests for artifact dict keys matching template expectations."""