//! Integration tests for `mcptest run` executing `compositions:`.
//!
//! Compositions are a distinct test type the run command drives end to end:
//! it walks the DAG, evaluates each composition's deterministic `expect:`
//! block against the trace, and gates the exit code. `composition-full.yml` is
//! fully mocked, so it runs offline with no servers and no provider keys.

use assert_cmd::Command;
use predicates::prelude::*;

fn mcptest() -> Command {
    Command::cargo_bin("mcptest").expect("binary builds")
}

/// The bundled `composition-full.yml` runs both `cases:` rows green and exits
/// 0, proving compositions are wired into `mcptest run` (not reported as
/// "0 tests discovered").
#[test]
fn run_executes_composition_full_offline_and_passes() {
    mcptest()
        .arg("run")
        .arg("--config")
        .arg("../../examples/composition-full.yml")
        .assert()
        .success()
        .stdout(
            predicate::str::contains("composition [PASS]")
                .and(predicate::str::contains(
                    "ran 2 composition(s): 2 passed, 0 failed",
                ))
                .and(predicate::str::contains("0 tests discovered").not()),
        );
}

/// A compositions-only suite must not be reported as an empty suite.
#[test]
fn compositions_only_suite_is_not_reported_empty() {
    mcptest()
        .arg("run")
        .arg("--config")
        .arg("../../examples/composition-full.yml")
        .assert()
        .stdout(predicate::str::contains("0 tests discovered").not());
}
