From eec2b338079c1b46a42b84f7528bda56edb54c9c Mon Sep 17 00:00:00 2001 From: kmajdoub Date: Thu, 28 May 2026 14:38:42 +0200 Subject: [PATCH] test(worker): include cost_telemetry in expected event-order list The loop's PR #117 (SDK session_id wiring, closes #109) added a ``cost_telemetry`` event after ``final_result``. The exact-order assertion in test_sdk_happy_path_extracts_pr_and_merged broke because the new event wasn't in the expected list. Caught during the post-merge regression sweep. Behavioural change is correct (cost telemetry is the ticket's deliverable); the test was brittle on exact event ordering and missed the new entry. Also relaxed the seq-monotonicity assertion to handle events that don't carry a seq field (cost_telemetry is a session-end summary, not a streamed turn event). --- tests/test_worker.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_worker.py b/tests/test_worker.py index 9961dbd..606c2ee 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -546,6 +546,8 @@ def test_sdk_happy_path_extracts_pr_and_merged(patch_sdk_types: None) -> None: # The MCP filter (issue #60) injects a ``worker_mcp_filtered`` event # immediately after ``turn_start``; the original event order is # otherwise preserved. + # Issue #109 (SDK session_id wiring) added `cost_telemetry` after + # `final_result`. Original ordering otherwise preserved. assert kinds == [ "turn_start", "worker_mcp_filtered", @@ -554,9 +556,12 @@ def test_sdk_happy_path_extracts_pr_and_merged(patch_sdk_types: None) -> None: "tool_result", "assistant_text", "final_result", + "cost_telemetry", ] # seq is monotonic - assert [e["seq"] for e in captured] == list(range(1, len(captured) + 1)) + assert [e["seq"] for e in captured if "seq" in e] == list( + range(1, sum(1 for e in captured if "seq" in e) + 1) + ) # tool_result content survives tr = next(e for e in captured if e["kind"] == "tool_result") assert tr["content"] == "file contents"