//! Integration snapshot tests for the Ratatui TUI components
//!
//! These tests use the `insta` crate to capture visual snapshots of the actual terminal output.
//! This ensures that the TUI continues to render correctly after changes.
//!
//! To update snapshots, run: `cargo insta review`

use insta::assert_snapshot;
use ratatui::{Terminal, backend::TestBackend};

/// Test basic rendering with TestBackend to simulate terminal rendering
#[test]
fn test_basic_terminal_rendering() {
    // Use a TestBackend with fixed dimensions to simulate terminal
    let backend = TestBackend::new(80, 20);
    let mut terminal = Terminal::new(backend).unwrap();

    // Draw a simple frame - this is a basic test of the TestBackend functionality
    terminal
        .draw(|f| {
            // Create a simple area test
            let _area = f.area();
            // This just tests that the backend works without any complex rendering
        })
        .unwrap();

    // Take a snapshot of the terminal backend - this captures the rendered output
    // The snapshot will show an empty terminal with the given dimensions
    assert_snapshot!(format!("{}", terminal.backend()));
}

/// Test terminal rendering with basic content
#[test]
fn test_terminal_rendering_with_content() {
    let backend = TestBackend::new(40, 10);
    let mut terminal = Terminal::new(backend).unwrap();

    // Draw a simple representation
    terminal
        .draw(|f| {
            // Use the frame for basic rendering operations
            // Note: this is basic test of terminal drawing functionality
            let _area = f.area();
        })
        .unwrap();

    assert_snapshot!(format!("{}", terminal.backend()));
}
