Skip to content

test: extract shared _build_overlay_call_order_fixtures helper in test_actions.py - #311

Merged
dhruvbatra merged 1 commit into
mainfrom
claude/admiring-hawking-5tb64v
Sep 1, 2026
Merged

test: extract shared _build_overlay_call_order_fixtures helper in test_actions.py#311
dhruvbatra merged 1 commit into
mainfrom
claude/admiring-hawking-5tb64v

Conversation

@dhruvbatra

@dhruvbatra dhruvbatra commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Issue

Six overlay-preview tests in tests/test_actions.py each hand-rolled the same arrange block before wiring their own overlay behaviour:

call_order: list[tuple[Any, ...]] = []
page = _make_overlay_enabled_page(call_order)
overlay = MagicMock()
...                                    # test-specific wiring
executor, viewport = _build_overlay_action_fixtures(module, overlay)

The sites are _build_move_down_up_overlay_fixtures and the left_click, goto_url, key_press/F5, and hover tests. A sixth — the _preview_types inner helper in test_execute_action_key_press_shows_copy_paste_glyph_only_for_bare_chords — additionally re-implemented _build_overlay_action_fixtures by hand, repeating the instantiate_with_supported_kwargs(module.ActionExecutor, navigation_timeout_ms=1_000, settle_delay_seconds=0) + executor.overlay = overlay pair that _build_action_executor already owns.

This is the same duplication class the file has already factored out three times (_build_action_executor, _build_overlay_action_fixtures, _make_overlay_enabled_page); these last sites just weren't covered.

Improvement

Add _build_overlay_call_order_fixtures(module), returning the (call_order, page, overlay, executor, viewport) tuple that _build_move_down_up_overlay_fixtures already returns, and route all six sites through it. Each test keeps its own preview_action / set_status / mouse wiring — the helper stops at the part that was genuinely identical.

Net -33 / +27 lines in one test file.

Safety

  • Test-only; no production code touched, no behavior change. Every assertion is unchanged.
  • The one ordering change is that _build_overlay_action_fixtures now runs before the test attaches its overlay coroutines rather than after. That is equivalent: _build_overlay_action_fixtures only does executor = _build_action_executor(module); executor.overlay = overlay; viewport = ViewportConfig() — it never reads the overlay, and the executor holds a reference to the same MagicMock object, so side effects attached afterwards still take effect. The docstring records this.
  • _preview_types now uses the helper's viewport instead of constructing ViewportConfig() inline at the call — identical, both are the default-constructed config.
  • Verified: uv run pytest tests/ gives 328 passed / 21 failed, and the failing set diffs byte-identical against the same command on origin/main (all pre-existing Chromium-sandbox environment failures in test_browser.py / test_live_runner.py). tests/test_actions.py alone: 40 passed.
  • uv run ruff check src/ tests/ clean; uv run ruff format --check tests/test_actions.py reports already formatted.

Generated by Claude Code


Note

Low Risk
Changes are limited to test helpers and assertions are unchanged; no production code is modified.

Overview
Test-only refactor in tests/test_actions.py: introduces _build_overlay_call_order_fixtures(module) to centralize the repeated overlay call-order arrange block (call_order, overlay-enabled FakePage, MagicMock overlay, and executor/viewport from _build_overlay_action_fixtures).

Six sites now call the helper instead of duplicating that setup: _build_move_down_up_overlay_fixtures, the left-click preview ordering test, navigation set_status, semantic F5 key shortcut, hover preview ordering, and the _preview_types inner helper in the copy/paste glyph test. Each test still wires its own preview_action, set_status, or mouse mocks afterward; the helper’s docstring notes that ordering relative to _build_overlay_action_fixtures does not change behavior because the executor keeps a reference to the same overlay mock.

The copy/paste test also drops hand-rolled ActionExecutor construction in favor of the shared fixtures (same timeout/settle tuning and default ViewportConfig).

Reviewed by Cursor Bugbot for commit cacd6f6. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Tests
    • Consolidated shared test setup for overlay behavior.
    • Updated overlay-related test cases while preserving their specific interaction and execution scenarios.

…t_actions.py

Six overlay-preview tests each hand-rolled the same four-statement arrange
block: a call-order list, an overlay-enabled FakePage recording into it, a
bare MagicMock overlay double, and the overlay-wired executor/viewport pair
from _build_overlay_action_fixtures. They differ only in which overlay
coroutines and page mouse methods they wire up afterwards.

Extract the common part into _build_overlay_call_order_fixtures and route
all six sites through it, including _build_move_down_up_overlay_fixtures
(which previously duplicated it inline) and the _preview_types inner helper
(which additionally re-implemented _build_overlay_action_fixtures by hand).

Test-only, no behavior change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W5i16kvsHTAB61hk5Ehqy1
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: e8ea8d80-f53a-4325-a9f7-154b61d5efaf

📥 Commits

Reviewing files that changed from the base of the PR and between 4943055 and cacd6f6.

📒 Files selected for processing (1)
  • tests/test_actions.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Changes

The test suite centralizes overlay call-order fixture construction in _build_overlay_call_order_fixtures. Overlay action tests reuse the shared executor, viewport, tracking page, and overlay mock while retaining test-specific callbacks and mouse wiring.

Overlay test fixture consolidation

Layer / File(s) Summary
Centralize overlay call-order setup
tests/test_actions.py
Adds a helper for shared overlay call-order state and updates the mouse fixture to use it.
Update overlay action tests
tests/test_actions.py
Updates preview, navigation, shortcut, hover, and key-preview tests to reuse the helper while preserving specific callback setup.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to cacd6

This test-only refactor centralizes duplicated fixture setup while preserving the existing test behavior and assertions. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the test-only change: extracting the shared _build_overlay_call_order_fixtures helper in tests/test_actions.py.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/admiring-hawking-5tb64v

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dhruvbatra
dhruvbatra merged commit 8f39611 into main Sep 1, 2026
4 checks passed
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.

2 participants