Skip to content

Refactor tests to avoid mutating TUI context directly #210

@panarch

Description

@panarch

Summary

Several notebook view snapshot tests currently poke into App::context_mut() to flip internal state (e.g. setting last_log, mutating tabs, forcing vim_keymap). This bypasses real user flows and makes the tests fragile.

Examples

  • tui/tests/notebook_views.rs manually edits context.notebook.editors, pushes synthetic tabs, and sets breadcrumb vectors directly.
  • The same file toggles context.vim_keymap to display overlays instead of driving the key sequences that would normally open them.

Impact

  • Tests couple snapshots to internal implementation details instead of public behaviour.
  • It is hard to refactor the TUI context because tests rely on private state.
  • App::context_mut remains in tui/app.rs purely to support these tests.

Proposal

  1. Introduce helper functions or actions that exercise the notebook flows through real transitions (e.g. dedicated commands to show Vim keymaps, helpers for log/saving indicators).
  2. Refactor tests to use those helpers or existing input sequences instead of reaching into context.
  3. Remove App::context_mut entirely once no tests depend on it.

Acceptance Criteria

  • Notebook view snapshot tests operate via user-level inputs or dedicated helpers; no direct context mutation remains.
  • App::context_mut is no longer needed and is removed from tui/app.rs.
  • Existing coverage stays unchanged after the refactor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions