rho-coding-agent 2.19.0

A fast Rust agent harness with a small footprint and opinionated defaults
use pretty_assertions::assert_eq;

use super::*;

const READY: SetupState = SetupState { signed_in: true };
const SIGNED_OUT: SetupState = SetupState { signed_in: false };

/// The header announces itself only when the session cannot run a turn. A
/// first launch says its welcome on the setup screen, so repeating it here
/// would greet the user twice.
#[test]
fn only_a_signed_out_session_adds_a_headline() {
    let cases = [(READY, false), (SIGNED_OUT, true)];

    for (setup, expected) in cases {
        assert_eq!(
            setup.headline().is_some(),
            expected,
            "headline presence for {setup:?}"
        );
    }
}

/// Login is the only next step Rho pushes, and only while a session cannot run
/// a turn. A signed-in session must never be told to log in.
#[test]
fn login_is_the_next_step_exactly_while_signed_out() {
    let cases = [(READY, 0), (SIGNED_OUT, 1)];

    for (setup, expected) in cases {
        let next_steps = setup
            .hints(HeaderHints::Shown)
            .iter()
            .filter(|hint| hint.tone == HintTone::NextStep)
            .count();
        assert_eq!(next_steps, expected, "next-step hints for {setup:?}");
        if expected > 0 {
            assert_eq!(
                setup
                    .hints(HeaderHints::Shown)
                    .first()
                    .map(|hint| hint.tone),
                Some(HintTone::NextStep),
                "the next step must lead the hint block for {setup:?}"
            );
        }
    }
}

/// Hiding header hints drops the reference block, but never the step that
/// unblocks a signed-out session.
#[test]
fn hidden_header_hints_keep_the_signed_out_next_step() {
    assert_eq!(READY.hints(HeaderHints::Hidden), &[] as &[Hint]);
    assert_eq!(
        SIGNED_OUT.hints(HeaderHints::Hidden),
        SIGNED_OUT.hints(HeaderHints::Shown)
    );
}