module RatatuiRuby::TestHelper::EventInjection

Event injection helpers for testing TUI interactions.

Testing keyboard navigation and mouse clicks requires simulating user input. Constructing event objects by hand for every test is verbose and repetitive.

This mixin provides convenience methods to inject keys, clicks, and other events into the test terminal’s event queue. Events are consumed by the next poll_event call.

Use it to simulate user interactions: typing, clicking, dragging, pasting.

Examples

with_test_terminal do
  inject_keys("h", "e", "l", "l", "o")
  inject_keys(:enter, :ctrl_s)
  inject_click(x: 10, y: 5)
  inject_event(RatatuiRuby::Event::Paste.new(content: "pasted text"))

  @app.run
end