From b30f02a3f08c3dff94f04eca83d684bb569cb41a Mon Sep 17 00:00:00 2001 From: Wes Huber Date: Tue, 2 Jun 2026 22:12:17 -0700 Subject: [PATCH] fix(tests): align broken test assertions with current behavior (#1791) * fix(tests): align broken test assertions with current behavior - test_readme_native_quickstart_uses_loopback: README warning text moved from --host prefix to bind-to phrasing; update assertion - test_sanitize_merges_consecutive_user_messages: consecutive user messages ARE merged and orphan tool messages ARE dropped by the adjacency repair pass; update expected counts and values Co-Authored-By: Claude Opus 4.6 (1M context) * fix(tests): update cookbook status poll assertion for stopped state The cookbookRunning.js ternary now handles a 'stopped' status alongside 'error', so the exact string match in the test no longer holds. Relax the assertion to check for the error branch presence instead of the full ternary expression. Co-Authored-By: Claude Opus 4.6 (1M context) --------- Co-authored-by: Claude Opus 4.6 (1M context) --- .../test_cookbook_dependency_completion_regression.py | 2 +- tests/test_llm_core_sanitize_tool_calls.py | 10 +++++----- tests/test_security_regressions.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_cookbook_dependency_completion_regression.py b/tests/test_cookbook_dependency_completion_regression.py index 3de226c..642611e 100644 --- a/tests/test_cookbook_dependency_completion_regression.py +++ b/tests/test_cookbook_dependency_completion_regression.py @@ -22,7 +22,7 @@ def test_background_status_poll_reconciles_into_local_tasks(): assert "const statusById = new Map(tasks.map(t => [t.session_id, t]));" in source assert "const nextStatus = live.status === 'completed'" in source assert "? 'done'" in source - assert ": (live.status === 'error' ? 'error' : null);" in source + assert "live.status === 'error'" in source assert "_saveTasks(localTasks);" in source assert "completedDeps.forEach(t => _refreshDepsAfterInstall(t));" in source diff --git a/tests/test_llm_core_sanitize_tool_calls.py b/tests/test_llm_core_sanitize_tool_calls.py index c71933a..7ff319b 100644 --- a/tests/test_llm_core_sanitize_tool_calls.py +++ b/tests/test_llm_core_sanitize_tool_calls.py @@ -74,16 +74,16 @@ def test_sanitize_merges_consecutive_user_messages(): ] out = _sanitize_llm_messages(messages) - # Only consecutive user messages should be merged. - # Consecutive system/assistant/tool messages are left as-is. - assert len(out) == 7 + # Consecutive user messages are merged into one. + # Consecutive system/assistant messages are left as-is. + # Orphan tool messages (no preceding assistant with tool_calls) are + # dropped by the adjacency repair pass per the OpenAI spec. + assert len(out) == 5 assert out[0] == {"role": "system", "content": "System message 1"} assert out[1] == {"role": "system", "content": "System message 2"} assert out[2] == {"role": "user", "content": "User message 1\n\nUser message 2"} assert out[3] == {"role": "assistant", "content": "Assistant message 1"} assert out[4] == {"role": "assistant", "content": "Assistant message 2"} - assert out[5] == {"role": "tool", "content": "Tool output 1", "tool_call_id": "c1"} - assert out[6] == {"role": "tool", "content": "Tool output 2", "tool_call_id": "c2"} def test_sanitize_merges_search_results_and_user_query(): diff --git a/tests/test_security_regressions.py b/tests/test_security_regressions.py index 1f8e397..0792b9a 100644 --- a/tests/test_security_regressions.py +++ b/tests/test_security_regressions.py @@ -122,7 +122,7 @@ def test_docker_compose_binds_web_ui_to_loopback_by_default(): def test_readme_native_quickstart_uses_loopback(): readme = Path("README.md").read_text(encoding="utf-8") assert "python -m uvicorn app:app --host 127.0.0.1 --port 7000" in readme - assert "Use `--host 0.0.0.0` only when you intentionally want" in readme + assert "0.0.0.0` only when you intentionally want" in readme def test_ollama_cookbook_runner_does_not_force_public_bind():