Skip to content

test: unit tests for episode_to_html, agent_xray helpers, overlay_utils - #59

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/unit-tests-analyze-viz
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/unit-tests-analyze-viz

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Summary

Adds hermetic unit tests for the episode HTML export, AgentXray's non-UI helpers, and overlay utils. Only three new test files; no src/ or existing test changes.

  • tests/analyze/test_episode_to_html.py builds a synthetic exp dir in tmp_path via StepInfo.save_step_info + ExpResult, then checks exp_result_to_html output: base64 data-URI vs file:// images (embed_images), the open/closed flags on sections, <script> escaping in goal/think/action/chat, plus tool-call and message-type formatting.
  • tests/analyze/test_agent_xray_helpers.py covers the dataframe helpers, ClickMapper, markdown/chat formatting, screenshots/gallery, the update_* tabs, submit_action (OpenAI is mocked), the selection callbacks, get_directory_contents, and profiling. An autouse fixture swaps in a fresh agent_xray.info for each test so nothing leaks between tests (safe under xdist and random order). Gradio is never launched.
  • tests/analyze/test_overlay_utils_unit.py covers AST parsing of parse_function_calls, bid and x/y pair merging, the PIL overlays and linedashed, annotate_action, and create_colored_html.

Coverage (target modules)

Module Before (main) After
episode_to_html 0% 91% (only the __main__ block, lines 424-442, is uncovered)
agent_xray 0% 74% (mostly the Gradio run_gradio UI construction, lines 178-550)
overlay_utils 57% 98%

Tests: 159 passed, 7 xfailed (140 test functions, some parametrized). About 7s serially and about 10s with -n 4.

Strict-xfailed source bugs (not fixed here)

  • episode_to_html.exp_result_to_html: task_name is put into the HTML without escaping.
  • episode_to_html._format_chat_messages_like_xray: the chat message role is not HTML-escaped.
  • agent_xray.Info.update_exp_result: there is no return after the result_df is None guard.
  • agent_xray.dict_msg_to_markdown: dict messages with plain-string content crash because the code iterates over the string's characters.
  • agent_xray.update_agent_info_html: when html_page is missing, the default is a list, which _page_to_iframe can't encode.
  • agent_xray.get_episode_info: errors when obs has no goal_object (str(BaseMessage("", None))), even though the KeyError is caught deliberately.
  • overlay_utils.create_colored_html: raw action text is inserted into the HTML without escaping.

Run

uv run pytest tests/analyze/test_episode_to_html.py tests/analyze/test_agent_xray_helpers.py tests/analyze/test_overlay_utils_unit.py -p no:cacheprovider -q   # add -n 4 for xdist

Devin-Org: engineering

Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/f0c73caf2b6e4a29a47075802f0b5f32
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/f0c73caf2b6e4a29a47075802f0b5f32?variant=devin
Requested by: @danigrim


Devin Review

…rlay_utils

Co-Authored-By: Daniella Grimberg <daniella@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant