Files
odysseus/tests/test_chat_ttft_timer_static.py
T
64b457dc0a fix(tests): read static sources as UTF-8 in the static assertion tests (#6850)
On native Windows the default text encoding is the ANSI code page
(cp1252 on en/pt systems), so the module-level read_text() calls in
eight static tests fail at collection with UnicodeDecodeError on bytes
0x81/0x90 that appear in static/js/chat.js, chatRenderer.js, app.js,
index.html and src/visual_report.py. Pass encoding="utf-8" like the
other 700+ tests in the suite already do.

Found by running the suite natively on Windows 11 (Python 3.11).

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Alexandre Teixeira <general@alexandreteixeira.dev>
2026-11-01 01:26:11 +00:00

39 lines
1.6 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
CHAT = (ROOT / "static/js/chat.js").read_text(encoding="utf-8")
RENDERER = (ROOT / "static/js/chatRenderer.js").read_text(encoding="utf-8")
def test_processing_indicator_shows_live_ttft_timer():
assert "Processing request · ${elapsed.toFixed(1)}s" in CHAT
assert "_ttftDisplayTimer = setInterval(update, 100);" in CHAT
def test_ttft_stops_on_model_output_not_agent_prep_metadata():
assert "if (data && data !== '[DONE]') markFirstVisibleOutput();" not in CHAT
assert "typeof json.delta === 'string' && json.delta.length > 0" in CHAT
assert "json.type === 'final_response'" in CHAT
def test_measured_ttft_is_shown_in_message_stats():
assert "metrics.client_ttft = _clientTtftSeconds" in CHAT
assert "metrics.client_ttft ?? metrics.time_to_first_token" in RENDERER
assert '<span class="ctx-label">TTFT</span>' in RENDERER
def test_compact_footer_and_details_show_real_performance_counters():
assert "`${Number(tps).toFixed(2)} tok/s`" in RENDERER
assert "const visibleTtft = metrics.client_ttft ?? metrics.time_to_first_token" in RENDERER
assert "${Number(visibleTtft).toFixed(3)}s" in RENDERER
assert '<span class="ctx-label">Input</span>' in RENDERER
# Injected-context size is no longer a separate details row.
assert '<span class="ctx-label">Injected</span>' not in RENDERER
assert 'all rounds' not in RENDERER
assert 'first request' not in RENDERER
assert 'Tool schemas' in RENDERER
assert 'Agent rounds' in RENDERER
assert 'Tool calls' in RENDERER
assert "metrics.tps_source === 'computed' ? 'Speed (wall)'" in RENDERER