Raxol.Test.Integration (Raxol v0.5.0)

View Source

Provides utilities for testing component interactions and system integration.

This module focuses on testing:

  • Multi-component interactions
  • Event propagation between components
  • State synchronization
  • Terminal I/O simulation
  • Component hierarchy behavior

Example

defmodule MyApp.IntegrationTest do
  use ExUnit.Case
  use Raxol.Test.Integration

  test_scenario "parent-child communication", %{parent: Parent, child: Child} do
    # Set up component hierarchy
    {:ok, parent, child} = setup_component_hierarchy(Parent, Child)

    # Simulate user interaction
    simulate_user_action(parent, {:click, {10, 10}})

    # Verify component interaction
    assert_child_received(child, :parent_clicked)
    assert_parent_updated(parent, :child_responded)
  end
end

Summary

Functions

Verifies that a component properly handles a system event.

Simulates component mounting in the application.

Sets up a parent-child component hierarchy for testing.

Sets up a test scenario with multiple components.

Simulates a user action on a component.

Simulates component unmounting from the application.

Functions

assert_handles_system_event(component, event)

Verifies that a component properly handles a system event.

mount_component(component, parent \\ nil)

Simulates component mounting in the application.

setup_component_hierarchy(parent_module, child_module, opts \\ [])

Sets up a parent-child component hierarchy for testing.

Returns the initialized parent and child components with proper event routing.

setup_test_scenario(components)

Sets up a test scenario with multiple components.

This function:

  1. Initializes all components
  2. Sets up event routing
  3. Configures component relationships
  4. Establishes test monitoring

simulate_user_action(component, action)

Simulates a user action on a component.

Handles various types of user interactions and ensures proper event propagation.

test_scenario(name, components, list)

(macro)

unmount_component(component)

Simulates component unmounting from the application.